js-utils-kit 0.5.5 → 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/README.md +16 -157
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.mjs +1 -0
- package/package.json +10 -123
- package/dist/array/index.cjs +0 -1
- package/dist/array/index.d.ts +0 -21
- package/dist/array/index.js +0 -1
- package/dist/char/index.cjs +0 -1
- package/dist/char/index.d.ts +0 -41
- package/dist/char/index.js +0 -1
- package/dist/cli/index.js +0 -2
- package/dist/env/index.cjs +0 -1
- package/dist/env/index.d.ts +0 -128
- package/dist/env/index.js +0 -1
- package/dist/file/index.cjs +0 -1
- package/dist/file/index.d.ts +0 -75
- package/dist/file/index.js +0 -1
- package/dist/index.d.ts +0 -37
- package/dist/index.js +0 -1
- package/dist/number/index.cjs +0 -1
- package/dist/number/index.d.ts +0 -116
- package/dist/number/index.js +0 -1
- package/dist/object/index.cjs +0 -1
- package/dist/object/index.d.ts +0 -89
- package/dist/object/index.js +0 -1
- package/dist/string/index.cjs +0 -1
- package/dist/string/index.d.ts +0 -694
- package/dist/string/index.js +0 -1
- package/dist/validate-BKQ-HFTd.js +0 -1
- package/dist/validate-D9J7otjc.js +0 -1
package/dist/file/index.d.ts
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { ArchiverOptions } from 'archiver';
|
|
2
|
-
export { ArchiverOptions } from 'archiver';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Supported archive formats.
|
|
6
|
-
*/
|
|
7
|
-
type ArchiveFormat = 'zip' | 'tar';
|
|
8
|
-
/**
|
|
9
|
-
* Configuration options.
|
|
10
|
-
*/
|
|
11
|
-
interface CreateArchiveOptions {
|
|
12
|
-
/**
|
|
13
|
-
* Archive format to use {@link ArchiveFormat}.
|
|
14
|
-
*/
|
|
15
|
-
format: ArchiveFormat;
|
|
16
|
-
/**
|
|
17
|
-
* Path to the source directory that should be archived.
|
|
18
|
-
*/
|
|
19
|
-
source: string;
|
|
20
|
-
/**
|
|
21
|
-
* Destination file path where the archive will be written
|
|
22
|
-
* @example
|
|
23
|
-
* - For `zip` format: `dist.zip`
|
|
24
|
-
* - For `tar` format: `dist.tar`
|
|
25
|
-
*/
|
|
26
|
-
destination: string;
|
|
27
|
-
/**
|
|
28
|
-
* Additional options passed directly to the archiver library. See {@link ArchiverOptions}.
|
|
29
|
-
*/
|
|
30
|
-
options?: ArchiverOptions;
|
|
31
|
-
/**
|
|
32
|
-
* Optional flag to enable internal logging. Useful for CLI mode.
|
|
33
|
-
*/
|
|
34
|
-
log?: boolean;
|
|
35
|
-
/**
|
|
36
|
-
* Called after archiving is complete — receives total size in bytes.
|
|
37
|
-
*/
|
|
38
|
-
onSuccess?: (bytes: number) => void;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Creates a {@link ArchiveFormat } archive from a specified directory.
|
|
42
|
-
*
|
|
43
|
-
* This function uses the `archiver` library to package a directory into an archive file.
|
|
44
|
-
* It supports optional compression for `zip` and returns a Promise that resolves
|
|
45
|
-
* when the archive is successfully created.
|
|
46
|
-
*
|
|
47
|
-
* @example
|
|
48
|
-
*
|
|
49
|
-
* Function usage:
|
|
50
|
-
*
|
|
51
|
-
* ```ts
|
|
52
|
-
* await createArchive({
|
|
53
|
-
* format: "zip",
|
|
54
|
-
* source: "dist/",
|
|
55
|
-
* destination: "dist.zip",
|
|
56
|
-
* });
|
|
57
|
-
* ```
|
|
58
|
-
*
|
|
59
|
-
* CLI usage:
|
|
60
|
-
* ```sh
|
|
61
|
-
* npx js-utils-kit createArchive -f zip -s dist -d dist.zip
|
|
62
|
-
* ```
|
|
63
|
-
*
|
|
64
|
-
* @param options - Archive creation options
|
|
65
|
-
* @returns A Promise that resolves when the archive is created
|
|
66
|
-
* @throws If an error occurs during the archiving process
|
|
67
|
-
*/
|
|
68
|
-
declare function createArchive({ format, source, destination, options, log, onSuccess, }: CreateArchiveOptions): Promise<void>;
|
|
69
|
-
|
|
70
|
-
declare const _default: {
|
|
71
|
-
createArchive: typeof createArchive;
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
export { createArchive, _default as default };
|
|
75
|
-
export type { ArchiveFormat, CreateArchiveOptions };
|
package/dist/file/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import r from"fs";import o from"path";import e from"archiver";function t({format:t,source:i,destination:n,options:c={},log:s=!0,onSuccess:a}){const l=o.resolve(i);if(!r.existsSync(l)||!r.statSync(l).isDirectory())throw new Error(`Source directory "${i}" does not exist or is not a directory.`);const f=r.createWriteStream(n);"zip"===t&&(c={...c,zlib:{level:9}});const p=e(t,c);return new Promise((r,o)=>{f.on("close",()=>{const o=p.pointer();s&&console.log(`${n} created: ${o} total bytes`),a&&a(o),r()}),p.on("error",r=>{o(r)}),p.pipe(f),p.directory(i,!1),p.finalize().catch(r=>o(r instanceof Error?r:new Error(String(r))))})}var i={createArchive:t};export{t as createArchive,i as default};
|
package/dist/index.d.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
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 { Hour, MinuteOrSecond, clamp, getMilliseconds, 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 { Trim, capitalize, containsWhitespace, countChars, countFrequencies, countLines, countSubstring, countWords, endsWithPunctuation, isAlphabetic, isCamelCase, isEmail, isKebabCase, isLowerCase, isNonEmptyString, isNumericString, isPascalCase, isSnakeCase, isString, isURL, isUpperCase, longestWord, longestWordLength, padLeft, padRight, repeatString, shortestWord, shortestWordLength, splitString, startsWithUppercase, default as string, stripSymbols, trim, truncate, uniqueChars } 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
DELETED
|
@@ -1 +0,0 @@
|
|
|
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,getMilliseconds,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,countChars,countFrequencies,countLines,countSubstring,countWords,endsWithPunctuation,isAlphabetic,isCamelCase,isEmail,isKebabCase,isLowerCase,isNonEmptyString,isNumericString,isPascalCase,isSnakeCase,isString,isURL,isUpperCase,longestWord,longestWordLength,padLeft,padRight,repeatString,shortestWord,shortestWordLength,splitString,startsWithUppercase,default as string,stripSymbols,trim,truncate,uniqueChars}from"./string/index.js";export{i as isArray,a as isDefined,b as isUndefinedOrNull}from"./validate-D9J7otjc.js";import"fs";import"path";import"archiver";
|
package/dist/number/index.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";function t(t,e,n){return Math.min(Math.max(t,e),n)}function e(t){return t%2==0}function n(t){return t%2!=0}function r(t,e){return Math.floor(Math.random()*(e-t+1))+t}function o(t,e){return Math.random()*(e-t)+t}function s(t=0,e=0,n=0,r=0){if([t,e,n,r].some(t=>t<0))throw new Error("All time values must be non-negative numbers.");return 1e3*(24*t*60*60+60*e*60+60*n+r)}Object.defineProperty(exports,"__esModule",{value:!0});var a={clamp:t,isEven:e,isOdd:n,randomInt:r,randomFloat:o,getMilliseconds:s};exports.clamp=t,exports.default=a,exports.getMilliseconds=s,exports.isEven=e,exports.isOdd=n,exports.randomFloat=o,exports.randomInt=r;
|
package/dist/number/index.d.ts
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Clamps a number between a minimum and maximum value.
|
|
3
|
-
*
|
|
4
|
-
* Ensures that the returned number is not less than `min` and not more than `max`.
|
|
5
|
-
*
|
|
6
|
-
* @param value - The number to clamp.
|
|
7
|
-
* @param min - The minimum allowed value.
|
|
8
|
-
* @param max - The maximum allowed value.
|
|
9
|
-
* @returns The clamped number.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* clamp(5, 1, 10); // 5
|
|
13
|
-
* clamp(0, 1, 10); // 1
|
|
14
|
-
* clamp(15, 1, 10); // 10
|
|
15
|
-
*/
|
|
16
|
-
declare function clamp(value: number, min: number, max: number): number;
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Checks if a number is even.
|
|
20
|
-
*
|
|
21
|
-
* @param value - The number to check.
|
|
22
|
-
* @returns True if the number is even, false otherwise.
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* isEven(4); // true
|
|
26
|
-
* isEven(3); // false
|
|
27
|
-
*/
|
|
28
|
-
declare function isEven(value: number): boolean;
|
|
29
|
-
/**
|
|
30
|
-
* Checks if a number is odd.
|
|
31
|
-
*
|
|
32
|
-
* @param value - The number to check.
|
|
33
|
-
* @returns True if the number is odd, false otherwise.
|
|
34
|
-
*
|
|
35
|
-
* @example
|
|
36
|
-
* isOdd(3); // true
|
|
37
|
-
* isOdd(4); // false
|
|
38
|
-
*/
|
|
39
|
-
declare function isOdd(value: number): boolean;
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Returns a random integer between `min` and `max`, inclusive.
|
|
43
|
-
*
|
|
44
|
-
* @param min - Minimum value (inclusive).
|
|
45
|
-
* @param max - Maximum value (inclusive).
|
|
46
|
-
* @returns A random integer between min and max.
|
|
47
|
-
*
|
|
48
|
-
* @example
|
|
49
|
-
* randomInt(1, 5); // 3
|
|
50
|
-
* randomInt(10, 20); // 17
|
|
51
|
-
*/
|
|
52
|
-
declare function randomInt(min: number, max: number): number;
|
|
53
|
-
/**
|
|
54
|
-
* Returns a random floating-point number between `min` and `max`.
|
|
55
|
-
*
|
|
56
|
-
* @param min - Minimum value (inclusive).
|
|
57
|
-
* @param max - Maximum value (exclusive).
|
|
58
|
-
* @returns A random float between min and max.
|
|
59
|
-
*
|
|
60
|
-
* @example
|
|
61
|
-
* randomFloat(0, 1); // 0.624...
|
|
62
|
-
* randomFloat(1.5, 5.2); // 3.1415...
|
|
63
|
-
*/
|
|
64
|
-
declare function randomFloat(min: number, max: number): number;
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Represents an hour value in a 24-hour format.
|
|
68
|
-
*
|
|
69
|
-
* @remarks
|
|
70
|
-
* - Valid range is `0–23`.
|
|
71
|
-
* - Used in {@link getMilliseconds}.
|
|
72
|
-
*/
|
|
73
|
-
type Hour = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23;
|
|
74
|
-
/**
|
|
75
|
-
* Represents a minute or second value in time.
|
|
76
|
-
*
|
|
77
|
-
* @remarks
|
|
78
|
-
* - Valid range is `0–59`.
|
|
79
|
-
* - Used in {@link getMilliseconds}.
|
|
80
|
-
*/
|
|
81
|
-
type MinuteOrSecond = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59;
|
|
82
|
-
/**
|
|
83
|
-
* Converts a time duration (days, hours, minutes, seconds) into total milliseconds.
|
|
84
|
-
*
|
|
85
|
-
* @returns The equivalent duration in milliseconds.
|
|
86
|
-
*
|
|
87
|
-
* @throws Will throw an error if any parameter is negative.
|
|
88
|
-
*
|
|
89
|
-
* @example
|
|
90
|
-
* ```ts
|
|
91
|
-
* getMilliseconds(1); // 86400000 (1 day)
|
|
92
|
-
* getMilliseconds(0, 1); // 3600000 (1 hour)
|
|
93
|
-
* getMilliseconds(0, 0, 30, 15); // 1815000 (30 minutes 15 seconds)
|
|
94
|
-
* ```
|
|
95
|
-
*/
|
|
96
|
-
declare function getMilliseconds(
|
|
97
|
-
/** Number of days. */
|
|
98
|
-
days?: number,
|
|
99
|
-
/** Hour of the day (`0–23`). */
|
|
100
|
-
hours?: Hour,
|
|
101
|
-
/** Minute value (`0–59`). */
|
|
102
|
-
minutes?: MinuteOrSecond,
|
|
103
|
-
/** Second value (`0–59`). */
|
|
104
|
-
seconds?: MinuteOrSecond): number;
|
|
105
|
-
|
|
106
|
-
declare const _default: {
|
|
107
|
-
clamp: typeof clamp;
|
|
108
|
-
isEven: typeof isEven;
|
|
109
|
-
isOdd: typeof isOdd;
|
|
110
|
-
randomInt: typeof randomInt;
|
|
111
|
-
randomFloat: typeof randomFloat;
|
|
112
|
-
getMilliseconds: typeof getMilliseconds;
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
export { clamp, _default as default, getMilliseconds, isEven, isOdd, randomFloat, randomInt };
|
|
116
|
-
export type { Hour, MinuteOrSecond };
|
package/dist/number/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function n(n,t,r){return Math.min(Math.max(n,t),r)}function t(n){return n%2==0}function r(n){return n%2!=0}function e(n,t){return Math.floor(Math.random()*(t-n+1))+n}function o(n,t){return Math.random()*(t-n)+n}function a(n=0,t=0,r=0,e=0){if([n,t,r,e].some(n=>n<0))throw new Error("All time values must be non-negative numbers.");return 1e3*(24*n*60*60+60*t*60+60*r+e)}var u={clamp:n,isEven:t,isOdd:r,randomInt:e,randomFloat:o,getMilliseconds:a};export{n as clamp,u as default,a as getMilliseconds,t as isEven,r as isOdd,o as randomFloat,e as randomInt};
|
package/dist/object/index.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
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;
|
package/dist/object/index.d.ts
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Deeply merges multiple source objects into one.
|
|
3
|
-
*
|
|
4
|
-
* - Object properties are merged recursively.
|
|
5
|
-
* - If a key exists in multiple objects:
|
|
6
|
-
* - If the value is a plain object, it is deeply merged.
|
|
7
|
-
* - If the value is an array:
|
|
8
|
-
* - If `appendArray` is `true`, arrays are concatenated.
|
|
9
|
-
* - If `appendArray` is `false` (default), later arrays replace earlier ones.
|
|
10
|
-
* - Primitive values (string, number, boolean, etc.) are overwritten by later sources.
|
|
11
|
-
*
|
|
12
|
-
* - Objects passed later in the list of sources have **higher priority**.
|
|
13
|
-
* For example, values in the last object will override previous ones.
|
|
14
|
-
* - If you want to give **priority to a specific object**, **pass it last**.
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```ts
|
|
18
|
-
* const defaultConfig = { env: "dev", features: ["a"], flags: { debug: true } };
|
|
19
|
-
* const userConfig = { env: "prod", features: ["b"], flags: { beta: true } };
|
|
20
|
-
*
|
|
21
|
-
* const result = mergeObj(defaultConfig, userConfig);
|
|
22
|
-
* // {
|
|
23
|
-
* // env: "prod",
|
|
24
|
-
* // features: ["b"], // replaced, not merged
|
|
25
|
-
* // flags: { debug: true, beta: true }
|
|
26
|
-
* // }
|
|
27
|
-
*
|
|
28
|
-
* const result2 = mergeObj(true, defaultConfig, userConfig);
|
|
29
|
-
* // {
|
|
30
|
-
* // env: "prod",
|
|
31
|
-
* // features: ["a", "b"], // arrays merged
|
|
32
|
-
* // flags: { debug: true, beta: true }
|
|
33
|
-
* // }
|
|
34
|
-
* ```
|
|
35
|
-
*
|
|
36
|
-
* @param appendArray - If `true`, arrays are concatenated. If `false` (default), arrays are replaced.
|
|
37
|
-
* @param sources - One or more objects to deeply merge.
|
|
38
|
-
* @returns A new object containing deeply merged keys and values.
|
|
39
|
-
*/
|
|
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;
|
|
81
|
-
|
|
82
|
-
declare const _default: {
|
|
83
|
-
mergeObj: typeof mergeObj;
|
|
84
|
-
isObject: typeof isObject;
|
|
85
|
-
isEmptyObject: typeof isEmptyObject;
|
|
86
|
-
isNonEmptyObject: typeof isNonEmptyObject;
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
export { _default as default, isEmptyObject, isNonEmptyObject, isObject, mergeObj };
|
package/dist/object/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
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};
|
package/dist/string/index.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";function t(t){return t.replace(/^\w/,t=>t.toUpperCase())}function e(t,e,n=" "){return t.padStart(e,n)}function n(t,e,n=" "){return t.padEnd(e,n)}function r(t,e,n="..."){return e<=0?"":t.length<=e?t:n.length>=e?n.slice(0,e):t.trim().slice(0,e)+n}function s(t,e){return t.repeat(e)}function i(t,e=""){return t.replace(/[^\p{L}\p{N}\s]/gu,e)}function o(t,e=/\s+/){return t.split(e)}function u(t,e){return e?[...t].filter(t=>t===e).length:o(t).length}function a(t){return o(t.trim()).length}function p(t,e){return 0===e.length?0:o(t,e).length-1}function c(t){return[...t].reduce((t,e)=>(t[e]=(t[e]||0)+1,t),{})}function l(t){return t?o(t,/\r\n|\r|\n/).length:0}function h(t){return[...new Set(t)]}function g(t){const e=o(t).map(t=>i(t)).filter(Boolean);return 0===e.length?0:e.reduce((t,e)=>Math.max(t,e.length),0)}function f(t){const e=o(t.trim()).map(t=>i(t)).filter(Boolean);return 0===e.length?0:e.reduce((t,e)=>Math.min(t,e.length),1/0)}function x(t){const e=o(t.trim()).map(t=>i(t)).filter(Boolean);if(0===e.length)return"";const n=Math.max(...e.map(t=>t.length)),r=e.filter(t=>t.length===n),s=[...new Set(r)];return 1===s.length?s[0]:s}function m(t){const e=o(t.trim()).map(t=>i(t)).filter(Boolean);if(0===e.length)return"";const n=Math.min(...e.map(t=>t.length)),r=e.filter(t=>t.length===n),s=[...new Set(r)];return 1===s.length?s[0]:s}Object.defineProperty(exports,"__esModule",{value:!0});const d={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 C(t,e=!0){return!!S(t)&&("string"==typeof t&&(e?t.trim().length>0:t.length>0))}function z(t){try{return new URL(t),!0}catch{return!1}}function W(t){if("string"!=typeof t)throw new TypeError("Expected a string");if(t.length>254)return!1;const e=t.split("@");if(2!==e.length)return!1;const[n,r]=e;if(0===n.length||n.length>64)return!1;if(0===r.length||r.length>255)return!1;return!!/^[a-zA-Z0-9_%+-]+(\.[a-zA-Z0-9_%+-]+)*$/.test(n)&&!!/^(?!.*\.\.)(?!-)[A-Za-z0-9-]{1,63}(?<!-)(\.[A-Za-z0-9-]{1,63}(?<!-))*\.[A-Za-z]{2,}$/.test(r)}function L(t){return/^[a-zA-Z]+$/.test(t)}function A(t){return!isNaN(Number(t))&&!isNaN(parseFloat(t))}function b(t){return/^[A-Z]/.test(t)}function Z(t){return/[\p{P}]$/u.test(t)}function y(t){return/\s/.test(t)}function N(t){return/^[a-z][a-zA-Z0-9]*$/.test(t)}function $(t){return/^[A-Z][a-zA-Z0-9]*$/.test(t)}function w(t){return/^[a-z0-9]+(-[a-z0-9]+)*$/.test(t)}function E(t){return/^[a-z0-9]+(_[a-z0-9]+)*$/.test(t)}function U(t){return/^[A-Z]+$/.test(t)}function P(t){return/^[a-z]+$/.test(t)}var M={capitalize:t,splitString:o,countChars:u,countWords:a,countSubstring:p,countFrequencies:c,countLines:l,uniqueChars:h,longestWordLength:g,shortestWordLength:f,longestWord:x,shortestWord:m,padLeft:e,padRight:n,truncate:r,repeatString:s,stripSymbols:i,trim:d,isString:S,isNonEmptyString:C,isURL:z,isEmail:W,isAlphabetic:L,isNumericString:A,startsWithUppercase:b,endsWithPunctuation:Z,containsWhitespace:y,isCamelCase:N,isPascalCase:$,isKebabCase:w,isSnakeCase:E,isUpperCase:U,isLowerCase:P};exports.capitalize=t,exports.containsWhitespace=y,exports.countChars=u,exports.countFrequencies=c,exports.countLines=l,exports.countSubstring=p,exports.countWords=a,exports.default=M,exports.endsWithPunctuation=Z,exports.isAlphabetic=L,exports.isCamelCase=N,exports.isEmail=W,exports.isKebabCase=w,exports.isLowerCase=P,exports.isNonEmptyString=C,exports.isNumericString=A,exports.isPascalCase=$,exports.isSnakeCase=E,exports.isString=S,exports.isURL=z,exports.isUpperCase=U,exports.longestWord=x,exports.longestWordLength=g,exports.padLeft=e,exports.padRight=n,exports.repeatString=s,exports.shortestWord=m,exports.shortestWordLength=f,exports.splitString=o,exports.startsWithUppercase=b,exports.stripSymbols=i,exports.trim=d,exports.truncate=r,exports.uniqueChars=h;
|