nhb-toolbox 0.8.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/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # NHB ToolBox
2
+
3
+ - A versatile collection of smart, efficient, and reusable utility functions for everyday development needs.
@@ -0,0 +1,2 @@
1
+ export * from './string';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Utility to convert the first letter of any string to uppercase and the rest lowercase (unless specified).
3
+ * @param string String to be capitalized.
4
+ * @param capEach If true, capitalizes the first letter of each word (space separated). Defaults to `false`.
5
+ * @param lowerRest If true, ensures that the rest of the string is lowercase. Defaults to `true`.
6
+ * @returns Capitalized string.
7
+ */
8
+ const capitalizeString = (string, capEach = false, lowerRest = true) => {
9
+ if (!string)
10
+ return '';
11
+ const trimmedString = string.trim();
12
+ if (!trimmedString)
13
+ return '';
14
+ if (capEach) {
15
+ return trimmedString
16
+ .split(' ')
17
+ .map((word) => capitalizeString(word, false, lowerRest))
18
+ .join(' ');
19
+ }
20
+ else {
21
+ if (lowerRest) {
22
+ return trimmedString
23
+ .charAt(0)
24
+ .toUpperCase()
25
+ .concat(trimmedString.slice(1).toLowerCase());
26
+ }
27
+ return trimmedString
28
+ .charAt(0)
29
+ .toUpperCase()
30
+ .concat(trimmedString.slice(1));
31
+ }
32
+ };
33
+
34
+ export { capitalizeString };
35
+ //# sourceMappingURL=index.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.esm.js","sources":["../src/string/index.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;;;;AAMG;AACI,MAAM,gBAAgB,GAAG,CAC/B,MAAc,EACd,OAAA,GAAmB,KAAK,EACxB,SAAqB,GAAA,IAAI,KACd;AACX,IAAA,IAAI,CAAC,MAAM;AAAE,QAAA,OAAO,EAAE;AAEtB,IAAA,MAAM,aAAa,GAAG,MAAM,CAAC,IAAI,EAAE;AAEnC,IAAA,IAAI,CAAC,aAAa;AAAE,QAAA,OAAO,EAAE;IAE7B,IAAI,OAAO,EAAE;AACZ,QAAA,OAAO;aACL,KAAK,CAAC,GAAG;AACT,aAAA,GAAG,CAAC,CAAC,IAAI,KAAK,gBAAgB,CAAC,IAAI,EAAE,KAAK,EAAE,SAAS,CAAC;aACtD,IAAI,CAAC,GAAG,CAAC;;SACL;QACN,IAAI,SAAS,EAAE;AACd,YAAA,OAAO;iBACL,MAAM,CAAC,CAAC;AACR,iBAAA,WAAW;iBACX,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;;AAG/C,QAAA,OAAO;aACL,MAAM,CAAC,CAAC;AACR,aAAA,WAAW;aACX,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;;AAElC;;;;"}
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./string"), exports);
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,mDAAyB"}
@@ -0,0 +1,2 @@
1
+ "use strict";const t=(e,r=!1,c=!0)=>{if(!e)return"";const s=e.trim();return s?r?s.split(" ").map((e=>t(e,!1,c))).join(" "):c?s.charAt(0).toUpperCase().concat(s.slice(1).toLowerCase()):s.charAt(0).toUpperCase().concat(s.slice(1)):""};exports.capitalizeString=t;
2
+ //# sourceMappingURL=index.min.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.min.js","sources":["../src/string/index.ts"],"sourcesContent":[null],"names":["capitalizeString","string","capEach","lowerRest","trimmedString","trim","split","map","word","join","charAt","toUpperCase","concat","slice","toLowerCase"],"mappings":"aAOO,MAAMA,EAAmB,CAC/BC,EACAC,GAAmB,EACnBC,GAAqB,KAErB,IAAKF,EAAQ,MAAO,GAEpB,MAAMG,EAAgBH,EAAOI,OAE7B,OAAKD,EAEDF,EACIE,EACLE,MAAM,KACNC,KAAKC,GAASR,EAAiBQ,GAAM,EAAOL,KAC5CM,KAAK,KAEHN,EACIC,EACLM,OAAO,GACPC,cACAC,OAAOR,EAAcS,MAAM,GAAGC,eAG1BV,EACLM,OAAO,GACPC,cACAC,OAAOR,EAAcS,MAAM,IAlBH"}
@@ -0,0 +1,2 @@
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).NHBToolBox={})}(this,(function(e){"use strict";const t=(e,o=!1,i=!0)=>{if(!e)return"";const n=e.trim();return n?o?n.split(" ").map((e=>t(e,!1,i))).join(" "):i?n.charAt(0).toUpperCase().concat(n.slice(1).toLowerCase()):n.charAt(0).toUpperCase().concat(n.slice(1)):""};e.capitalizeString=t}));
2
+ //# sourceMappingURL=index.umd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.umd.js","sources":["../src/string/index.ts"],"sourcesContent":[null],"names":["capitalizeString","string","capEach","lowerRest","trimmedString","trim","split","map","word","join","charAt","toUpperCase","concat","slice","toLowerCase"],"mappings":"kPAOO,MAAMA,EAAmB,CAC/BC,EACAC,GAAmB,EACnBC,GAAqB,KAErB,IAAKF,EAAQ,MAAO,GAEpB,MAAMG,EAAgBH,EAAOI,OAE7B,OAAKD,EAEDF,EACIE,EACLE,MAAM,KACNC,KAAKC,GAASR,EAAiBQ,GAAM,EAAOL,KAC5CM,KAAK,KAEHN,EACIC,EACLM,OAAO,GACPC,cACAC,OAAOR,EAAcS,MAAM,GAAGC,eAG1BV,EACLM,OAAO,GACPC,cACAC,OAAOR,EAAcS,MAAM,IAlBH"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Utility to convert the first letter of any string to uppercase and the rest lowercase (unless specified).
3
+ * @param string String to be capitalized.
4
+ * @param capEach If true, capitalizes the first letter of each word (space separated). Defaults to `false`.
5
+ * @param lowerRest If true, ensures that the rest of the string is lowercase. Defaults to `true`.
6
+ * @returns Capitalized string.
7
+ */
8
+ export declare const capitalizeString: (string: string, capEach?: boolean, lowerRest?: boolean) => string;
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/string/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,WACpB,MAAM,YACL,OAAO,cACL,OAAO,KAChB,MAyBF,CAAC"}
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.capitalizeString = void 0;
4
+ /**
5
+ * Utility to convert the first letter of any string to uppercase and the rest lowercase (unless specified).
6
+ * @param string String to be capitalized.
7
+ * @param capEach If true, capitalizes the first letter of each word (space separated). Defaults to `false`.
8
+ * @param lowerRest If true, ensures that the rest of the string is lowercase. Defaults to `true`.
9
+ * @returns Capitalized string.
10
+ */
11
+ const capitalizeString = (string, capEach = false, lowerRest = true) => {
12
+ if (!string)
13
+ return '';
14
+ const trimmedString = string.trim();
15
+ if (!trimmedString)
16
+ return '';
17
+ if (capEach) {
18
+ return trimmedString
19
+ .split(' ')
20
+ .map((word) => (0, exports.capitalizeString)(word, false, lowerRest))
21
+ .join(' ');
22
+ }
23
+ else {
24
+ if (lowerRest) {
25
+ return trimmedString
26
+ .charAt(0)
27
+ .toUpperCase()
28
+ .concat(trimmedString.slice(1).toLowerCase());
29
+ }
30
+ return trimmedString
31
+ .charAt(0)
32
+ .toUpperCase()
33
+ .concat(trimmedString.slice(1));
34
+ }
35
+ };
36
+ exports.capitalizeString = capitalizeString;
37
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/string/index.ts"],"names":[],"mappings":";;;AAAA;;;;;;GAMG;AACI,MAAM,gBAAgB,GAAG,CAC/B,MAAc,EACd,UAAmB,KAAK,EACxB,YAAqB,IAAI,EAChB,EAAE;IACX,IAAI,CAAC,MAAM;QAAE,OAAO,EAAE,CAAC;IAEvB,MAAM,aAAa,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC;IAEpC,IAAI,CAAC,aAAa;QAAE,OAAO,EAAE,CAAC;IAE9B,IAAI,OAAO,EAAE,CAAC;QACb,OAAO,aAAa;aAClB,KAAK,CAAC,GAAG,CAAC;aACV,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAA,wBAAgB,EAAC,IAAI,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;aACvD,IAAI,CAAC,GAAG,CAAC,CAAC;IACb,CAAC;SAAM,CAAC;QACP,IAAI,SAAS,EAAE,CAAC;YACf,OAAO,aAAa;iBAClB,MAAM,CAAC,CAAC,CAAC;iBACT,WAAW,EAAE;iBACb,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;QAChD,CAAC;QAED,OAAO,aAAa;aAClB,MAAM,CAAC,CAAC,CAAC;aACT,WAAW,EAAE;aACb,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAClC,CAAC;AACF,CAAC,CAAC;AA7BW,QAAA,gBAAgB,oBA6B3B"}
@@ -0,0 +1,2 @@
1
+ export type TCapitalize = (string: string, capEach?: boolean, lowerRest?: boolean) => string;
2
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/string/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG,CACzB,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,OAAO,EACjB,SAAS,CAAC,EAAE,OAAO,KACf,MAAM,CAAC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/string/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":""}
package/package.json ADDED
@@ -0,0 +1,78 @@
1
+ {
2
+ "name": "nhb-toolbox",
3
+ "version": "0.8.1",
4
+ "description": "A versatile collection of smart, efficient, and reusable utility functions for everyday development needs.",
5
+ "main": "./dist/index.cjs.js",
6
+ "module": "./dist/index.esm.js",
7
+ "types": "./dist/types/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.esm.js",
11
+ "require": "./dist/index.cjs.js"
12
+ }
13
+ },
14
+ "publishConfig": {
15
+ "access": "public"
16
+ },
17
+ "files": [
18
+ "dist"
19
+ ],
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/nazmul-nhb/nhb-toolbox.git"
23
+ },
24
+ "keywords": [
25
+ "toolbox",
26
+ "utility",
27
+ "functions",
28
+ "development",
29
+ "tools",
30
+ "helpers",
31
+ "utils",
32
+ "nhb",
33
+ "nhb-toolbox"
34
+ ],
35
+ "author": {
36
+ "name": "Nazmul Hassan",
37
+ "email": "nazmulnhb@gmail.com"
38
+ },
39
+ "license": "ISC",
40
+ "devDependencies": {
41
+ "@eslint/js": "^9.18.0",
42
+ "@rollup/plugin-commonjs": "^28.0.2",
43
+ "@rollup/plugin-node-resolve": "^16.0.0",
44
+ "@rollup/plugin-terser": "^0.4.4",
45
+ "@rollup/plugin-typescript": "^12.1.2",
46
+ "@types/jest": "^29.5.14",
47
+ "@types/node": "^22.10.7",
48
+ "@typescript-eslint/eslint-plugin": "^8.21.0",
49
+ "@typescript-eslint/parser": "^8.21.0",
50
+ "chalk": "4.1.2",
51
+ "eslint": "^9.18.0",
52
+ "eslint-config-prettier": "^10.0.1",
53
+ "eslint-plugin-prettier": "^5.2.3",
54
+ "execa": "^9.5.2",
55
+ "globals": "^15.14.0",
56
+ "globby": "^14.0.2",
57
+ "jest": "^29.7.0",
58
+ "prettier": "^3.4.2",
59
+ "progress-estimator": "^0.3.1",
60
+ "rimraf": "^6.0.1",
61
+ "rollup": "^4.31.0",
62
+ "rollup-plugin-dts": "^6.1.1",
63
+ "ts-jest": "^29.2.5",
64
+ "typescript": "^5.7.3",
65
+ "typescript-eslint": "^8.21.0"
66
+ },
67
+ "dependencies": {
68
+ "tslib": "^2.8.1"
69
+ },
70
+ "scripts": {
71
+ "clean": "rimraf dist",
72
+ "build": "node build.mjs && rollup -c",
73
+ "test": "jest --coverage",
74
+ "format": "prettier --write src/",
75
+ "lint": "node lint.mjs",
76
+ "fix": "node fix.mjs"
77
+ }
78
+ }