ns-string-utils 1.0.0
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 +45 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/package.json +37 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
toKebabCase: () => toKebabCase,
|
|
24
|
+
toPascalCase: () => toPascalCase,
|
|
25
|
+
toSnakeCase: () => toSnakeCase
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(index_exports);
|
|
28
|
+
|
|
29
|
+
// src/string/case.ts
|
|
30
|
+
function toKebabCase(input) {
|
|
31
|
+
return input.trim().replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").replace(/[^a-z0-9-]/gi, "").toLowerCase();
|
|
32
|
+
}
|
|
33
|
+
function toPascalCase(input) {
|
|
34
|
+
return input.trim().split(/[-_\s]+/).map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join("");
|
|
35
|
+
}
|
|
36
|
+
function toSnakeCase(input) {
|
|
37
|
+
return toKebabCase(input).replace(/-/g, "_");
|
|
38
|
+
}
|
|
39
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
40
|
+
0 && (module.exports = {
|
|
41
|
+
toKebabCase,
|
|
42
|
+
toPascalCase,
|
|
43
|
+
toSnakeCase
|
|
44
|
+
});
|
|
45
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/string/case.ts"],"sourcesContent":["export { toKebabCase, toPascalCase, toSnakeCase } from \"./string/case.js\";\n","export function toKebabCase(input: string): string {\n return input\n .trim()\n .replace(/([a-z])([A-Z])/g, \"$1-$2\")\n .replace(/[\\s_]+/g, \"-\")\n .replace(/[^a-z0-9-]/gi, \"\")\n .toLowerCase();\n}\n\nexport function toPascalCase(input: string): string {\n return input\n .trim()\n .split(/[-_\\s]+/)\n .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())\n .join(\"\");\n}\n\nexport function toSnakeCase(input: string): string {\n return toKebabCase(input).replace(/-/g, \"_\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,SAAS,YAAY,OAAuB;AACjD,SAAO,MACJ,KAAK,EACL,QAAQ,mBAAmB,OAAO,EAClC,QAAQ,WAAW,GAAG,EACtB,QAAQ,gBAAgB,EAAE,EAC1B,YAAY;AACjB;AAEO,SAAS,aAAa,OAAuB;AAClD,SAAO,MACJ,KAAK,EACL,MAAM,SAAS,EACf,IAAI,CAAC,SAAS,KAAK,OAAO,CAAC,EAAE,YAAY,IAAI,KAAK,MAAM,CAAC,EAAE,YAAY,CAAC,EACxE,KAAK,EAAE;AACZ;AAEO,SAAS,YAAY,OAAuB;AACjD,SAAO,YAAY,KAAK,EAAE,QAAQ,MAAM,GAAG;AAC7C;","names":[]}
|
package/dist/index.d.cts
ADDED
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// src/string/case.ts
|
|
2
|
+
function toKebabCase(input) {
|
|
3
|
+
return input.trim().replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").replace(/[^a-z0-9-]/gi, "").toLowerCase();
|
|
4
|
+
}
|
|
5
|
+
function toPascalCase(input) {
|
|
6
|
+
return input.trim().split(/[-_\s]+/).map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join("");
|
|
7
|
+
}
|
|
8
|
+
function toSnakeCase(input) {
|
|
9
|
+
return toKebabCase(input).replace(/-/g, "_");
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
toKebabCase,
|
|
13
|
+
toPascalCase,
|
|
14
|
+
toSnakeCase
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/string/case.ts"],"sourcesContent":["export function toKebabCase(input: string): string {\n return input\n .trim()\n .replace(/([a-z])([A-Z])/g, \"$1-$2\")\n .replace(/[\\s_]+/g, \"-\")\n .replace(/[^a-z0-9-]/gi, \"\")\n .toLowerCase();\n}\n\nexport function toPascalCase(input: string): string {\n return input\n .trim()\n .split(/[-_\\s]+/)\n .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())\n .join(\"\");\n}\n\nexport function toSnakeCase(input: string): string {\n return toKebabCase(input).replace(/-/g, \"_\");\n}\n"],"mappings":";AAAO,SAAS,YAAY,OAAuB;AACjD,SAAO,MACJ,KAAK,EACL,QAAQ,mBAAmB,OAAO,EAClC,QAAQ,WAAW,GAAG,EACtB,QAAQ,gBAAgB,EAAE,EAC1B,YAAY;AACjB;AAEO,SAAS,aAAa,OAAuB;AAClD,SAAO,MACJ,KAAK,EACL,MAAM,SAAS,EACf,IAAI,CAAC,SAAS,KAAK,OAAO,CAAC,EAAE,YAAY,IAAI,KAAK,MAAM,CAAC,EAAE,YAAY,CAAC,EACxE,KAAK,EAAE;AACZ;AAEO,SAAS,YAAY,OAAuB;AACjD,SAAO,YAAY,KAAK,EAAE,QAAQ,MAAM,GAAG;AAC7C;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ns-string-utils",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "String utilities for Node.js projects",
|
|
5
|
+
"main": "./dist/index.cjs",
|
|
6
|
+
"module": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"require": "./dist/index.cjs"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsup",
|
|
20
|
+
"test": "vitest run",
|
|
21
|
+
"prepare": "npm run build",
|
|
22
|
+
"prepublishOnly": "npm test"
|
|
23
|
+
},
|
|
24
|
+
"keywords": [
|
|
25
|
+
"string",
|
|
26
|
+
"utils",
|
|
27
|
+
"typescript"
|
|
28
|
+
],
|
|
29
|
+
"author": "Gabino",
|
|
30
|
+
"license": "MIT",
|
|
31
|
+
"type": "module",
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"tsup": "^8.5.1",
|
|
34
|
+
"typescript": "^6.0.3",
|
|
35
|
+
"vitest": "^4.1.7"
|
|
36
|
+
}
|
|
37
|
+
}
|