@idlapps/t 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});function e(e){return e.replace(/[-_\s]+(.)?/g,(e,t)=>t?t.toUpperCase():``).replace(/^[A-Z]/,e=>e.toLowerCase())}function t(e,t,n=`...`){return e.length<=t?e:e.slice(0,t-n.length)+n}exports.camelCase=e,exports.truncate=t;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});function e(e){return e.replace(/[-_\s]+(.)?/g,(e,t)=>t?t.toUpperCase():``).replace(/^[A-Z]/,e=>e.toLowerCase())}function t(e,t,n=`...`){return e.length<=t?e:e.slice(0,t-n.length)+n}function n(e){return e.replace(/([a-z])([A-Z])/g,`$1-$2`).replace(/[_\s]+/g,`-`).toLowerCase()}exports.camelCase=e,exports.kebabCase=n,exports.truncate=t;
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\n * Converts a string to camelCase.\n *\n * @example\n * ```ts\n * import { camelCase } from \"@idlapps/t\";\n *\n * camelCase(\"hello-world\"); // \"helloWorld\"\n * camelCase(\"foo_bar_baz\"); // \"fooBarBaz\"\n * camelCase(\"Hello World\"); // \"helloWorld\"\n * camelCase(\"alreadyCamel\"); // \"alreadyCamel\"\n * ```\n */\nexport function camelCase(str: string): string {\n return str\n .replace(/[-_\\s]+(.)?/g, (_, char: string | undefined) =>\n char ? char.toUpperCase() : \"\"\n )\n .replace(/^[A-Z]/, (char) => char.toLowerCase());\n}\n\n/**\n * Truncates a string to a maximum length, appending an ellipsis if truncated.\n *\n * @example\n * ```ts\n * import { truncate } from \"@idlapps/t\";\n *\n * truncate(\"Hello, World!\", 5); // \"Hello...\"\n * truncate(\"Hi\", 10); // \"Hi\"\n * truncate(\"abcdefghij\", 7); // \"abcd...\"\n * ```\n */\nexport function truncate(str: string, maxLength: number, suffix = \"...\"): string {\n if (str.length <= maxLength) return str;\n return str.slice(0, maxLength - suffix.length) + suffix;\n}\n"],"mappings":"mEAaA,SAAgB,EAAU,EAAqB,CAC7C,OAAO,EACJ,QAAQ,gBAAiB,EAAG,IAC3B,EAAO,EAAK,YAAY,EAAI,EAC9B,CAAC,CACA,QAAQ,SAAW,GAAS,EAAK,YAAY,CAAC,CACnD,CAcA,SAAgB,EAAS,EAAa,EAAmB,EAAS,MAAe,CAE/E,OADI,EAAI,QAAU,EAAkB,EAC7B,EAAI,MAAM,EAAG,EAAY,EAAO,MAAM,EAAI,CACnD"}
1
+ {"version":3,"file":"index.cjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\n * Converts a string to camelCase.\n *\n * @example\n * ```ts\n * import { camelCase } from \"@idlapps/t\";\n *\n * camelCase(\"hello-world\"); // \"helloWorld\"\n * camelCase(\"foo_bar_baz\"); // \"fooBarBaz\"\n * camelCase(\"Hello World\"); // \"helloWorld\"\n * camelCase(\"alreadyCamel\"); // \"alreadyCamel\"\n * ```\n */\nexport function camelCase(str: string): string {\n return str\n .replace(/[-_\\s]+(.)?/g, (_, char: string | undefined) =>\n char ? char.toUpperCase() : \"\"\n )\n .replace(/^[A-Z]/, (char) => char.toLowerCase());\n}\n\n/**\n * Truncates a string to a maximum length, appending an ellipsis if truncated.\n *\n * @example\n * ```ts\n * import { truncate } from \"@idlapps/t\";\n *\n * truncate(\"Hello, World!\", 5); // \"Hello...\"\n * truncate(\"Hi\", 10); // \"Hi\"\n * truncate(\"abcdefghij\", 7); // \"abcd...\"\n * ```\n */\nexport function truncate(str: string, maxLength: number, suffix = \"...\"): string {\n if (str.length <= maxLength) return str;\n return str.slice(0, maxLength - suffix.length) + suffix;\n}\n\n/**\n * Converts a string to kebab-case.\n *\n * @example\n * ```ts\n * import { kebabCase } from \"@idlapps/t\";\n *\n * kebabCase(\"helloWorld\"); // \"hello-world\"\n * kebabCase(\"foo_bar_baz\"); // \"foo-bar-baz\"\n * kebabCase(\"Hello World\"); // \"hello-world\"\n * ```\n */\nexport function kebabCase(str: string): string {\n return str\n .replace(/([a-z])([A-Z])/g, \"$1-$2\")\n .replace(/[_\\s]+/g, \"-\")\n .toLowerCase();\n}\n"],"mappings":"mEAaA,SAAgB,EAAU,EAAqB,CAC7C,OAAO,EACJ,QAAQ,gBAAiB,EAAG,IAC3B,EAAO,EAAK,YAAY,EAAI,EAC9B,CAAC,CACA,QAAQ,SAAW,GAAS,EAAK,YAAY,CAAC,CACnD,CAcA,SAAgB,EAAS,EAAa,EAAmB,EAAS,MAAe,CAE/E,OADI,EAAI,QAAU,EAAkB,EAC7B,EAAI,MAAM,EAAG,EAAY,EAAO,MAAM,EAAI,CACnD,CAcA,SAAgB,EAAU,EAAqB,CAC7C,OAAO,EACJ,QAAQ,kBAAmB,OAAO,CAAC,CACnC,QAAQ,UAAW,GAAG,CAAC,CACvB,YAAY,CACjB"}
package/dist/index.d.cts CHANGED
@@ -26,6 +26,19 @@ declare function camelCase(str: string): string;
26
26
  * ```
27
27
  */
28
28
  declare function truncate(str: string, maxLength: number, suffix?: string): string;
29
+ /**
30
+ * Converts a string to kebab-case.
31
+ *
32
+ * @example
33
+ * ```ts
34
+ * import { kebabCase } from "@idlapps/t";
35
+ *
36
+ * kebabCase("helloWorld"); // "hello-world"
37
+ * kebabCase("foo_bar_baz"); // "foo-bar-baz"
38
+ * kebabCase("Hello World"); // "hello-world"
39
+ * ```
40
+ */
41
+ declare function kebabCase(str: string): string;
29
42
  //#endregion
30
- export { camelCase, truncate };
43
+ export { camelCase, kebabCase, truncate };
31
44
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;;;;;;;iBAagB,UAAU;;;;;;;;;;;;;iBAoBV,SAAS,aAAa,mBAAmB"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;;;;;;;iBAagB,UAAU;;;;;;;;;;;;;iBAoBV,SAAS,aAAa,mBAAmB;;;;;;;;;;;;;iBAiBzC,UAAU"}
package/dist/index.d.mts CHANGED
@@ -26,6 +26,19 @@ declare function camelCase(str: string): string;
26
26
  * ```
27
27
  */
28
28
  declare function truncate(str: string, maxLength: number, suffix?: string): string;
29
+ /**
30
+ * Converts a string to kebab-case.
31
+ *
32
+ * @example
33
+ * ```ts
34
+ * import { kebabCase } from "@idlapps/t";
35
+ *
36
+ * kebabCase("helloWorld"); // "hello-world"
37
+ * kebabCase("foo_bar_baz"); // "foo-bar-baz"
38
+ * kebabCase("Hello World"); // "hello-world"
39
+ * ```
40
+ */
41
+ declare function kebabCase(str: string): string;
29
42
  //#endregion
30
- export { camelCase, truncate };
43
+ export { camelCase, kebabCase, truncate };
31
44
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;;;;;;;iBAagB,UAAU;;;;;;;;;;;;;iBAoBV,SAAS,aAAa,mBAAmB"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;;;;;;;iBAagB,UAAU;;;;;;;;;;;;;iBAoBV,SAAS,aAAa,mBAAmB;;;;;;;;;;;;;iBAiBzC,UAAU"}
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- function e(e){return e.replace(/[-_\s]+(.)?/g,(e,t)=>t?t.toUpperCase():``).replace(/^[A-Z]/,e=>e.toLowerCase())}function t(e,t,n=`...`){return e.length<=t?e:e.slice(0,t-n.length)+n}export{e as camelCase,t as truncate};
1
+ function e(e){return e.replace(/[-_\s]+(.)?/g,(e,t)=>t?t.toUpperCase():``).replace(/^[A-Z]/,e=>e.toLowerCase())}function t(e,t,n=`...`){return e.length<=t?e:e.slice(0,t-n.length)+n}function n(e){return e.replace(/([a-z])([A-Z])/g,`$1-$2`).replace(/[_\s]+/g,`-`).toLowerCase()}export{e as camelCase,n as kebabCase,t as truncate};
2
2
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\n * Converts a string to camelCase.\n *\n * @example\n * ```ts\n * import { camelCase } from \"@idlapps/t\";\n *\n * camelCase(\"hello-world\"); // \"helloWorld\"\n * camelCase(\"foo_bar_baz\"); // \"fooBarBaz\"\n * camelCase(\"Hello World\"); // \"helloWorld\"\n * camelCase(\"alreadyCamel\"); // \"alreadyCamel\"\n * ```\n */\nexport function camelCase(str: string): string {\n return str\n .replace(/[-_\\s]+(.)?/g, (_, char: string | undefined) =>\n char ? char.toUpperCase() : \"\"\n )\n .replace(/^[A-Z]/, (char) => char.toLowerCase());\n}\n\n/**\n * Truncates a string to a maximum length, appending an ellipsis if truncated.\n *\n * @example\n * ```ts\n * import { truncate } from \"@idlapps/t\";\n *\n * truncate(\"Hello, World!\", 5); // \"Hello...\"\n * truncate(\"Hi\", 10); // \"Hi\"\n * truncate(\"abcdefghij\", 7); // \"abcd...\"\n * ```\n */\nexport function truncate(str: string, maxLength: number, suffix = \"...\"): string {\n if (str.length <= maxLength) return str;\n return str.slice(0, maxLength - suffix.length) + suffix;\n}\n"],"mappings":"AAaA,SAAgB,EAAU,EAAqB,CAC7C,OAAO,EACJ,QAAQ,gBAAiB,EAAG,IAC3B,EAAO,EAAK,YAAY,EAAI,EAC9B,CAAC,CACA,QAAQ,SAAW,GAAS,EAAK,YAAY,CAAC,CACnD,CAcA,SAAgB,EAAS,EAAa,EAAmB,EAAS,MAAe,CAE/E,OADI,EAAI,QAAU,EAAkB,EAC7B,EAAI,MAAM,EAAG,EAAY,EAAO,MAAM,EAAI,CACnD"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\n * Converts a string to camelCase.\n *\n * @example\n * ```ts\n * import { camelCase } from \"@idlapps/t\";\n *\n * camelCase(\"hello-world\"); // \"helloWorld\"\n * camelCase(\"foo_bar_baz\"); // \"fooBarBaz\"\n * camelCase(\"Hello World\"); // \"helloWorld\"\n * camelCase(\"alreadyCamel\"); // \"alreadyCamel\"\n * ```\n */\nexport function camelCase(str: string): string {\n return str\n .replace(/[-_\\s]+(.)?/g, (_, char: string | undefined) =>\n char ? char.toUpperCase() : \"\"\n )\n .replace(/^[A-Z]/, (char) => char.toLowerCase());\n}\n\n/**\n * Truncates a string to a maximum length, appending an ellipsis if truncated.\n *\n * @example\n * ```ts\n * import { truncate } from \"@idlapps/t\";\n *\n * truncate(\"Hello, World!\", 5); // \"Hello...\"\n * truncate(\"Hi\", 10); // \"Hi\"\n * truncate(\"abcdefghij\", 7); // \"abcd...\"\n * ```\n */\nexport function truncate(str: string, maxLength: number, suffix = \"...\"): string {\n if (str.length <= maxLength) return str;\n return str.slice(0, maxLength - suffix.length) + suffix;\n}\n\n/**\n * Converts a string to kebab-case.\n *\n * @example\n * ```ts\n * import { kebabCase } from \"@idlapps/t\";\n *\n * kebabCase(\"helloWorld\"); // \"hello-world\"\n * kebabCase(\"foo_bar_baz\"); // \"foo-bar-baz\"\n * kebabCase(\"Hello World\"); // \"hello-world\"\n * ```\n */\nexport function kebabCase(str: string): string {\n return str\n .replace(/([a-z])([A-Z])/g, \"$1-$2\")\n .replace(/[_\\s]+/g, \"-\")\n .toLowerCase();\n}\n"],"mappings":"AAaA,SAAgB,EAAU,EAAqB,CAC7C,OAAO,EACJ,QAAQ,gBAAiB,EAAG,IAC3B,EAAO,EAAK,YAAY,EAAI,EAC9B,CAAC,CACA,QAAQ,SAAW,GAAS,EAAK,YAAY,CAAC,CACnD,CAcA,SAAgB,EAAS,EAAa,EAAmB,EAAS,MAAe,CAE/E,OADI,EAAI,QAAU,EAAkB,EAC7B,EAAI,MAAM,EAAG,EAAY,EAAO,MAAM,EAAI,CACnD,CAcA,SAAgB,EAAU,EAAqB,CAC7C,OAAO,EACJ,QAAQ,kBAAmB,OAAO,CAAC,CACnC,QAAQ,UAAW,GAAG,CAAC,CACvB,YAAY,CACjB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@idlapps/t",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Lightweight, tree-shakable string utility functions",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",