Skip to content

Commit

Permalink
npm: Add @codinasion/string (codinasion-archive#4904)
Browse files Browse the repository at this point in the history
  • Loading branch information
harshraj8843 authored Dec 27, 2023
1 parent 6845a8a commit eadd657
Show file tree
Hide file tree
Showing 3,303 changed files with 57,313 additions and 1,105 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
6 changes: 6 additions & 0 deletions .changeset/spotty-cats-battle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"codinasion": patch
"@codinasion/eslint-config": patch
---

Add string manipulation
162 changes: 162 additions & 0 deletions .changeset/yellow-grapes-battle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
---
"@codinasion/constant-case-string-to-sentence-case-string": major
"@codinasion/sentence-case-string-to-constant-case-string": major
"@codinasion/constant-case-string-to-header-case-string": major
"@codinasion/constant-case-string-to-pascal-case-string": major
"@codinasion/sentence-case-string-to-header-case-string": major
"@codinasion/sentence-case-string-to-pascal-case-string": major
"@codinasion/constant-case-string-to-camel-case-string": major
"@codinasion/constant-case-string-to-kebab-case-string": major
"@codinasion/constant-case-string-to-lower-case-string": major
"@codinasion/constant-case-string-to-snake-case-string": major
"@codinasion/constant-case-string-to-title-case-string": major
"@codinasion/constant-case-string-to-upper-case-string": major
"@codinasion/sentence-case-string-to-camel-case-string": major
"@codinasion/sentence-case-string-to-kebab-case-string": major
"@codinasion/sentence-case-string-to-lower-case-string": major
"@codinasion/sentence-case-string-to-snake-case-string": major
"@codinasion/sentence-case-string-to-title-case-string": major
"@codinasion/sentence-case-string-to-upper-case-string": major
"@codinasion/constant-case-string-to-path-case-string": major
"@codinasion/header-case-string-to-constant-case-string": major
"@codinasion/header-case-string-to-sentence-case-string": major
"@codinasion/pascal-case-string-to-constant-case-string": major
"@codinasion/pascal-case-string-to-sentence-case-string": major
"@codinasion/sentence-case-string-to-path-case-string": major
"@codinasion/constant-case-string-to-dot-case-string": major
"@codinasion/sentence-case-string-to-dot-case-string": major
"@codinasion/camel-case-string-to-constant-case-string": major
"@codinasion/camel-case-string-to-sentence-case-string": major
"@codinasion/header-case-string-to-pascal-case-string": major
"@codinasion/kebab-case-string-to-constant-case-string": major
"@codinasion/kebab-case-string-to-sentence-case-string": major
"@codinasion/lower-case-string-to-constant-case-string": major
"@codinasion/lower-case-string-to-sentence-case-string": major
"@codinasion/pascal-case-string-to-header-case-string": major
"@codinasion/snake-case-string-to-constant-case-string": major
"@codinasion/snake-case-string-to-sentence-case-string": major
"@codinasion/title-case-string-to-constant-case-string": major
"@codinasion/title-case-string-to-sentence-case-string": major
"@codinasion/upper-case-string-to-constant-case-string": major
"@codinasion/upper-case-string-to-sentence-case-string": major
"@codinasion/header-case-string-to-camel-case-string": major
"@codinasion/header-case-string-to-kebab-case-string": major
"@codinasion/header-case-string-to-lower-case-string": major
"@codinasion/header-case-string-to-snake-case-string": major
"@codinasion/header-case-string-to-title-case-string": major
"@codinasion/header-case-string-to-upper-case-string": major
"@codinasion/pascal-case-string-to-camel-case-string": major
"@codinasion/pascal-case-string-to-kebab-case-string": major
"@codinasion/pascal-case-string-to-lower-case-string": major
"@codinasion/pascal-case-string-to-snake-case-string": major
"@codinasion/pascal-case-string-to-title-case-string": major
"@codinasion/pascal-case-string-to-upper-case-string": major
"@codinasion/camel-case-string-to-header-case-string": major
"@codinasion/camel-case-string-to-pascal-case-string": major
"@codinasion/header-case-string-to-path-case-string": major
"@codinasion/kebab-case-string-to-header-case-string": major
"@codinasion/kebab-case-string-to-pascal-case-string": major
"@codinasion/lower-case-string-to-header-case-string": major
"@codinasion/lower-case-string-to-pascal-case-string": major
"@codinasion/pascal-case-string-to-path-case-string": major
"@codinasion/path-case-string-to-constant-case-string": major
"@codinasion/path-case-string-to-sentence-case-string": major
"@codinasion/snake-case-string-to-header-case-string": major
"@codinasion/snake-case-string-to-pascal-case-string": major
"@codinasion/title-case-string-to-header-case-string": major
"@codinasion/title-case-string-to-pascal-case-string": major
"@codinasion/upper-case-string-to-header-case-string": major
"@codinasion/upper-case-string-to-pascal-case-string": major
"@codinasion/camel-case-string-to-kebab-case-string": major
"@codinasion/camel-case-string-to-lower-case-string": major
"@codinasion/camel-case-string-to-snake-case-string": major
"@codinasion/camel-case-string-to-title-case-string": major
"@codinasion/camel-case-string-to-upper-case-string": major
"@codinasion/header-case-string-to-dot-case-string": major
"@codinasion/kebab-case-string-to-camel-case-string": major
"@codinasion/kebab-case-string-to-lower-case-string": major
"@codinasion/kebab-case-string-to-snake-case-string": major
"@codinasion/kebab-case-string-to-title-case-string": major
"@codinasion/kebab-case-string-to-upper-case-string": major
"@codinasion/lower-case-string-to-camel-case-string": major
"@codinasion/lower-case-string-to-kebab-case-string": major
"@codinasion/lower-case-string-to-snake-case-string": major
"@codinasion/lower-case-string-to-title-case-string": major
"@codinasion/lower-case-string-to-upper-case-string": major
"@codinasion/pascal-case-string-to-dot-case-string": major
"@codinasion/snake-case-string-to-camel-case-string": major
"@codinasion/snake-case-string-to-kebab-case-string": major
"@codinasion/snake-case-string-to-lower-case-string": major
"@codinasion/snake-case-string-to-title-case-string": major
"@codinasion/snake-case-string-to-upper-case-string": major
"@codinasion/title-case-string-to-camel-case-string": major
"@codinasion/title-case-string-to-kebab-case-string": major
"@codinasion/title-case-string-to-lower-case-string": major
"@codinasion/title-case-string-to-snake-case-string": major
"@codinasion/title-case-string-to-upper-case-string": major
"@codinasion/upper-case-string-to-camel-case-string": major
"@codinasion/upper-case-string-to-kebab-case-string": major
"@codinasion/upper-case-string-to-lower-case-string": major
"@codinasion/upper-case-string-to-snake-case-string": major
"@codinasion/upper-case-string-to-title-case-string": major
"@codinasion/camel-case-string-to-path-case-string": major
"@codinasion/dot-case-string-to-constant-case-string": major
"@codinasion/dot-case-string-to-sentence-case-string": major
"@codinasion/kebab-case-string-to-path-case-string": major
"@codinasion/lower-case-string-to-path-case-string": major
"@codinasion/path-case-string-to-header-case-string": major
"@codinasion/path-case-string-to-pascal-case-string": major
"@codinasion/snake-case-string-to-path-case-string": major
"@codinasion/title-case-string-to-path-case-string": major
"@codinasion/upper-case-string-to-path-case-string": major
"@codinasion/camel-case-string-to-dot-case-string": major
"@codinasion/kebab-case-string-to-dot-case-string": major
"@codinasion/lower-case-string-to-dot-case-string": major
"@codinasion/path-case-string-to-camel-case-string": major
"@codinasion/path-case-string-to-kebab-case-string": major
"@codinasion/path-case-string-to-lower-case-string": major
"@codinasion/path-case-string-to-snake-case-string": major
"@codinasion/path-case-string-to-title-case-string": major
"@codinasion/path-case-string-to-upper-case-string": major
"@codinasion/snake-case-string-to-dot-case-string": major
"@codinasion/title-case-string-to-dot-case-string": major
"@codinasion/upper-case-string-to-dot-case-string": major
"@codinasion/dot-case-string-to-header-case-string": major
"@codinasion/dot-case-string-to-pascal-case-string": major
"@codinasion/dot-case-string-to-camel-case-string": major
"@codinasion/dot-case-string-to-kebab-case-string": major
"@codinasion/dot-case-string-to-lower-case-string": major
"@codinasion/dot-case-string-to-snake-case-string": major
"@codinasion/dot-case-string-to-title-case-string": major
"@codinasion/dot-case-string-to-upper-case-string": major
"@codinasion/path-case-string-to-dot-case-string": major
"@codinasion/dot-case-string-to-path-case-string": major
"@codinasion/constant-case-string": major
"@codinasion/sentence-case-string": major
"@codinasion/header-case-string": major
"@codinasion/pascal-case-string": major
"@codinasion/camel-case-string": major
"@codinasion/kebab-case-string": major
"@codinasion/lower-case-string": major
"@codinasion/snake-case-string": major
"@codinasion/title-case-string": major
"@codinasion/upper-case-string": major
"@codinasion/path-case-string": major
"@codinasion/dot-case-string": major
"@codinasion/string-to-constant-case": major
"@codinasion/string-to-sentence-case": major
"@codinasion/string-to-header-case": major
"@codinasion/string-to-pascal-case": major
"@codinasion/string-to-camel-case": major
"@codinasion/string-to-kebab-case": major
"@codinasion/string-to-lower-case": major
"@codinasion/string-to-snake-case": major
"@codinasion/string-to-title-case": major
"@codinasion/string-to-upper-case": major
"@codinasion/string-to-path-case": major
"@codinasion/string-to-dot-case": major
"@codinasion/case": major
"@codinasion/string": major
---

Initial Release
2 changes: 1 addition & 1 deletion .github/workflows/tweet-gfi-data.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Tweet GFI Data

on:
schedule:
- cron: "7 1/3 * * *"
- cron: "12 0/1 * * *"
workflow_dispatch:
inputs:
TEST:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tweet-meme.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Tweet Meme

on:
schedule:
- cron: "17 2/3 * * *"
- cron: "17 0/1 * * *"
workflow_dispatch:
inputs:
TEST:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tweet-quote-data.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Tweet Quote Data

on:
schedule:
- cron: "17 3/5 * * *"
- cron: "23 0/1 * * *"
workflow_dispatch:
inputs:
TEST:
Expand Down
2 changes: 1 addition & 1 deletion action/src/twitter/quote/fetch-quote-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default async function FetchQuoteData(): Promise<QuoteType> {

const data = (await response.json()) as QuoteType[];

return data[0] as QuoteType;
return data[0];
} catch (error) {
core.setFailed(
error instanceof Error ? error.message : "Unknown error occurred",
Expand Down
1 change: 1 addition & 0 deletions npm/packages/codinasion/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from "./dsa";
export * from "./language-data";
export * from "./number-system";
export * from "./string";
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { CamelCaseStringToConstantCaseString } from "./camel-case-string-to-constant-case-string";

describe("CamelCaseStringToConstantCaseString", () => {
test("converts camelCase to CONSTANT_CASE", () => {
expect(CamelCaseStringToConstantCaseString("helloWorld")).toBe(
"HELLO_WORLD",
);
expect(CamelCaseStringToConstantCaseString("thisIsATest")).toBe(
"THIS_IS_A_TEST",
);
expect(CamelCaseStringToConstantCaseString("anotherExample")).toBe(
"ANOTHER_EXAMPLE",
);
});

test("returns empty string for empty input", () => {
expect(CamelCaseStringToConstantCaseString("")).toBe("");
});

test("throws error for non-string input", () => {
expect(() =>
CamelCaseStringToConstantCaseString(null as unknown as string),
).toThrow();
expect(() =>
CamelCaseStringToConstantCaseString(undefined as unknown as string),
).toThrow();
expect(() =>
CamelCaseStringToConstantCaseString(123 as unknown as string),
).toThrow();
expect(() =>
CamelCaseStringToConstantCaseString({} as unknown as string),
).toThrow();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* Converts a camel case string to a constant case string.
*
* @param str - The camel case string to convert.
* @returns The converted constant case string.
*/
export function CamelCaseStringToConstantCaseString(str: string): string {
return str.replace(/[A-Z]/g, (match) => `_${match}`).toUpperCase();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./camel-case-string-to-constant-case-string";
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { CamelCaseStringToDotCaseString } from "./camel-case-string-to-dot-case-string";

describe("CamelCaseStringToDotCaseString", () => {
test("converts camelCase to dot.case", () => {
expect(CamelCaseStringToDotCaseString("helloWorld")).toBe("hello.world");
expect(CamelCaseStringToDotCaseString("thisIsATest")).toBe(
"this.is.a.test",
);
expect(CamelCaseStringToDotCaseString("anotherExample")).toBe(
"another.example",
);
});

test("returns empty string for empty input", () => {
expect(CamelCaseStringToDotCaseString("")).toBe("");
});

test("throws error for non-string input", () => {
expect(() =>
CamelCaseStringToDotCaseString(null as unknown as string),
).toThrow();
expect(() =>
CamelCaseStringToDotCaseString(undefined as unknown as string),
).toThrow();
expect(() =>
CamelCaseStringToDotCaseString(123 as unknown as string),
).toThrow();
expect(() =>
CamelCaseStringToDotCaseString({} as unknown as string),
).toThrow();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Converts a camel case string to dot case string.
* @param str - The camel case string to convert.
* @returns The dot case string.
*/
export function CamelCaseStringToDotCaseString(str: string): string {
return str.replace(/[A-Z]/g, (match) => `.${match.toLowerCase()}`);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./camel-case-string-to-dot-case-string";
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { CamelCaseStringToHeaderCaseString } from "./camel-case-string-to-header-case-string";

describe("CamelCaseStringToHeaderCaseString", () => {
test("converts a camelCase string to header-case", () => {
expect(CamelCaseStringToHeaderCaseString("camelCaseString")).toBe(
"Camel-Case-String",
);
expect(CamelCaseStringToHeaderCaseString("anotherCamelCaseString")).toBe(
"Another-Camel-Case-String",
);
});

test("returns an empty string if input is empty", () => {
expect(CamelCaseStringToHeaderCaseString("")).toBe("");
});

test("returns the same string if input is already in header-case", () => {
expect(CamelCaseStringToHeaderCaseString("header-case-string")).toBe(
"Header-Case-String",
);
expect(CamelCaseStringToHeaderCaseString("Header-Case-String")).toBe(
"Header-Case-String",
);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* Converts a camel case string to header case string.
*
* @param str - The camel case string to convert.
* @returns The converted header case string.
*/
export function CamelCaseStringToHeaderCaseString(str: string): string {
return str
.replace(/(?<temp2>[a-z])(?<temp1>[A-Z])/g, "$1-$2")
.replace(/\b\w/g, (match) => match.toUpperCase());
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./camel-case-string-to-header-case-string";
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { CamelCaseStringToKebabCaseString } from "./camel-case-string-to-kebab-case-string";

describe("CamelCaseStringToKebabCaseString", () => {
test("converts a camelCase string to kebab-case", () => {
expect(CamelCaseStringToKebabCaseString("camelCaseString")).toBe(
"camel-case-string",
);
expect(CamelCaseStringToKebabCaseString("anotherCamelCaseString")).toBe(
"another-camel-case-string",
);
});

test("returns an empty string if input is empty", () => {
expect(CamelCaseStringToKebabCaseString("")).toBe("");
});

test("returns the same string if input is already in kebab-case", () => {
expect(CamelCaseStringToKebabCaseString("kebab-case-string")).toBe(
"kebab-case-string",
);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* Converts a camel case string to kebab case string.
*
* @param str - The camel case string to convert.
* @returns The kebab case string.
*/
export function CamelCaseStringToKebabCaseString(str: string): string {
return str.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./camel-case-string-to-kebab-case-string";
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { CamelCaseStringToLowerCaseString } from "./camel-case-string-to-lower-case-string";

describe("CamelCaseStringToLowerCaseString", () => {
test("converts a camelCase string to lower case", () => {
expect(CamelCaseStringToLowerCaseString("camelCaseString")).toBe(
"camel case string",
);
expect(CamelCaseStringToLowerCaseString("anotherCamelCaseString")).toBe(
"another camel case string",
);
});

test("returns an empty string if input is empty", () => {
expect(CamelCaseStringToLowerCaseString("")).toBe("");
});

test("returns the same string if input is already in lower case", () => {
expect(CamelCaseStringToLowerCaseString("lower case string")).toBe(
"lower case string",
);
});
});
Loading

0 comments on commit eadd657

Please sign in to comment.