@rtorcato/js-common 2.8.2 → 3.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/AGENTS.md +116 -0
- package/CHANGELOG.md +23 -0
- package/CONTRIBUTORS.md +5 -0
- package/README.md +70 -21
- package/dist/abortController/index.d.ts +30 -0
- package/dist/abortController/index.d.ts.map +1 -1
- package/dist/boolean/index.d.ts +18 -6
- package/dist/boolean/index.d.ts.map +1 -1
- package/dist/boolean/index.js +1 -1
- package/dist/chunks/chunk-7JQSIREC.js +1 -0
- package/dist/chunks/chunk-MFJ5XPUX.js +1 -0
- package/dist/chunks/chunk-RBXTRLWB.js +1 -0
- package/dist/cli/catalog.js +131 -0
- package/dist/cli/cli.mjs +16 -109
- package/dist/colors/index.d.ts +23 -3
- package/dist/colors/index.d.ts.map +1 -1
- package/dist/console/index.d.ts +12 -0
- package/dist/console/index.d.ts.map +1 -1
- package/dist/crypto/index.d.ts +23 -0
- package/dist/crypto/index.d.ts.map +1 -1
- package/dist/currency/index.d.ts +0 -14
- package/dist/currency/index.d.ts.map +1 -1
- package/dist/currency/index.js +1 -1
- package/dist/date/index.d.ts +16 -0
- package/dist/date/index.d.ts.map +1 -1
- package/dist/datetime/index.d.ts +21 -9
- package/dist/datetime/index.d.ts.map +1 -1
- package/dist/datetime/index.js +1 -1
- package/dist/emails/index.d.ts +22 -0
- package/dist/emails/index.d.ts.map +1 -1
- package/dist/emails/index.js +1 -1
- package/dist/env/index.d.ts +24 -0
- package/dist/env/index.d.ts.map +1 -1
- package/dist/errors/index.d.ts +30 -2
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/events/index.d.ts +25 -1
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/index.js +1 -1
- package/dist/fetch/index.d.ts +25 -0
- package/dist/fetch/index.d.ts.map +1 -1
- package/dist/file/index.d.ts +20 -0
- package/dist/file/index.d.ts.map +1 -1
- package/dist/functions/functions.test-d.d.ts +2 -0
- package/dist/functions/functions.test-d.d.ts.map +1 -0
- package/dist/functions/functions.test-d.js +1 -0
- package/dist/functions/index.d.ts +32 -2
- package/dist/functions/index.d.ts.map +1 -1
- package/dist/functions/index.js +1 -1
- package/dist/geometry/index.d.ts +21 -0
- package/dist/geometry/index.d.ts.map +1 -1
- package/dist/html/index.d.ts +38 -0
- package/dist/html/index.d.ts.map +1 -1
- package/dist/html/index.js +1 -1
- package/dist/i18n/index.d.ts +23 -7
- package/dist/i18n/index.d.ts.map +1 -1
- package/dist/i18n/index.js +1 -1
- package/dist/interval/index.d.ts +15 -0
- package/dist/interval/index.d.ts.map +1 -1
- package/dist/json/index.d.ts +27 -0
- package/dist/json/index.d.ts.map +1 -1
- package/dist/logger/index.js +1 -1
- package/dist/logger/logger.d.ts +12 -2
- package/dist/logger/logger.d.ts.map +1 -1
- package/dist/logger/logger.js +1 -1
- package/dist/logging/index.d.ts +19 -0
- package/dist/logging/index.d.ts.map +1 -1
- package/dist/maps/index.d.ts +21 -0
- package/dist/maps/index.d.ts.map +1 -1
- package/dist/mime-types/index.d.ts +20 -0
- package/dist/mime-types/index.d.ts.map +1 -1
- package/dist/node/index.d.ts +0 -9
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +1 -1
- package/dist/numbers/index.d.ts +28 -12
- package/dist/numbers/index.d.ts.map +1 -1
- package/dist/numbers/index.js +1 -1
- package/dist/objects/index.d.ts +23 -0
- package/dist/objects/index.d.ts.map +1 -1
- package/dist/os/index.d.ts +18 -0
- package/dist/os/index.d.ts.map +1 -1
- package/dist/process/index.d.ts +18 -0
- package/dist/process/index.d.ts.map +1 -1
- package/dist/promises/index.d.ts +29 -2
- package/dist/promises/index.d.ts.map +1 -1
- package/dist/promises/index.js +1 -1
- package/dist/promises/promises.test-d.d.ts +2 -0
- package/dist/promises/promises.test-d.d.ts.map +1 -0
- package/dist/promises/promises.test-d.js +1 -0
- package/dist/random/index.d.ts +21 -0
- package/dist/random/index.d.ts.map +1 -1
- package/dist/regex/index.d.ts +23 -0
- package/dist/regex/index.d.ts.map +1 -1
- package/dist/security/index.d.ts +36 -4
- package/dist/security/index.d.ts.map +1 -1
- package/dist/security/index.js +1 -1
- package/dist/sets/index.d.ts +19 -0
- package/dist/sets/index.d.ts.map +1 -1
- package/dist/sleep/index.d.ts +20 -0
- package/dist/sleep/index.d.ts.map +1 -1
- package/dist/strings/index.d.ts +0 -52
- package/dist/strings/index.d.ts.map +1 -1
- package/dist/strings/index.js +1 -1
- package/dist/system/index.d.ts +18 -0
- package/dist/system/index.d.ts.map +1 -1
- package/dist/time/index.d.ts +23 -4
- package/dist/time/index.d.ts.map +1 -1
- package/dist/try/trycatch.d.ts +24 -0
- package/dist/try/trycatch.d.ts.map +1 -1
- package/dist/types/index.d.ts +0 -1
- package/dist/url/index.d.ts +23 -0
- package/dist/url/index.d.ts.map +1 -1
- package/dist/url/index.js +1 -1
- package/dist/uuid/index.d.ts +10 -0
- package/dist/uuid/index.d.ts.map +1 -1
- package/dist/validation/index.d.ts +25 -0
- package/dist/validation/index.d.ts.map +1 -1
- package/dist/validation/index.js +1 -1
- package/package.json +23 -25
- package/dist/chunks/chunk-6J7HIWG6.js +0 -1
- package/dist/formatting/index.d.ts +0 -40
- package/dist/formatting/index.d.ts.map +0 -1
- package/dist/formatting/index.js +0 -1
- package/dist/math/index.d.ts +0 -37
- package/dist/math/index.d.ts.map +0 -1
- package/dist/math/index.js +0 -1
- package/dist/try/attempt.d.ts +0 -8
- package/dist/try/attempt.d.ts.map +0 -1
- package/dist/try/attempt.js +0 -1
package/dist/maps/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/maps/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/maps/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAMzD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAMzF;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAQ/D;AAED;;;;GAIG;AAEH,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAEtE;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAMrE"}
|
|
@@ -15,15 +15,35 @@ import type { FileExtension, MimeType } from './db.js';
|
|
|
15
15
|
export * from './db.js';
|
|
16
16
|
/**
|
|
17
17
|
* Map from `MimeType` to its associated file extensions, populated from the database.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* extensions['application/json'] // ['json', 'map']
|
|
22
|
+
* extensions['text/html'] // ['html', 'htm', 'shtml']
|
|
23
|
+
* ```
|
|
18
24
|
*/
|
|
19
25
|
export declare const extensions: Record<MimeType, FileExtension[]>;
|
|
20
26
|
/**
|
|
21
27
|
* Map from `FileExtension` to its canonical `MimeType`, populated from the database.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* types['json'] // 'application/json'
|
|
32
|
+
* types['png'] // 'image/png'
|
|
33
|
+
* ```
|
|
22
34
|
*/
|
|
23
35
|
export declare const types: Record<FileExtension, MimeType>;
|
|
24
36
|
/**
|
|
25
37
|
* Lookup the MIME type for a file path/extension.
|
|
26
38
|
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* lookup('json') // 'application/json'
|
|
42
|
+
* lookup('.png') // 'image/png'
|
|
43
|
+
* lookup('/path/to/report.pdf') // 'application/pdf'
|
|
44
|
+
* lookup('nope') // false
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
27
47
|
* @param {string} path
|
|
28
48
|
* @return {boolean|string}
|
|
29
49
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mime-types/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAOtD,cAAc,SAAS,CAAA;AAOvB
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mime-types/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAOtD,cAAc,SAAS,CAAA;AAOvB;;;;;;;;GAQG;AACH,eAAO,MAAM,UAAU,EAAS,MAAM,CAAC,QAAQ,EAAE,aAAa,EAAE,CAAC,CAAA;AAEjE;;;;;;;;GAQG;AACH,eAAO,MAAM,KAAK,EAAS,MAAM,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAA;AAK1D;;;;;;;;;;;;;GAaG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,swzBAalC"}
|
package/dist/node/index.d.ts
CHANGED
|
@@ -40,13 +40,4 @@ export declare const isNode: () => boolean;
|
|
|
40
40
|
* const optionalModule = requireOptional('some-module');
|
|
41
41
|
*/
|
|
42
42
|
export declare function requireOptional(moduleName: string): any | undefined;
|
|
43
|
-
/**
|
|
44
|
-
* Returns the process uptime in seconds.
|
|
45
|
-
*
|
|
46
|
-
* @returns The number of seconds the current Node.js process has been running.
|
|
47
|
-
*
|
|
48
|
-
* @example
|
|
49
|
-
* const uptime = getProcessUptime();
|
|
50
|
-
*/
|
|
51
|
-
export declare const getProcessUptime: () => number;
|
|
52
43
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/node/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,gBAAgB,GAAI,aAAa,MAAM,KAAG,IAMtD,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,QAAO,MAEtC,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,MAAM,QAAO,OAEzB,CAAA;AAED;;;;;;;;GAQG;AAEH,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,GAAG,GAAG,SAAS,CAOnE
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,gBAAgB,GAAI,aAAa,MAAM,KAAG,IAMtD,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,QAAO,MAEtC,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,MAAM,QAAO,OAEzB,CAAA;AAED;;;;;;;;GAQG;AAEH,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,GAAG,GAAG,SAAS,CAOnE"}
|
package/dist/node/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as r}from"../chunks/chunk-ANN5UYCF.js";var n=e=>{o()<e&&(console.log("Please update Node to run this app"),process.exit(1))},o=()=>Number(process.version.match(/^v(\d+)/)?.[1]||0),t=()=>typeof process<"u"&&process.release?.name==="node";function s(e){try{return r(e)}catch{return}}
|
|
1
|
+
import{a as r}from"../chunks/chunk-ANN5UYCF.js";var n=e=>{o()<e&&(console.log("Please update Node to run this app"),process.exit(1))},o=()=>Number(process.version.match(/^v(\d+)/)?.[1]||0),t=()=>typeof process<"u"&&process.release?.name==="node";function s(e){try{return r(e)}catch{return}}export{o as getNodeMajorVersion,t as isNode,n as nodeVersionCheck,s as requireOptional};
|
package/dist/numbers/index.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns a random integer between min and max (inclusive).
|
|
3
|
-
* @param min The minimum value (inclusive).
|
|
4
|
-
* @param max The maximum value (inclusive).
|
|
5
|
-
* @returns A random integer.
|
|
6
|
-
*/
|
|
7
|
-
export declare function getRandomInt(min: number, max: number): number;
|
|
8
1
|
/**
|
|
9
2
|
* Clamps a number between a minimum and maximum value.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```typescript
|
|
6
|
+
* clamp(15, 0, 10) // 10
|
|
7
|
+
* clamp(-5, 0, 10) // 0
|
|
8
|
+
* clamp(5, 0, 10) // 5
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
10
11
|
* @param value The number to clamp.
|
|
11
12
|
* @param min The minimum value.
|
|
12
13
|
* @param max The maximum value.
|
|
@@ -15,6 +16,14 @@ export declare function getRandomInt(min: number, max: number): number;
|
|
|
15
16
|
export declare function clamp(value: number, min: number, max: number): number;
|
|
16
17
|
/**
|
|
17
18
|
* Rounds a number to a specified number of decimal places.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* roundTo(3.14159) // 3.14
|
|
23
|
+
* roundTo(3.14159, 3) // 3.142
|
|
24
|
+
* roundTo(1234.5, 0) // 1235
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
18
27
|
* @param value The number to round.
|
|
19
28
|
* @param decimals The number of decimal places. Defaults to 2.
|
|
20
29
|
* @returns The rounded number.
|
|
@@ -27,12 +36,19 @@ export declare function roundTo(value: number, decimals?: number): number;
|
|
|
27
36
|
*/
|
|
28
37
|
export declare function isFiniteNumber(value: unknown): value is number;
|
|
29
38
|
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* @
|
|
33
|
-
*
|
|
39
|
+
* Formats a number as a percentage string.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* formatPercent(0.25) // '25%'
|
|
44
|
+
* formatPercent(0.1234, 1) // '12.3%'
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* @param value The value to format (e.g. 0.25 for 25%).
|
|
48
|
+
* @param fractionDigits Number of decimal places (default: 0).
|
|
49
|
+
* @returns The formatted percentage string.
|
|
34
50
|
*/
|
|
35
|
-
export declare function
|
|
51
|
+
export declare function formatPercent(value: number, fractionDigits?: number): string;
|
|
36
52
|
/**
|
|
37
53
|
* Checks if a value is an integer.
|
|
38
54
|
* @param value The value to check.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/numbers/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/numbers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAErE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,SAAI,GAAG,MAAM,CAG3D;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAE9D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,cAAc,SAAI,GAAG,MAAM,CAEvE;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAEzD;AAED;;;;;;;GAOG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,SAAS,UAAO,GAAG,OAAO,CAE1F;AAED;;;;GAIG;AACH,wBAAgB,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,CAE7C;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,CAEjD;AAED;;;;;GAKG;AACH,wBAAgB,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED;;;;GAIG;AACH,wBAAgB,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,CAE7C;AAED;;;;GAIG;AACH,wBAAgB,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,CAE7C"}
|
package/dist/numbers/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../chunks/chunk-ANN5UYCF.js";function o(n,r
|
|
1
|
+
import"../chunks/chunk-ANN5UYCF.js";function o(n,r,e){return Math.max(r,Math.min(e,n))}function m(n,r=2){let e=10**r;return Math.round(n*e)/e}function b(n){return typeof n=="number"&&Number.isFinite(n)}function i(n,r=0){return`${(n*100).toFixed(r)}%`}function c(n){return typeof n=="number"&&Number.isInteger(n)}function f(n,r,e,t=!0){return t?n>=r&&n<=e:n>r&&n<e}function u(n){return n.reduce((r,e)=>r+e,0)}function p(n){return n.length===0?0:u(n)/n.length}function x(n,r){return(n%r+r)%r}function a(n){return Math.min(...n)}function h(n){return Math.max(...n)}export{p as average,f as between,o as clamp,i as formatPercent,b as isFiniteNumber,c as isInteger,h as max,a as min,x as mod,m as roundTo,u as sum};
|
package/dist/objects/index.d.ts
CHANGED
|
@@ -1,11 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Returns true if the value is a plain object (not null, not array, not function).
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```typescript
|
|
6
|
+
* isPlainObject({ a: 1 }) // true
|
|
7
|
+
* isPlainObject([1, 2]) // false
|
|
8
|
+
* isPlainObject(null) // false
|
|
9
|
+
* isPlainObject(new Date()) // false
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
3
12
|
* @param value The value to check.
|
|
4
13
|
* @returns {boolean}
|
|
5
14
|
*/
|
|
6
15
|
export declare function isPlainObject(value: any): value is Record<string, any>;
|
|
7
16
|
/**
|
|
8
17
|
* Deeply merges two objects. Does not mutate inputs.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* deepMerge({ a: 1, nested: { x: 1, y: 2 } }, { nested: { y: 9 }, b: 2 })
|
|
22
|
+
* // { a: 1, nested: { x: 1, y: 9 }, b: 2 }
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
9
25
|
* @param target The target object.
|
|
10
26
|
* @param source The source object.
|
|
11
27
|
* @returns {object} The merged object.
|
|
@@ -13,6 +29,13 @@ export declare function isPlainObject(value: any): value is Record<string, any>;
|
|
|
13
29
|
export declare function deepMerge<T extends object, U extends object>(target: T, source: U): T & U;
|
|
14
30
|
/**
|
|
15
31
|
* Returns a shallow copy of an object with the given keys omitted.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* omit({ id: 1, name: 'Ada', password: 'x' }, ['password'])
|
|
36
|
+
* // { id: 1, name: 'Ada' }
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
16
39
|
* @param obj The source object.
|
|
17
40
|
* @param keys Keys to omit.
|
|
18
41
|
* @returns {object}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/objects/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/objects/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,wBAAgB,aAAa,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAEtE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAUzF;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAMvF;AAED;;;;;GAKG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAQvF;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAEtC"}
|
package/dist/os/index.d.ts
CHANGED
|
@@ -1,15 +1,33 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Returns the current operating system platform (Node.js only).
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```typescript
|
|
6
|
+
* getOsPlatform() // 'darwin' on macOS, 'win32' on Windows, undefined in a browser
|
|
7
|
+
* ```
|
|
8
|
+
*
|
|
3
9
|
* @returns {string | undefined} The platform (e.g., 'darwin', 'win32', 'linux').
|
|
4
10
|
*/
|
|
5
11
|
export declare function getOsPlatform(): string | undefined;
|
|
6
12
|
/**
|
|
7
13
|
* Returns the OS release/version (Node.js only).
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* getOsRelease() // 'node'
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
8
20
|
* @returns {string | undefined}
|
|
9
21
|
*/
|
|
10
22
|
export declare function getOsRelease(): string | undefined;
|
|
11
23
|
/**
|
|
12
24
|
* Returns the OS architecture (Node.js only).
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* getOsArch() // 'arm64' on Apple silicon, 'x64' on Intel
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
13
31
|
* @returns {string | undefined}
|
|
14
32
|
*/
|
|
15
33
|
export declare function getOsArch(): string | undefined;
|
package/dist/os/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/os/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/os/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,wBAAgB,aAAa,IAAI,MAAM,GAAG,SAAS,CAGlD;AAED;;;;;;;;;GASG;AACH,wBAAgB,YAAY,IAAI,MAAM,GAAG,SAAS,CAIjD;AAED;;;;;;;;;GASG;AACH,wBAAgB,SAAS,IAAI,MAAM,GAAG,SAAS,CAG9C;AAED;;;GAGG;AACH,wBAAgB,UAAU,IAAI,MAAM,GAAG,SAAS,CAM/C;AAED;;;GAGG;AACH,wBAAgB,SAAS,IAAI,MAAM,GAAG,SAAS,CAO9C"}
|
package/dist/process/index.d.ts
CHANGED
|
@@ -1,15 +1,33 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Returns the current process ID (Node.js only).
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```typescript
|
|
6
|
+
* getProcessId() // 48213 (undefined in a browser)
|
|
7
|
+
* ```
|
|
8
|
+
*
|
|
3
9
|
* @returns {number | undefined}
|
|
4
10
|
*/
|
|
5
11
|
export declare function getProcessId(): number | undefined;
|
|
6
12
|
/**
|
|
7
13
|
* Returns the current process uptime in seconds (Node.js only).
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* getProcessUptime() // 12.482
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
8
20
|
* @returns {number | undefined}
|
|
9
21
|
*/
|
|
10
22
|
export declare function getProcessUptime(): number | undefined;
|
|
11
23
|
/**
|
|
12
24
|
* Returns the current working directory (Node.js only).
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* getCwd() // '/Users/ada/projects/app'
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
13
31
|
* @returns {string | undefined}
|
|
14
32
|
*/
|
|
15
33
|
export declare function getCwd(): string | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/process/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/process/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,wBAAgB,YAAY,IAAI,MAAM,GAAG,SAAS,CAGjD;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,GAAG,SAAS,CAIrD;AAED;;;;;;;;;GASG;AACH,wBAAgB,MAAM,IAAI,MAAM,GAAG,SAAS,CAG3C;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,GAAG,SAAS,CAGvD;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,IAAI,GAAE,MAAU,GAAG,IAAI,CAElD;AAED;;;GAGG;AACH,wBAAgB,IAAI,IAAI,OAAO,CAS9B"}
|
package/dist/promises/index.d.ts
CHANGED
|
@@ -1,17 +1,44 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Returns a promise that resolves after a given delay (ms).
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```typescript
|
|
6
|
+
* const started = Date.now()
|
|
7
|
+
* await delay(100)
|
|
8
|
+
* Date.now() - started >= 100 // true
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
3
11
|
* @param ms Milliseconds to wait.
|
|
4
12
|
* @returns {Promise<void>}
|
|
5
13
|
*/
|
|
6
14
|
export declare function delay(ms: number): Promise<void>;
|
|
7
15
|
/**
|
|
8
16
|
* Wraps a promise and returns a tuple [error, result].
|
|
17
|
+
* The error slot is `unknown` — narrow it at the call site before touching its properties.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* const [err, value] = await to(Promise.resolve(42))
|
|
22
|
+
* // err = null, value = 42
|
|
23
|
+
*
|
|
24
|
+
* const [err2, value2] = await to(Promise.reject(new Error('boom')))
|
|
25
|
+
* const message = err2 instanceof Error ? err2.message : String(err2)
|
|
26
|
+
* // message = 'boom', value2 = undefined
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
9
29
|
* @param promise The promise to wrap.
|
|
10
|
-
* @returns {Promise<[
|
|
30
|
+
* @returns {Promise<[unknown, T | undefined]>}
|
|
11
31
|
*/
|
|
12
|
-
export declare function to<T>(promise: Promise<T>): Promise<[
|
|
32
|
+
export declare function to<T>(promise: Promise<T>): Promise<[unknown, T | undefined]>;
|
|
13
33
|
/**
|
|
14
34
|
* Returns a promise that rejects after a timeout if the input promise does not resolve.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* await withTimeout(delay(10).then(() => 'fast'), 100) // 'fast'
|
|
39
|
+
* await withTimeout(delay(500), 100) // rejects with Error('Timeout')
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
15
42
|
* @param promise The promise to race.
|
|
16
43
|
* @param ms Timeout in milliseconds.
|
|
17
44
|
* @param error Optional error to throw on timeout.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/promises/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/promises/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE/C;AAED;;;;;;;;;;;;;;;;GAgBG;AAEH,wBAAsB,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,OAAO,EAAE,CAAC,GAAG,SAAS,CAAC,CAAC,CAOlF;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAC5B,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EACnB,EAAE,EAAE,MAAM,EACV,KAAK,GAAE,GAA0B,GAC/B,OAAO,CAAC,CAAC,CAAC,CAEZ;AAED;;;;GAIG;AACH,wBAAgB,GAAG,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC,CAE3D;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC,CAAC,EAAE,CAAC,CAExF;AAED;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC,CAE1D"}
|
package/dist/promises/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../chunks/chunk-
|
|
1
|
+
import{a,b,c,d,e,f}from"../chunks/chunk-7JQSIREC.js";import"../chunks/chunk-ANN5UYCF.js";export{d as all,e as allSettled,a as delay,f as race,b as to,c as withTimeout};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promises.test-d.d.ts","sourceRoot":"","sources":["../../src/promises/promises.test-d.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as t,c as r,d as i,e as s,f as l}from"../chunks/chunk-7JQSIREC.js";import"../chunks/chunk-ANN5UYCF.js";import{describe as m,expectTypeOf as e,it as o}from"vitest";m("promises \u2014 types",()=>{o("withTimeout preserves the awaited type",()=>{e(r(Promise.resolve(42),10)).toEqualTypeOf(),e(r(Promise.resolve({id:1}),10)).toEqualTypeOf()}),o("to returns an [error, value] tuple with the value widened to undefined",()=>{e(t(Promise.resolve("x"))).toEqualTypeOf()}),o("all/allSettled/race preserve the element type",()=>{e(i([Promise.resolve(1)])).toEqualTypeOf(),e(s([Promise.resolve("a")])).toEqualTypeOf(),e(l([Promise.resolve(!0)])).toEqualTypeOf()})});
|
package/dist/random/index.d.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Returns a random integer between min (inclusive) and max (inclusive).
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```typescript
|
|
6
|
+
* randomInt(1, 6) // 3 (any integer from 1 to 6)
|
|
7
|
+
* randomInt(5, 5) // 5
|
|
8
|
+
* ```
|
|
9
|
+
*
|
|
3
10
|
* @param min Minimum integer value.
|
|
4
11
|
* @param max Maximum integer value.
|
|
5
12
|
* @returns {number} Random integer between min and max.
|
|
@@ -7,6 +14,13 @@
|
|
|
7
14
|
export declare function randomInt(min: number, max: number): number;
|
|
8
15
|
/**
|
|
9
16
|
* Returns a random float between min (inclusive) and max (exclusive).
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* randomFloat(0, 1) // 0.7342119...
|
|
21
|
+
* randomFloat(10, 20) // 14.028...
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
10
24
|
* @param min Minimum float value.
|
|
11
25
|
* @param max Maximum float value.
|
|
12
26
|
* @returns {number} Random float between min and max.
|
|
@@ -14,6 +28,13 @@ export declare function randomInt(min: number, max: number): number;
|
|
|
14
28
|
export declare function randomFloat(min: number, max: number): number;
|
|
15
29
|
/**
|
|
16
30
|
* Returns a random boolean value.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* randomBool() // true
|
|
35
|
+
* randomBool() // false
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
17
38
|
* @returns {boolean}
|
|
18
39
|
*/
|
|
19
40
|
export declare function randomBool(): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/random/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/random/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAE1D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAE5D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,IAAI,OAAO,CAEpC;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,CAAC,GAAG,SAAS,CAGxD;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAC3B,MAAM,EAAE,MAAM,EACd,KAAK,GAAE,MAAyE,GAC9E,MAAM,CAMR"}
|
package/dist/regex/index.d.ts
CHANGED
|
@@ -1,11 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Escapes special regex characters in a string so it can be used in a RegExp.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```typescript
|
|
6
|
+
* escapeRegExp('1 + 1 = 2?') // '1 \\+ 1 = 2\\?'
|
|
7
|
+
* new RegExp(escapeRegExp('a.b')).test('a.b') // true
|
|
8
|
+
* new RegExp(escapeRegExp('a.b')).test('axb') // false
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
3
11
|
* @param str The string to escape.
|
|
4
12
|
* @returns The escaped string.
|
|
5
13
|
*/
|
|
6
14
|
export declare function escapeRegExp(str: string): string;
|
|
7
15
|
/**
|
|
8
16
|
* Tests if a string matches a given regex pattern.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* testRegex('hello world', /world/) // true
|
|
21
|
+
* testRegex('hello world', '^hello') // true
|
|
22
|
+
* testRegex('hello', /bye/) // false
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
9
25
|
* @param str The string to test.
|
|
10
26
|
* @param pattern The regex pattern (string or RegExp).
|
|
11
27
|
* @returns True if the string matches, false otherwise.
|
|
@@ -13,6 +29,13 @@ export declare function escapeRegExp(str: string): string;
|
|
|
13
29
|
export declare function testRegex(str: string, pattern: string | RegExp): boolean;
|
|
14
30
|
/**
|
|
15
31
|
* Returns all matches of a regex pattern in a string.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* matchAll('a1 b2 c3', /[a-z](\d)/).map((m) => m[1]) // ['1', '2', '3']
|
|
36
|
+
* matchAll('nothing here', /\d/) // []
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
16
39
|
* @param str The string to search.
|
|
17
40
|
* @param pattern The regex pattern (string or RegExp).
|
|
18
41
|
* @returns An array of matches, or an empty array if none found.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/regex/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/regex/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAGxE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,gBAAgB,EAAE,CASlF;AAED;;;;;;GAMG;AAEH,wBAAgB,eAAe,CAC9B,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,WAAW,EAAE,MAAM,GAAG,CAAC,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,MAAM,CAAC,GACnE,MAAM,CASR;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,CAG5E"}
|
package/dist/security/index.d.ts
CHANGED
|
@@ -1,17 +1,49 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* Removes `<script>` blocks and inline `on*=` event-handler attributes from a string.
|
|
3
|
+
*
|
|
4
|
+
* **Not a sanitizer, and deliberately not named like one.** It is a blocklist over
|
|
5
|
+
* two shapes, so anything it does not name survives, and a single pass can be
|
|
6
|
+
* defeated by nesting the pattern inside itself. Use it as defence in depth on
|
|
7
|
+
* markup you already trust. For untrusted input, escape with `html.escapeHtml`,
|
|
8
|
+
* or run a real sanitizer such as DOMPurify when the markup must survive.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* stripScriptish('<p onclick="steal()">hi</p><script>bad()</script>')
|
|
13
|
+
* // '<p>hi</p>'
|
|
14
|
+
*
|
|
15
|
+
* // Bypassable by construction — this is XSS it does not name, so it survives:
|
|
16
|
+
* stripScriptish('<a href="javascript:alert(1)">x</a>')
|
|
17
|
+
* // '<a href="javascript:alert(1)">x</a>'
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @param str The string to strip.
|
|
21
|
+
* @returns The string with script blocks and inline handlers removed.
|
|
5
22
|
*/
|
|
6
|
-
export declare function
|
|
23
|
+
export declare function stripScriptish(str: string): string;
|
|
7
24
|
/**
|
|
8
25
|
* Checks if a password is strong (min 8 chars, upper, lower, number, special char).
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* isStrongPassword('Str0ng!pass') // true
|
|
30
|
+
* isStrongPassword('password') // false
|
|
31
|
+
* isStrongPassword('Sh0rt!') // false (under 8 characters)
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
9
34
|
* @param password The password to check.
|
|
10
35
|
* @returns True if the password is strong, false otherwise.
|
|
11
36
|
*/
|
|
12
37
|
export declare function isStrongPassword(password: string): boolean;
|
|
13
38
|
/**
|
|
14
39
|
* Generates a cryptographically secure random token (hex string).
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* generateSecureToken() // 64 hex chars (32 bytes)
|
|
44
|
+
* generateSecureToken(8) // 'c1f0a4e29b73d518'
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
15
47
|
* @param length The number of bytes (not hex chars).
|
|
16
48
|
* @returns A random hex string.
|
|
17
49
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/security/index.ts"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/security/index.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAgBlD;AAgDD;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAI1D;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,SAAK,GAAG,MAAM,CAEvD"}
|
package/dist/security/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../chunks/chunk-ANN5UYCF.js";import{randomBytes as
|
|
1
|
+
import"../chunks/chunk-ANN5UYCF.js";import{randomBytes as a}from"node:crypto";function u(t){let e=d(t),n;do n=e,e=e.replace(/[\s/]on\w+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]*)/gi,"");while(e!==n);return e}function d(t){let e=t.toLowerCase(),n="",i=0,s=0;for(;;){let r=e.indexOf("<script",s);if(r===-1)break;let o=e[r+7];if(o!==void 0&&o!==">"&&o!=="/"&&!/\s/.test(o)){s=r+7;continue}let c=e.indexOf(">",r);if(c===-1)break;let f=e.indexOf("</script",c);if(f===-1)break;let l=e.indexOf(">",f);if(l===-1)break;n+=t.slice(i,r),i=l+1,s=i}return n+t.slice(i)}function g(t){return/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[!@#$%^&*()_+\-=[\]{};':"\\|,.<>/?]).{8,}$/.test(t)}function x(t=32){return a(t).toString("hex")}export{x as generateSecureToken,g as isStrongPassword,u as stripScriptish};
|
package/dist/sets/index.d.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Returns the union of two sets.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```typescript
|
|
6
|
+
* union(new Set([1, 2]), new Set([2, 3])) // Set { 1, 2, 3 }
|
|
7
|
+
* ```
|
|
8
|
+
*
|
|
3
9
|
* @param a First set.
|
|
4
10
|
* @param b Second set.
|
|
5
11
|
* @returns {Set<T>} Union of a and b.
|
|
@@ -7,6 +13,13 @@
|
|
|
7
13
|
export declare function union<T>(a: Set<T>, b: Set<T>): Set<T>;
|
|
8
14
|
/**
|
|
9
15
|
* Returns the intersection of two sets.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* intersection(new Set([1, 2, 3]), new Set([2, 3, 4])) // Set { 2, 3 }
|
|
20
|
+
* intersection(new Set([1]), new Set([2])) // Set {}
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
10
23
|
* @param a First set.
|
|
11
24
|
* @param b Second set.
|
|
12
25
|
* @returns {Set<T>} Intersection of a and b.
|
|
@@ -14,6 +27,12 @@ export declare function union<T>(a: Set<T>, b: Set<T>): Set<T>;
|
|
|
14
27
|
export declare function intersection<T>(a: Set<T>, b: Set<T>): Set<T>;
|
|
15
28
|
/**
|
|
16
29
|
* Returns the difference of two sets (elements in a not in b).
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* difference(new Set([1, 2, 3]), new Set([2])) // Set { 1, 3 }
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
17
36
|
* @param a First set.
|
|
18
37
|
* @param b Second set.
|
|
19
38
|
* @returns {Set<T>} Difference of a and b.
|
package/dist/sets/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sets/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sets/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAErD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAE5D;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAE1D;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,OAAO,CAGzD;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,OAAO,CAG3D;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAE9C;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,CAE9C"}
|
package/dist/sleep/index.d.ts
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Returns a promise that resolves after the specified number of milliseconds.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```typescript
|
|
6
|
+
* const started = Date.now()
|
|
7
|
+
* await sleep(200)
|
|
8
|
+
* Date.now() - started >= 200 // true
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
3
11
|
* @param ms Number of milliseconds to sleep.
|
|
4
12
|
* @returns Promise that resolves after ms milliseconds.
|
|
5
13
|
*/
|
|
@@ -7,11 +15,23 @@ export declare const sleep: (ms: number) => Promise<void>;
|
|
|
7
15
|
/**
|
|
8
16
|
* Blocks the event loop for the specified number of milliseconds (synchronous sleep).
|
|
9
17
|
* Not recommended for production use, but useful for scripts or tests.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* sleepSync(50) // blocks the event loop for ~50ms, no await needed
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
10
24
|
* @param ms Number of milliseconds to block.
|
|
11
25
|
*/
|
|
12
26
|
export declare function sleepSync(ms: number): void;
|
|
13
27
|
/**
|
|
14
28
|
* Returns a promise that resolves after a random delay between min and max milliseconds.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* await sleepRandom(100, 500) // resolves after 100–500ms — handy for jittered retries
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
15
35
|
* @param min Minimum milliseconds to sleep.
|
|
16
36
|
* @param max Maximum milliseconds to sleep.
|
|
17
37
|
* @returns Promise that resolves after a random delay.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sleep/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sleep/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,KAAK,GAAI,IAAI,MAAM,KAAG,OAAO,CAAC,IAAI,CACG,CAAA;AAElD;;;;;;;;;;GAUG;AACH,wBAAgB,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAG1C;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAGnE;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAU9E"}
|