js-utils-kit 0.2.3 → 0.3.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 CHANGED
@@ -1 +1 @@
1
- "use strict";var e=require("./char/index.cjs"),r=require("./env/index.cjs"),i=require("./file/index.cjs"),u=require("./number/index.cjs"),s=require("./object/index.cjs"),t=require("./string/index.cjs");require("fs"),require("path"),require("constants"),require("stream"),require("util"),require("assert"),require("buffer"),require("node:url"),require("node:path"),require("node:fs"),require("node:fs/promises"),require("node:events"),require("node:stream"),require("node:string_decoder"),require("zlib"),exports.char=e.default,exports.env=r.default,exports.file=i.default,exports.number=u.default,exports.object=s.default,exports.string=t.default;
1
+ "use strict";var e=require("./array/index.cjs"),r=require("./char/index.cjs"),s=require("./env/index.cjs"),t=require("./file/index.cjs"),i=require("./number/index.cjs"),o=require("./object/index.cjs"),a=require("./string/index.cjs"),p=require("./validate-BKQ-HFTd.js");require("fs"),require("path"),require("events"),require("constants"),require("stream"),require("util"),require("assert"),require("buffer"),require("node:url"),require("node:path"),require("node:fs"),require("node:fs/promises"),require("node:events"),require("node:stream"),require("node:string_decoder"),require("zlib"),exports.array=e.default,exports.all=r.all,exports.char=r.default,exports.digits=r.digits,exports.lowercase=r.lowercase,exports.uppercase=r.uppercase,Object.defineProperty(exports,"Environment",{enumerable:!0,get:function(){return s.Environment}}),exports.env=s.default,exports.getRunTimeEnvironment=s.getRunTimeEnvironment,exports.isBrowser=s.isBrowser,exports.isDev=s.isDev,exports.isNode=s.isNode,exports.isProd=s.isProd,exports.isTest=s.isTest,exports.createArchive=t.createArchive,exports.file=t.default,exports.clamp=i.clamp,exports.isEven=i.isEven,exports.isOdd=i.isOdd,exports.number=i.default,exports.randomFloat=i.randomFloat,exports.randomInt=i.randomInt,exports.isEmptyObject=o.isEmptyObject,exports.isNonEmptyObject=o.isNonEmptyObject,exports.isObject=o.isObject,exports.mergeObj=o.mergeObj,exports.object=o.default,exports.capitalize=a.capitalize,exports.containsWhitespace=a.containsWhitespace,exports.endsWithPunctuation=a.endsWithPunctuation,exports.isAlphabetic=a.isAlphabetic,exports.isCamelCase=a.isCamelCase,exports.isEmail=a.isEmail,exports.isKebabCase=a.isKebabCase,exports.isLowerCase=a.isLowerCase,exports.isNonEmptyString=a.isNonEmptyString,exports.isNumericString=a.isNumericString,exports.isPascalCase=a.isPascalCase,exports.isSnakeCase=a.isSnakeCase,exports.isString=a.isString,exports.isURL=a.isURL,exports.isUpperCase=a.isUpperCase,exports.padLeft=a.padLeft,exports.padRight=a.padRight,exports.repeatString=a.repeatString,exports.startsWithUppercase=a.startsWithUppercase,exports.string=a.default,exports.trim=a.trim,exports.truncate=a.truncate,exports.isArray=p.isArray,exports.isDefined=p.isDefined,exports.isUndefinedOrNull=p.isUndefinedOrNull;
package/dist/index.d.ts CHANGED
@@ -1,7 +1,37 @@
1
- export { default as char } from './char/index.js';
2
- export { default as env } from './env/index.js';
3
- export { default as file } from './file/index.js';
4
- export { default as number } from './number/index.js';
5
- export { default as object } from './object/index.js';
6
- export { default as string } from './string/index.js';
7
- import 'archiver';
1
+ export { default as array, isArray } from './array/index.js';
2
+ export { all, default as char, digits, lowercase, uppercase } from './char/index.js';
3
+ export { Environment, default as env, getRunTimeEnvironment, isBrowser, isDev, isNode, isProd, isTest } from './env/index.js';
4
+ export { ArchiveFormat, CreateArchiveOptions, createArchive, default as file } from './file/index.js';
5
+ export { clamp, isEven, isOdd, default as number, randomFloat, randomInt } from './number/index.js';
6
+ export { isEmptyObject, isNonEmptyObject, isObject, mergeObj, default as object } from './object/index.js';
7
+ export { capitalize, containsWhitespace, endsWithPunctuation, isAlphabetic, isCamelCase, isEmail, isKebabCase, isLowerCase, isNonEmptyString, isNumericString, isPascalCase, isSnakeCase, isString, isURL, isUpperCase, padLeft, padRight, repeatString, startsWithUppercase, default as string, trim, truncate } from './string/index.js';
8
+ export { ArchiverOptions } from 'archiver';
9
+
10
+ /**
11
+ * Checks if a value is neither null nor undefined.
12
+ * @param value - The value to check.
13
+ * @returns True if the value is defined (not null or undefined), false otherwise.
14
+ * @example
15
+ * ```ts
16
+ * isDefined(42); // true
17
+ * isDefined("hello"); // true
18
+ * isDefined(null); // false
19
+ * isDefined(undefined); // false
20
+ * ```
21
+ */
22
+ declare function isDefined<T>(value: T): boolean;
23
+ /**
24
+ * Checks if a value is either null or undefined.
25
+ * @param value - The value to check.
26
+ * @returns True if the value is null or undefined, false otherwise.
27
+ * @example
28
+ * ```ts
29
+ * isUndefinedOrNull(null); // true
30
+ * isUndefinedOrNull(undefined); // true
31
+ * isUndefinedOrNull(0); // false
32
+ * isUndefinedOrNull(""); // false
33
+ * ```
34
+ */
35
+ declare function isUndefinedOrNull<T>(value: T): boolean;
36
+
37
+ export { isDefined, isUndefinedOrNull };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export{default as char}from"./char/index.js";export{default as env}from"./env/index.js";export{default as file}from"./file/index.js";export{default as number}from"./number/index.js";export{default as object}from"./object/index.js";export{default as string}from"./string/index.js";import"fs";import"path";import"constants";import"stream";import"util";import"assert";import"buffer";import"node:url";import"node:path";import"node:fs";import"node:fs/promises";import"node:events";import"node:stream";import"node:string_decoder";import"zlib";
1
+ export{default as array}from"./array/index.js";export{all,default as char,digits,lowercase,uppercase}from"./char/index.js";export{Environment,default as env,getRunTimeEnvironment,isBrowser,isDev,isNode,isProd,isTest}from"./env/index.js";export{createArchive,default as file}from"./file/index.js";export{clamp,isEven,isOdd,default as number,randomFloat,randomInt}from"./number/index.js";export{isEmptyObject,isNonEmptyObject,isObject,mergeObj,default as object}from"./object/index.js";export{capitalize,containsWhitespace,endsWithPunctuation,isAlphabetic,isCamelCase,isEmail,isKebabCase,isLowerCase,isNonEmptyString,isNumericString,isPascalCase,isSnakeCase,isString,isURL,isUpperCase,padLeft,padRight,repeatString,startsWithUppercase,default as string,trim,truncate}from"./string/index.js";export{i as isArray,a as isDefined,b as isUndefinedOrNull}from"./validate-D9J7otjc.js";import"fs";import"path";import"events";import"constants";import"stream";import"util";import"assert";import"buffer";import"node:url";import"node:path";import"node:fs";import"node:fs/promises";import"node:events";import"node:stream";import"node:string_decoder";import"zlib";
@@ -1 +1 @@
1
- "use strict";function r(e=!1,...t){const o=r=>"object"==typeof r&&null!==r&&!Array.isArray(r);return t.reduce((t,s)=>{for(const n in s){const a=s[n],u=t[n];Array.isArray(a)?t[n]=e&&Array.isArray(u)?[...u,...a]:[...a]:o(a)?t[n]=r(e,o(u)?u:{},a):t[n]=a}return t},{})}Object.defineProperty(exports,"__esModule",{value:!0});var e={mergeObj:r};exports.default=e,exports.mergeObj=r;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../validate-BKQ-HFTd.js");function t(e=!1,...r){const o=e=>"object"==typeof e&&null!==e,s={};for(const c of r)if(o(c))for(const r of Object.keys(c)){const n=c[r],y=s[r];Array.isArray(n)?s[r]=e&&Array.isArray(y)?[...y,...n]:[...n]:o(n)&&!Array.isArray(n)?s[r]=o(y)&&!Array.isArray(y)?t(e,y,n):t(e,{},n):s[r]=n}return s}function r(t){return e.isDefined(t)&&"object"==typeof t&&!e.isArray(t)&&Object.getPrototypeOf(t)===Object.prototype}function o(t){return null!==t&&"object"==typeof t&&0===Object.keys(t).length&&!e.isArray(t)}function s(t){return null!==t&&"object"==typeof t&&Object.keys(t).length>0&&!e.isArray(t)}var c={mergeObj:t,isObject:r,isEmptyObject:o,isNonEmptyObject:s};exports.default=c,exports.isEmptyObject=o,exports.isNonEmptyObject=s,exports.isObject=r,exports.mergeObj=t;
@@ -18,7 +18,7 @@
18
18
  * const defaultConfig = { env: "dev", features: ["a"], flags: { debug: true } };
19
19
  * const userConfig = { env: "prod", features: ["b"], flags: { beta: true } };
20
20
  *
21
- * const result = mergeObj(false, defaultConfig, userConfig);
21
+ * const result = mergeObj(defaultConfig, userConfig);
22
22
  * // {
23
23
  * // env: "prod",
24
24
  * // features: ["b"], // replaced, not merged
@@ -37,10 +37,53 @@
37
37
  * @param sources - One or more objects to deeply merge.
38
38
  * @returns A new object containing deeply merged keys and values.
39
39
  */
40
- declare function mergeObj(appendArray?: boolean, ...sources: Record<string, unknown>[]): Record<string, unknown>;
40
+ declare function mergeObj(appendArray?: boolean, ...sources: object[]): object;
41
+
42
+ /**
43
+ * Checks if a value is a plain object (created by {} or new Object()).
44
+ * @param value - The value to check.
45
+ * @returns True if the value is a plain object, false otherwise.
46
+ * @example
47
+ * ```ts
48
+ * isObject({}); // true
49
+ * isObject(new Object()); // true
50
+ * isObject([]); // false
51
+ * isObject(new Date()); // false
52
+ * ```
53
+ */
54
+ declare function isObject<T>(value: T): boolean;
55
+ /**
56
+ * Checks if a value is an empty object (has no enumerable own properties).
57
+ * @param value - The value to check.
58
+ * @returns True if the value is a non-null object with no enumerable own properties, false otherwise.
59
+ * @example
60
+ * ```ts
61
+ * isEmptyObject({}); // true
62
+ * isEmptyObject({ key: 'value' }); // false
63
+ * isEmptyObject(null); // false
64
+ * isEmptyObject([]); // false
65
+ * ```
66
+ */
67
+ declare function isEmptyObject(value: object): boolean;
68
+ /**
69
+ * Checks if a value is a non-empty object (has at least one enumerable own property).
70
+ * @param value - The value to check.
71
+ * @returns True if the value is a non-null object with at least one enumerable own property, false otherwise.
72
+ * @example
73
+ * ```ts
74
+ * isNonEmptyObject({ key: 'value' }); // true
75
+ * isNonEmptyObject({}); // false
76
+ * isNonEmptyObject(null); // false
77
+ * isNonEmptyObject([]); // false
78
+ * ```
79
+ */
80
+ declare function isNonEmptyObject(value: object): boolean;
41
81
 
42
82
  declare const _default: {
43
83
  mergeObj: typeof mergeObj;
84
+ isObject: typeof isObject;
85
+ isEmptyObject: typeof isEmptyObject;
86
+ isNonEmptyObject: typeof isNonEmptyObject;
44
87
  };
45
88
 
46
- export { _default as default, mergeObj };
89
+ export { _default as default, isEmptyObject, isNonEmptyObject, isObject, mergeObj };
@@ -1 +1 @@
1
- function r(e=!1,...t){const a=r=>"object"==typeof r&&null!==r&&!Array.isArray(r);return t.reduce((t,n)=>{for(const o in n){const s=n[o],y=t[o];Array.isArray(s)?t[o]=e&&Array.isArray(y)?[...y,...s]:[...s]:a(s)?t[o]=r(e,a(y)?y:{},s):t[o]=s}return t},{})}var e={mergeObj:r};export{e as default,r as mergeObj};
1
+ import{i as t,a as e}from"../validate-D9J7otjc.js";function r(t=!1,...e){const o=t=>"object"==typeof t&&null!==t,n={};for(const c of e)if(o(c))for(const e of Object.keys(c)){const y=c[e],s=n[e];Array.isArray(y)?n[e]=t&&Array.isArray(s)?[...s,...y]:[...y]:o(y)&&!Array.isArray(y)?n[e]=o(s)&&!Array.isArray(s)?r(t,s,y):r(t,{},y):n[e]=y}return n}function o(r){return e(r)&&"object"==typeof r&&!t(r)&&Object.getPrototypeOf(r)===Object.prototype}function n(e){return null!==e&&"object"==typeof e&&0===Object.keys(e).length&&!t(e)}function c(e){return null!==e&&"object"==typeof e&&Object.keys(e).length>0&&!t(e)}var y={mergeObj:r,isObject:o,isEmptyObject:n,isNonEmptyObject:c};export{y as default,n as isEmptyObject,c as isNonEmptyObject,o as isObject,r as mergeObj};
@@ -1 +1 @@
1
- "use strict";function t(t){return null!=t&&"string"==typeof t}function r(r,e=!0){return!!t(r)&&(e?r.trim().length>0:r.length>0)}function e(t){try{return new URL(t),!0}catch{return!1}}function i(t){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)}function n(t){return/^[a-zA-Z]+$/.test(t)}function s(t){return!isNaN(Number(t))&&!isNaN(parseFloat(t))}Object.defineProperty(exports,"__esModule",{value:!0});var u={isString:t,isNonEmptyString:r,isURL:e,isEmail:i,isAlphabetic:n,isNumericString:s};exports.default=u,exports.isAlphabetic=n,exports.isEmail=i,exports.isNonEmptyString=r,exports.isNumericString=s,exports.isString=t,exports.isURL=e;
1
+ "use strict";function t(t){return t.replace(/^\w/,t=>t.toUpperCase())}function e(t,e,r=" "){return t.padStart(e,r)}function r(t,e,r=" "){return t.padEnd(e,r)}function s(t,e,r="..."){return t.length>e?t.slice(0,e-r.length)+r:t}function n(t,e){return t.repeat(e)}Object.defineProperty(exports,"__esModule",{value:!0});const i={function:t=>t.trim(),start:t=>t.trimStart(),end:t=>t.trimEnd(),normalizeWhitespace:t=>t.trim().replace(/\s+/g," ")};function a(t){return null!=t&&"string"==typeof t}function o(t,e=!0){return!!a(t)&&(e?t.trim().length>0:t.length>0)}function p(t){try{return new URL(t),!0}catch{return!1}}function u(t){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)}function c(t){return/^[a-zA-Z]+$/.test(t)}function f(t){return!isNaN(Number(t))&&!isNaN(parseFloat(t))}function l(t){return/^[A-Z]/.test(t)}function x(t){return/[\p{P}]$/u.test(t)}function m(t){return/\s/.test(t)}function g(t){return/^[a-z][a-zA-Z0-9]*$/.test(t)}function h(t){return/^[A-Z][a-zA-Z0-9]*$/.test(t)}function C(t){return/^[a-z0-9]+(-[a-z0-9]+)*$/.test(t)}function d(t){return/^[a-z0-9]+(_[a-z0-9]+)*$/.test(t)}function z(t){return/^[A-Z]+$/.test(t)}function S(t){return/^[a-z]+$/.test(t)}var N={capitalize:t,padLeft:e,padRight:r,truncate:s,repeatString:n,trim:i,isString:a,isNonEmptyString:o,isURL:p,isEmail:u,isAlphabetic:c,isNumericString:f,startsWithUppercase:l,endsWithPunctuation:x,containsWhitespace:m,isCamelCase:g,isPascalCase:h,isKebabCase:C,isSnakeCase:d,isUpperCase:z,isLowerCase:S};exports.capitalize=t,exports.containsWhitespace=m,exports.default=N,exports.endsWithPunctuation=x,exports.isAlphabetic=c,exports.isCamelCase=g,exports.isEmail=u,exports.isKebabCase=C,exports.isLowerCase=S,exports.isNonEmptyString=o,exports.isNumericString=f,exports.isPascalCase=h,exports.isSnakeCase=d,exports.isString=a,exports.isURL=p,exports.isUpperCase=z,exports.padLeft=e,exports.padRight=r,exports.repeatString=n,exports.startsWithUppercase=l,exports.trim=i,exports.truncate=s;
@@ -1,3 +1,115 @@
1
+ /**
2
+ * Capitalizes the first character of a string using a regular expression.
3
+ *
4
+ * @param value - The string to capitalize.
5
+ *
6
+ * @returns The input string with its first character capitalized, or the original string if empty or not a string.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * capitalize("hello"); // "Hello"
11
+ * capitalize("world"); // "World"
12
+ * capitalize(""); // ""
13
+ * capitalize("a"); // "A"
14
+ * ```
15
+ */
16
+ declare function capitalize(value: string): string;
17
+
18
+ /**
19
+ * Pads a string on the left with a specified character until it reaches the desired length.
20
+ * @param str - The string to pad.
21
+ * @param length - The target length of the padded string.
22
+ * @param char - The character to use for padding (defaults to a space).
23
+ * @returns The padded string, or the original string if its length is already greater than or equal to the target length.
24
+ * @example
25
+ * ```ts
26
+ * console.log(padLeft("hello", 8)); // " hello"
27
+ * console.log(padLeft("hi", 5, "*")); // "***hi"
28
+ * console.log(padLeft("hello", 3)); // "hello"
29
+ * console.log(padLeft("", 3, "0")); // "000"
30
+ * ```
31
+ */
32
+ declare function padLeft(str: string, length: number, char?: string): string;
33
+ /**
34
+ * Pads a string on the right with a specified character until it reaches the desired length.
35
+ * @param str - The string to pad.
36
+ * @param length - The target length of the padded string.
37
+ * @param char - The character to use for padding (defaults to a space).
38
+ * @returns The padded string, or the original string if its length is already greater than or equal to the target length.
39
+ * @example
40
+ * ```ts
41
+ * console.log(padRight("hello", 8)); // "hello "
42
+ * console.log(padRight("hi", 5, "*")); // "hi***"
43
+ * console.log(padRight("hello", 3)); // "hello"
44
+ * console.log(padRight("", 3, "0")); // "000"
45
+ * ```
46
+ */
47
+ declare function padRight(str: string, length: number, char?: string): string;
48
+ /**
49
+ * Truncates a string to a specified length, appending a suffix if the string is too long.
50
+ * @param str - The string to truncate.
51
+ * @param length - The maximum length of the resulting string (including the suffix).
52
+ * @param suffix - The suffix to append if truncation occurs (defaults to "...").
53
+ * @returns The truncated string with the suffix if the original string exceeds the length, otherwise the original string.
54
+ * @example
55
+ * ```ts
56
+ * console.log(truncate("hello world", 8)); // "hello..."
57
+ * console.log(truncate("hi", 5)); // "hi"
58
+ * console.log(truncate("hello", 5, "...")); // "he..."
59
+ * console.log(truncate("", 3)); // ""
60
+ * ```
61
+ */
62
+ declare function truncate(str: string, length: number, suffix?: string): string;
63
+ /**
64
+ * Repeats a string a specified number of times.
65
+ * @param str - The string to repeat.
66
+ * @param count - The number of times to repeat the string (must be non-negative).
67
+ * @returns The string repeated the specified number of times.
68
+ * @example
69
+ * ```ts
70
+ * console.log(repeatString("hi", 3)); // "hihihi"
71
+ * console.log(repeatString("a", 2)); // "aa"
72
+ * console.log(repeatString("test", 0)); // ""
73
+ * console.log(repeatString("", 5)); // ""
74
+ * ```
75
+ */
76
+ declare function repeatString(str: string, count: number): string;
77
+
78
+ /**
79
+ * String trimming utilities.
80
+ * Trims whitespace from a string (both sides by default) with methods for leading and trailing and normalizing whitespace.
81
+ * @param str - The string to trim.
82
+ * @returns The string with leading and trailing whitespace removed.
83
+ * @example
84
+ * ```ts
85
+ * // Trim both sides
86
+ * console.log(trim(" hello ")); // "hello"
87
+ * console.log(trim("")); // ""
88
+ * console.log(trim("hello")); // "hello"
89
+ *
90
+ * // Trim leading whitespace
91
+ * console.log(trim.start(" hello ")); // "hello "
92
+ * console.log(trim.start("")); // ""
93
+ * console.log(trim.start("hello")); // "hello"
94
+ *
95
+ * // Trim trailing whitespace
96
+ * console.log(trim.end(" hello ")); // " hello"
97
+ * console.log(trim.end("")); // ""
98
+ * console.log(trim.end("hello")); // "hello"
99
+ *
100
+ * // Normalize whitespace
101
+ * console.log(trim.normalizeWhitespace(" hello world ")); // "hello world"
102
+ * console.log(trim.normalizeWhitespace("hello\t world")); // "hello world"
103
+ * console.log(trim.normalizeWhitespace("")); // ""
104
+ * ```
105
+ */
106
+ declare const trim: {
107
+ function(str: string): string;
108
+ start: (str: string) => string;
109
+ end: (str: string) => string;
110
+ normalizeWhitespace: (str: string) => string;
111
+ };
112
+
1
113
  /**
2
114
  * Determines whether the provided value is a string.
3
115
  *
@@ -43,11 +155,13 @@ declare function isString<T>(value: T): value is T & string;
43
155
  * @returns - A boolean indicating whether the input is a non-empty string.
44
156
  *
45
157
  * @example
158
+ * ```ts
46
159
  * isNonEmptyString('hello'); // true
47
160
  * isNonEmptyString(' '); // false (trim is true by default)
48
161
  * isNonEmptyString(' ', false); // true (whitespace is counted)
49
162
  * isNonEmptyString(123); // false
50
163
  * isNonEmptyString(null); // false
164
+ * ```
51
165
  */
52
166
  declare function isNonEmptyString<T>(value: T, trim?: boolean): boolean;
53
167
  /**
@@ -60,10 +174,12 @@ declare function isNonEmptyString<T>(value: T, trim?: boolean): boolean;
60
174
  * @returns - `true` if the string is a valid absolute URL; otherwise, `false`.
61
175
  *
62
176
  * @example
177
+ * ```ts
63
178
  * isURL('https://example.com'); // true
64
179
  * isURL('ftp://files.example.com'); // true
65
180
  * isURL('invalid-url'); // false
66
181
  * isURL('/relative/path'); // false
182
+ * ```
67
183
  */
68
184
  declare function isURL(value: string): boolean;
69
185
  /**
@@ -77,10 +193,12 @@ declare function isURL(value: string): boolean;
77
193
  * @returns - `true` if the string is a valid email; otherwise, `false`.
78
194
  *
79
195
  * @example
196
+ * ```ts
80
197
  * isEmail('user@example.com'); // true
81
198
  * isEmail('first.last@college.university.in'); // true
82
199
  * isEmail('invalid-email'); // false
83
200
  * isEmail('name@domain'); // false
201
+ * ```
84
202
  */
85
203
  declare function isEmail(value: string): boolean;
86
204
  /**
@@ -90,9 +208,11 @@ declare function isEmail(value: string): boolean;
90
208
  * @returns - `true` if the string contains only letters; otherwise, `false`.
91
209
  *
92
210
  * @example
211
+ * ```ts
93
212
  * isAlphabetic("Hello"); // true
94
213
  * isAlphabetic("world123"); // false
95
214
  * isAlphabetic("Test!"); // false
215
+ * ```
96
216
  */
97
217
  declare function isAlphabetic(value: string): boolean;
98
218
  /**
@@ -111,27 +231,149 @@ declare function isAlphabetic(value: string): boolean;
111
231
  * @returns - `true` if the string represents a valid number; otherwise, `false`.
112
232
  *
113
233
  * @example
234
+ * ```ts
114
235
  * isNumericString("42"); // true
115
236
  * isNumericString("-3.14"); // true
116
237
  * isNumericString("1e5"); // true
117
238
  * isNumericString(" 123 "); // true
118
239
  * isNumericString("123abc"); // false
119
240
  * isNumericString("abc123"); // false
120
- *
241
+ * ```
121
242
  * See also:
122
243
  * - {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number Number()}
123
244
  * - {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseFloat parseFloat()}
124
245
  * - {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/isNaN isNaN()}
125
246
  */
126
247
  declare function isNumericString(value: string): boolean;
248
+ /**
249
+ * Checks if a string starts with an uppercase letter.
250
+ * @param value - The input string to check.
251
+ * @returns True if the first character is uppercase, false otherwise.
252
+ * @example
253
+ * ```ts
254
+ * startsWithUppercase('Hello') // true
255
+ * startsWithUppercase('world') // false
256
+ * ```
257
+ */
258
+ declare function startsWithUppercase(value: string): boolean;
259
+ /**
260
+ * Checks if a string ends with any Unicode punctuation character.
261
+ *
262
+ * @param value - The string to check.
263
+ * @returns True if the string ends with a punctuation character.
264
+ * @example
265
+ * ```ts
266
+ * endsWithPunctuation("Hi!") // true
267
+ * endsWithPunctuation("Hello—") // true
268
+ * endsWithPunctuation("Okay") // false
269
+ * ```
270
+ */
271
+ declare function endsWithPunctuation(value: string): boolean;
272
+ /**
273
+ * Checks if a string contains any whitespace.
274
+ * @param value - The string to check.
275
+ * @returns True if the string contains whitespace.
276
+ * @example
277
+ * ```ts
278
+ * containsWhitespace("Hello world") // true
279
+ * containsWhitespace("Nowordspace") // false
280
+ * ```
281
+ */
282
+ declare function containsWhitespace(value: string): boolean;
283
+ /**
284
+ * Checks if a string is in camelCase format.
285
+ * @param value - The input string.
286
+ * @returns True if the string is camelCase.
287
+ * @example
288
+ * ```ts
289
+ * isCamelCase("helloWorld") // true
290
+ * isCamelCase("HelloWorld") // false
291
+ * ```
292
+ */
293
+ declare function isCamelCase(value: string): boolean;
294
+ /**
295
+ * Checks if a string is in PascalCase format.
296
+ * @param value - The input string.
297
+ * @returns True if the string is PascalCase.
298
+ * @example
299
+ * ```ts
300
+ * isPascalCase("HelloWorld") // true
301
+ * isPascalCase("helloWorld") // false
302
+ * ```
303
+ */
304
+ declare function isPascalCase(value: string): boolean;
305
+ /**
306
+ * Checks if a string is in kebab-case format.
307
+ * @param value - The input string.
308
+ * @returns True if the string is kebab-case.
309
+ * @example
310
+ * ```ts
311
+ * isKebabCase("hello-world") // true
312
+ * isKebabCase("hello_world") // false
313
+ * ```
314
+ */
315
+ declare function isKebabCase(value: string): boolean;
316
+ /**
317
+ * Checks if a string is in snake_case format.
318
+ * @param value - The input string.
319
+ * @returns True if the string is snake_case.
320
+ * @example
321
+ * ```ts
322
+ * isSnakeCase("hello_world") // true
323
+ * isSnakeCase("hello-world") // false
324
+ * ```
325
+ */
326
+ declare function isSnakeCase(value: string): boolean;
327
+ /**
328
+ * Checks if a string contains only uppercase letters.
329
+ * @param value - The input string.
330
+ * @returns True if all letters are uppercase.
331
+ * @example
332
+ * ```ts
333
+ * isUpperCase("HELLO") // true
334
+ * isUpperCase("Hello") // false
335
+ * ```
336
+ */
337
+ declare function isUpperCase(value: string): boolean;
338
+ /**
339
+ * Checks if a string contains only lowercase letters.
340
+ * @param value - The input string.
341
+ * @returns True if all letters are lowercase.
342
+ * @example
343
+ * ```ts
344
+ * isLowerCase("hello") // true
345
+ * isLowerCase("Hello") // false
346
+ * ```
347
+ */
348
+ declare function isLowerCase(value: string): boolean;
127
349
 
128
350
  declare const _default: {
351
+ capitalize: typeof capitalize;
352
+ padLeft: typeof padLeft;
353
+ padRight: typeof padRight;
354
+ truncate: typeof truncate;
355
+ repeatString: typeof repeatString;
356
+ trim: {
357
+ function(str: string): string;
358
+ start: (str: string) => string;
359
+ end: (str: string) => string;
360
+ normalizeWhitespace: (str: string) => string;
361
+ };
129
362
  isString: typeof isString;
130
363
  isNonEmptyString: typeof isNonEmptyString;
131
364
  isURL: typeof isURL;
132
365
  isEmail: typeof isEmail;
133
366
  isAlphabetic: typeof isAlphabetic;
134
367
  isNumericString: typeof isNumericString;
368
+ startsWithUppercase: typeof startsWithUppercase;
369
+ endsWithPunctuation: typeof endsWithPunctuation;
370
+ containsWhitespace: typeof containsWhitespace;
371
+ isCamelCase: typeof isCamelCase;
372
+ isPascalCase: typeof isPascalCase;
373
+ isKebabCase: typeof isKebabCase;
374
+ isSnakeCase: typeof isSnakeCase;
375
+ isUpperCase: typeof isUpperCase;
376
+ isLowerCase: typeof isLowerCase;
135
377
  };
136
378
 
137
- export { _default as default, isAlphabetic, isEmail, isNonEmptyString, isNumericString, isString, isURL };
379
+ export { capitalize, containsWhitespace, _default as default, endsWithPunctuation, isAlphabetic, isCamelCase, isEmail, isKebabCase, isLowerCase, isNonEmptyString, isNumericString, isPascalCase, isSnakeCase, isString, isURL, isUpperCase, padLeft, padRight, repeatString, startsWithUppercase, trim, truncate };
@@ -1 +1 @@
1
- function t(t){return null!=t&&"string"==typeof t}function n(n,r=!0){return!!t(n)&&(r?n.trim().length>0:n.length>0)}function r(t){try{return new URL(t),!0}catch{return!1}}function i(t){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)}function e(t){return/^[a-zA-Z]+$/.test(t)}function u(t){return!isNaN(Number(t))&&!isNaN(parseFloat(t))}var s={isString:t,isNonEmptyString:n,isURL:r,isEmail:i,isAlphabetic:e,isNumericString:u};export{s as default,e as isAlphabetic,i as isEmail,n as isNonEmptyString,u as isNumericString,t as isString,r as isURL};
1
+ function t(t){return t.replace(/^\w/,t=>t.toUpperCase())}function n(t,n,e=" "){return t.padStart(n,e)}function e(t,n,e=" "){return t.padEnd(n,e)}function r(t,n,e="..."){return t.length>n?t.slice(0,n-e.length)+e:t}function i(t,n){return t.repeat(n)}const a={function:t=>t.trim(),start:t=>t.trimStart(),end:t=>t.trimEnd(),normalizeWhitespace:t=>t.trim().replace(/\s+/g," ")};function s(t){return null!=t&&"string"==typeof t}function u(t,n=!0){return!!s(t)&&(n?t.trim().length>0:t.length>0)}function c(t){try{return new URL(t),!0}catch{return!1}}function o(t){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)}function f(t){return/^[a-zA-Z]+$/.test(t)}function p(t){return!isNaN(Number(t))&&!isNaN(parseFloat(t))}function l(t){return/^[A-Z]/.test(t)}function m(t){return/[\p{P}]$/u.test(t)}function g(t){return/\s/.test(t)}function h(t){return/^[a-z][a-zA-Z0-9]*$/.test(t)}function z(t){return/^[A-Z][a-zA-Z0-9]*$/.test(t)}function d(t){return/^[a-z0-9]+(-[a-z0-9]+)*$/.test(t)}function $(t){return/^[a-z0-9]+(_[a-z0-9]+)*$/.test(t)}function C(t){return/^[A-Z]+$/.test(t)}function A(t){return/^[a-z]+$/.test(t)}var N={capitalize:t,padLeft:n,padRight:e,truncate:r,repeatString:i,trim:a,isString:s,isNonEmptyString:u,isURL:c,isEmail:o,isAlphabetic:f,isNumericString:p,startsWithUppercase:l,endsWithPunctuation:m,containsWhitespace:g,isCamelCase:h,isPascalCase:z,isKebabCase:d,isSnakeCase:$,isUpperCase:C,isLowerCase:A};export{t as capitalize,g as containsWhitespace,N as default,m as endsWithPunctuation,f as isAlphabetic,h as isCamelCase,o as isEmail,d as isKebabCase,A as isLowerCase,u as isNonEmptyString,p as isNumericString,z as isPascalCase,$ as isSnakeCase,s as isString,c as isURL,C as isUpperCase,n as padLeft,e as padRight,i as repeatString,l as startsWithUppercase,a as trim,r as truncate};
@@ -0,0 +1 @@
1
+ "use strict";function r(r){return null!=r}exports.isArray=function(n){return r(n)&&Array.isArray(n)},exports.isDefined=r,exports.isUndefinedOrNull=function(r){return null==r};
@@ -0,0 +1 @@
1
+ function n(n){return null!=n}function r(n){return null==n}function u(r){return n(r)&&Array.isArray(r)}export{n as a,r as b,u as i};
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "js-utils-kit",
3
3
  "displayName": "JS Utils Kit",
4
- "version": "0.2.3",
4
+ "version": "0.3.0",
5
5
  "description": "Essential JavaScript helpers",
6
6
  "license": "MIT",
7
7
  "private": false,
8
- "repository": "https://github.com/TenEplaysOfficial/js-utils-kit",
8
+ "repository": "https://github.com/teneplaysofficial/js-utils-kit",
9
9
  "bugs": {
10
- "url": "https://github.com/TenEplaysOfficial/js-utils-kit/issues"
10
+ "url": "https://github.com/teneplaysofficial/js-utils-kit/issues"
11
11
  },
12
12
  "author": {
13
13
  "name": "Sriman",
@@ -52,6 +52,11 @@
52
52
  "require": "./dist/index.cjs",
53
53
  "types": "./dist/index.d.ts"
54
54
  },
55
+ "./array": {
56
+ "import": "./dist/array/index.js",
57
+ "require": "./dist/array/index.cjs",
58
+ "types": "./dist/array/index.d.ts"
59
+ },
55
60
  "./char": {
56
61
  "import": "./dist/char/index.js",
57
62
  "require": "./dist/char/index.cjs",
@@ -110,8 +115,8 @@
110
115
  },
111
116
  "devDependencies": {
112
117
  "@eslint/js": "^9.29.0",
113
- "@eslint/json": "^0.12.0",
114
- "@eslint/markdown": "^6.6.0",
118
+ "@eslint/json": "^0.13.0",
119
+ "@eslint/markdown": "^7.0.0",
115
120
  "@release-it/conventional-changelog": "^10.0.1",
116
121
  "@rollup/plugin-commonjs": "^28.0.6",
117
122
  "@rollup/plugin-node-resolve": "^16.0.1",