@cognite/underscore 1.0.1 → 1.48411.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 +2 -0
- package/dist/arrays.d.ts +31 -31
- package/dist/arrays.js +53 -18
- package/dist/arrays.js.map +1 -0
- package/dist/assert.d.ts +6 -6
- package/dist/assert.js +12 -5
- package/dist/assert.js.map +1 -0
- package/dist/brand.d.ts +41 -38
- package/dist/brand.js +39 -0
- package/dist/brand.js.map +1 -0
- package/dist/chunk-and-process-in-parallel.d.ts +112 -106
- package/dist/chunk-and-process-in-parallel.js +138 -29
- package/dist/chunk-and-process-in-parallel.js.map +1 -0
- package/dist/chunk-array.d.ts +25 -25
- package/dist/chunk-array.js +34 -6
- package/dist/chunk-array.js.map +1 -0
- package/dist/class.d.ts +8 -8
- package/dist/class.js +11 -5
- package/dist/class.js.map +1 -0
- package/dist/exhaustive-guard.d.ts +15 -15
- package/dist/exhaustive-guard.js +19 -5
- package/dist/exhaustive-guard.js.map +1 -0
- package/dist/exponential-backoff-with-jitter.d.ts +13 -13
- package/dist/exponential-backoff-with-jitter.js +23 -7
- package/dist/exponential-backoff-with-jitter.js.map +1 -0
- package/dist/generate-unique-name.d.ts +17 -17
- package/dist/generate-unique-name.js +46 -10
- package/dist/generate-unique-name.js.map +1 -0
- package/dist/get-numbers-between.d.ts +15 -15
- package/dist/get-numbers-between.js +21 -5
- package/dist/get-numbers-between.js.map +1 -0
- package/dist/humanize-value.d.ts +3 -3
- package/dist/humanize-value.js +33 -15
- package/dist/humanize-value.js.map +1 -0
- package/dist/index.d.ts +23 -23
- package/dist/index.js +23 -23
- package/dist/index.js.map +1 -0
- package/dist/is-function.d.ts +5 -5
- package/dist/is-function.js +9 -5
- package/dist/is-function.js.map +1 -0
- package/dist/is-primitive.d.ts +7 -7
- package/dist/is-primitive.js +16 -6
- package/dist/is-primitive.js.map +1 -0
- package/dist/is-valid-url.d.ts +11 -14
- package/dist/is-valid-url.js +39 -16
- package/dist/is-valid-url.js.map +1 -0
- package/dist/iterators.d.ts +7 -7
- package/dist/iterators.js +16 -6
- package/dist/iterators.js.map +1 -0
- package/dist/math.d.ts +10 -10
- package/dist/math.js +16 -7
- package/dist/math.js.map +1 -0
- package/dist/random.d.ts +24 -24
- package/dist/random.js +52 -18
- package/dist/random.js.map +1 -0
- package/dist/react/use-debounce.d.ts +21 -21
- package/dist/react/use-debounce.js +39 -14
- package/dist/react/use-debounce.js.map +1 -0
- package/dist/react/use-derived-promise.d.ts +28 -29
- package/dist/react/use-derived-promise.js +70 -33
- package/dist/react/use-derived-promise.js.map +1 -0
- package/dist/react/use-stable-sync-external-store.d.ts +25 -25
- package/dist/react/use-stable-sync-external-store.js +52 -11
- package/dist/react/use-stable-sync-external-store.js.map +1 -0
- package/dist/react.d.ts +3 -3
- package/dist/react.js +5 -4
- package/dist/react.js.map +1 -0
- package/dist/repeat.d.ts +5 -5
- package/dist/repeat.js +11 -5
- package/dist/repeat.js.map +1 -0
- package/dist/retry-async.d.ts +87 -87
- package/dist/retry-async.js +88 -17
- package/dist/retry-async.js.map +1 -0
- package/dist/sleep.d.ts +5 -5
- package/dist/sleep.js +9 -5
- package/dist/sleep.js.map +1 -0
- package/dist/string.d.ts +35 -35
- package/dist/string.js +48 -9
- package/dist/string.js.map +1 -0
- package/dist/structMap/index.d.ts +3 -3
- package/dist/structMap/index.js +4 -0
- package/dist/structMap/index.js.map +1 -0
- package/dist/structMap/stableStringify.d.ts +21 -21
- package/dist/structMap/stableStringify.js +69 -22
- package/dist/structMap/stableStringify.js.map +1 -0
- package/dist/structMap/structMap.d.ts +111 -108
- package/dist/structMap/structMap.js +131 -28
- package/dist/structMap/structMap.js.map +1 -0
- package/dist/structMap/testUtils.d.ts +8 -8
- package/dist/structMap/testUtils.js +26 -0
- package/dist/structMap/testUtils.js.map +1 -0
- package/dist/structMap/types.d.ts +4 -4
- package/dist/structMap/types.js +5 -0
- package/dist/structMap/types.js.map +1 -0
- package/package.json +7 -4
|
@@ -1,6 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Generates a sequence of numbers between the specified range.
|
|
3
|
+
*
|
|
4
|
+
* @param minInclusive - The starting number of the sequence (inclusive).
|
|
5
|
+
* @param maxExclusive - The ending number of the sequence (exclusive).
|
|
6
|
+
* @param step - The step value to increment by (default is 1).
|
|
7
|
+
* @returns A generator that yields numbers between the specified range.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* const numbers = getNumbersBetween(1, 5);
|
|
12
|
+
* for (const num of numbers) {
|
|
13
|
+
* console.log(num); // 1, 2, 3, 4
|
|
14
|
+
* }
|
|
15
|
+
* ```
|
|
16
|
+
*/ export function* getNumbersBetween(minInclusive, maxExclusive, step = 1) {
|
|
17
|
+
for(let i = minInclusive; i < maxExclusive; i += step){
|
|
18
|
+
yield i;
|
|
19
|
+
}
|
|
4
20
|
}
|
|
5
|
-
|
|
6
|
-
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=get-numbers-between.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/get-numbers-between.ts"],"sourcesContent":["/**\n * Generates a sequence of numbers between the specified range.\n *\n * @param minInclusive - The starting number of the sequence (inclusive).\n * @param maxExclusive - The ending number of the sequence (exclusive).\n * @param step - The step value to increment by (default is 1).\n * @returns A generator that yields numbers between the specified range.\n *\n * @example\n * ```ts\n * const numbers = getNumbersBetween(1, 5);\n * for (const num of numbers) {\n * console.log(num); // 1, 2, 3, 4\n * }\n * ```\n */\nexport function* getNumbersBetween(\n minInclusive: number,\n maxExclusive: number,\n step: number = 1\n): Generator<number> {\n for (let i = minInclusive; i < maxExclusive; i += step) {\n yield i;\n }\n}\n"],"names":["getNumbersBetween","minInclusive","maxExclusive","step","i"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD,OAAO,UAAUA,kBACfC,YAAoB,EACpBC,YAAoB,EACpBC,OAAe,CAAC;IAEhB,IAAK,IAAIC,IAAIH,cAAcG,IAAIF,cAAcE,KAAKD,KAAM;QACtD,MAAMC;IACR;AACF"}
|
package/dist/humanize-value.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
* Turns nested objects and arrays into a flat, human-readable string for UI display.
|
|
3
|
+
* Null, undefined, NaN, and empty collections render as `'-'`.
|
|
4
|
+
*/
|
|
5
5
|
export declare function humanizeValue(value: unknown): string;
|
package/dist/humanize-value.js
CHANGED
|
@@ -1,16 +1,34 @@
|
|
|
1
|
-
import { isArray
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { isArray, isNaN, isObject } from "lodash-es";
|
|
2
|
+
/**
|
|
3
|
+
* Turns nested objects and arrays into a flat, human-readable string for UI display.
|
|
4
|
+
* Null, undefined, NaN, and empty collections render as `'-'`.
|
|
5
|
+
*/ export function humanizeValue(value) {
|
|
6
|
+
if (value === undefined || value === null || isNaN(value)) {
|
|
7
|
+
return '-';
|
|
8
|
+
}
|
|
9
|
+
if (isArray(value) && value.length === 0) {
|
|
10
|
+
return '-';
|
|
11
|
+
}
|
|
12
|
+
if (isObject(value) && Object.keys(value).length === 0) {
|
|
13
|
+
return '-';
|
|
14
|
+
}
|
|
15
|
+
let result = '';
|
|
16
|
+
const parseValue = (val)=>{
|
|
17
|
+
if (isArray(val)) {
|
|
18
|
+
val.forEach((innerValue)=>{
|
|
19
|
+
parseValue(innerValue);
|
|
20
|
+
});
|
|
21
|
+
} else if (isObject(val)) {
|
|
22
|
+
Object.entries(val).forEach(([key, innerValue])=>{
|
|
23
|
+
const humanizedInnerValue = humanizeValue(innerValue);
|
|
24
|
+
result += `${key}: ${humanizedInnerValue} `;
|
|
25
|
+
});
|
|
26
|
+
} else {
|
|
27
|
+
result += `${String(val)} `;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
parseValue(value);
|
|
31
|
+
return result.trim();
|
|
14
32
|
}
|
|
15
|
-
|
|
16
|
-
|
|
33
|
+
|
|
34
|
+
//# sourceMappingURL=humanize-value.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/humanize-value.ts"],"sourcesContent":["import { isArray, isNaN, isObject } from 'lodash-es';\n\n/**\n * Turns nested objects and arrays into a flat, human-readable string for UI display.\n * Null, undefined, NaN, and empty collections render as `'-'`.\n */\nexport function humanizeValue(value: unknown): string {\n if (value === undefined || value === null || isNaN(value)) {\n return '-';\n }\n if (isArray(value) && value.length === 0) {\n return '-';\n }\n if (isObject(value) && Object.keys(value).length === 0) {\n return '-';\n }\n\n let result = '';\n\n const parseValue = (val: unknown): void => {\n if (isArray(val)) {\n val.forEach((innerValue) => {\n parseValue(innerValue);\n });\n } else if (isObject(val)) {\n Object.entries(val).forEach(([key, innerValue]) => {\n const humanizedInnerValue = humanizeValue(innerValue);\n result += `${key}: ${humanizedInnerValue} `;\n });\n } else {\n result += `${String(val)} `;\n }\n };\n\n parseValue(value);\n\n return result.trim();\n}\n"],"names":["isArray","isNaN","isObject","humanizeValue","value","undefined","length","Object","keys","result","parseValue","val","forEach","innerValue","entries","key","humanizedInnerValue","String","trim"],"mappings":"AAAA,SAASA,OAAO,EAAEC,KAAK,EAAEC,QAAQ,QAAQ,YAAY;AAErD;;;CAGC,GACD,OAAO,SAASC,cAAcC,KAAc;IAC1C,IAAIA,UAAUC,aAAaD,UAAU,QAAQH,MAAMG,QAAQ;QACzD,OAAO;IACT;IACA,IAAIJ,QAAQI,UAAUA,MAAME,MAAM,KAAK,GAAG;QACxC,OAAO;IACT;IACA,IAAIJ,SAASE,UAAUG,OAAOC,IAAI,CAACJ,OAAOE,MAAM,KAAK,GAAG;QACtD,OAAO;IACT;IAEA,IAAIG,SAAS;IAEb,MAAMC,aAAa,CAACC;QAClB,IAAIX,QAAQW,MAAM;YAChBA,IAAIC,OAAO,CAAC,CAACC;gBACXH,WAAWG;YACb;QACF,OAAO,IAAIX,SAASS,MAAM;YACxBJ,OAAOO,OAAO,CAACH,KAAKC,OAAO,CAAC,CAAC,CAACG,KAAKF,WAAW;gBAC5C,MAAMG,sBAAsBb,cAAcU;gBAC1CJ,UAAU,GAAGM,IAAI,EAAE,EAAEC,oBAAoB,CAAC,CAAC;YAC7C;QACF,OAAO;YACLP,UAAU,GAAGQ,OAAON,KAAK,CAAC,CAAC;QAC7B;IACF;IAEAD,WAAWN;IAEX,OAAOK,OAAOS,IAAI;AACpB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
export { insertAt, remove, removeAt, swap, shuffle } from
|
|
2
|
-
export { assert } from
|
|
3
|
-
export type { Brand } from
|
|
4
|
-
export { chunkAndProcessInParallel } from
|
|
5
|
-
export { chunkArray } from
|
|
6
|
-
export { isInstanceOf, type Class } from
|
|
7
|
-
export { exhaustiveGuard } from
|
|
8
|
-
export { exponentialBackoffWithJitter } from
|
|
9
|
-
export { generateUniqueName } from
|
|
10
|
-
export { getNumbersBetween } from
|
|
11
|
-
export { humanizeValue } from
|
|
12
|
-
export { isFunction } from
|
|
13
|
-
export { isPrimitive } from
|
|
14
|
-
export { isValidUrl } from
|
|
15
|
-
export { every } from
|
|
16
|
-
export { isEven, isOdd } from
|
|
17
|
-
export { randomString, randomInteger, randomFloat, randomElement
|
|
18
|
-
export { repeat } from
|
|
19
|
-
export { retryAsync } from
|
|
20
|
-
export { sleep } from
|
|
21
|
-
export { capitalizeFirstLetter, kebabToPascalCase, toKebabCase
|
|
22
|
-
export type { KeySerializer } from
|
|
23
|
-
export { stableStringify, StructMap } from
|
|
1
|
+
export { insertAt, remove, removeAt, swap, shuffle } from "./arrays";
|
|
2
|
+
export { assert } from "./assert";
|
|
3
|
+
export type { Brand } from "./brand";
|
|
4
|
+
export { chunkAndProcessInParallel } from "./chunk-and-process-in-parallel";
|
|
5
|
+
export { chunkArray } from "./chunk-array";
|
|
6
|
+
export { isInstanceOf, type Class } from "./class";
|
|
7
|
+
export { exhaustiveGuard } from "./exhaustive-guard";
|
|
8
|
+
export { exponentialBackoffWithJitter } from "./exponential-backoff-with-jitter";
|
|
9
|
+
export { generateUniqueName } from "./generate-unique-name";
|
|
10
|
+
export { getNumbersBetween } from "./get-numbers-between";
|
|
11
|
+
export { humanizeValue } from "./humanize-value";
|
|
12
|
+
export { isFunction } from "./is-function";
|
|
13
|
+
export { isPrimitive } from "./is-primitive";
|
|
14
|
+
export { isValidUrl } from "./is-valid-url";
|
|
15
|
+
export { every } from "./iterators";
|
|
16
|
+
export { isEven, isOdd } from "./math";
|
|
17
|
+
export { randomString, randomInteger, randomFloat, randomElement } from "./random";
|
|
18
|
+
export { repeat } from "./repeat";
|
|
19
|
+
export { retryAsync } from "./retry-async";
|
|
20
|
+
export { sleep } from "./sleep";
|
|
21
|
+
export { capitalizeFirstLetter, kebabToPascalCase, toKebabCase } from "./string";
|
|
22
|
+
export type { KeySerializer } from "./structMap";
|
|
23
|
+
export { stableStringify, StructMap } from "./structMap";
|
package/dist/index.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
export { insertAt, remove, removeAt, swap, shuffle } from "./arrays.js";
|
|
2
|
+
export { assert } from "./assert.js";
|
|
3
|
+
export { chunkAndProcessInParallel } from "./chunk-and-process-in-parallel.js";
|
|
4
|
+
export { chunkArray } from "./chunk-array.js";
|
|
5
|
+
export { isInstanceOf } from "./class.js";
|
|
6
|
+
export { exhaustiveGuard } from "./exhaustive-guard.js";
|
|
7
|
+
export { exponentialBackoffWithJitter } from "./exponential-backoff-with-jitter.js";
|
|
8
|
+
export { generateUniqueName } from "./generate-unique-name.js";
|
|
9
|
+
export { getNumbersBetween } from "./get-numbers-between.js";
|
|
10
|
+
export { humanizeValue } from "./humanize-value.js";
|
|
11
|
+
export { isFunction } from "./is-function.js";
|
|
12
|
+
export { isPrimitive } from "./is-primitive.js";
|
|
13
|
+
export { isValidUrl } from "./is-valid-url.js";
|
|
14
|
+
export { every } from "./iterators.js";
|
|
15
|
+
export { isEven, isOdd } from "./math.js";
|
|
16
|
+
export { randomString, randomInteger, randomFloat, randomElement } from "./random.js";
|
|
17
|
+
export { repeat } from "./repeat.js";
|
|
18
|
+
export { retryAsync } from "./retry-async.js";
|
|
19
|
+
export { sleep } from "./sleep.js";
|
|
20
|
+
export { capitalizeFirstLetter, kebabToPascalCase, toKebabCase } from "./string.js";
|
|
21
|
+
export { stableStringify, StructMap } from "./structMap/index.js";
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export { insertAt, remove, removeAt, swap, shuffle } from './arrays';\nexport { assert } from './assert';\nexport type { Brand } from './brand';\nexport { chunkAndProcessInParallel } from './chunk-and-process-in-parallel';\nexport { chunkArray } from './chunk-array';\nexport { isInstanceOf, type Class } from './class';\nexport { exhaustiveGuard } from './exhaustive-guard';\nexport { exponentialBackoffWithJitter } from './exponential-backoff-with-jitter';\nexport { generateUniqueName } from './generate-unique-name';\nexport { getNumbersBetween } from './get-numbers-between';\nexport { humanizeValue } from './humanize-value';\nexport { isFunction } from './is-function';\nexport { isPrimitive } from './is-primitive';\nexport { isValidUrl } from './is-valid-url';\nexport { every } from './iterators';\nexport { isEven, isOdd } from './math';\nexport {\n randomString,\n randomInteger,\n randomFloat,\n randomElement,\n} from './random';\nexport { repeat } from './repeat';\nexport { retryAsync } from './retry-async';\nexport { sleep } from './sleep';\nexport {\n capitalizeFirstLetter,\n kebabToPascalCase,\n toKebabCase,\n} from './string';\nexport type { KeySerializer } from './structMap';\nexport { stableStringify, StructMap } from './structMap';\n"],"names":["insertAt","remove","removeAt","swap","shuffle","assert","chunkAndProcessInParallel","chunkArray","isInstanceOf","exhaustiveGuard","exponentialBackoffWithJitter","generateUniqueName","getNumbersBetween","humanizeValue","isFunction","isPrimitive","isValidUrl","every","isEven","isOdd","randomString","randomInteger","randomFloat","randomElement","repeat","retryAsync","sleep","capitalizeFirstLetter","kebabToPascalCase","toKebabCase","stableStringify","StructMap"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,QAAQ,EAAEC,IAAI,EAAEC,OAAO,QAAQ,cAAW;AACrE,SAASC,MAAM,QAAQ,cAAW;AAElC,SAASC,yBAAyB,QAAQ,qCAAkC;AAC5E,SAASC,UAAU,QAAQ,mBAAgB;AAC3C,SAASC,YAAY,QAAoB,aAAU;AACnD,SAASC,eAAe,QAAQ,wBAAqB;AACrD,SAASC,4BAA4B,QAAQ,uCAAoC;AACjF,SAASC,kBAAkB,QAAQ,4BAAyB;AAC5D,SAASC,iBAAiB,QAAQ,2BAAwB;AAC1D,SAASC,aAAa,QAAQ,sBAAmB;AACjD,SAASC,UAAU,QAAQ,mBAAgB;AAC3C,SAASC,WAAW,QAAQ,oBAAiB;AAC7C,SAASC,UAAU,QAAQ,oBAAiB;AAC5C,SAASC,KAAK,QAAQ,iBAAc;AACpC,SAASC,MAAM,EAAEC,KAAK,QAAQ,YAAS;AACvC,SACEC,YAAY,EACZC,aAAa,EACbC,WAAW,EACXC,aAAa,QACR,cAAW;AAClB,SAASC,MAAM,QAAQ,cAAW;AAClC,SAASC,UAAU,QAAQ,mBAAgB;AAC3C,SAASC,KAAK,QAAQ,aAAU;AAChC,SACEC,qBAAqB,EACrBC,iBAAiB,EACjBC,WAAW,QACN,cAAW;AAElB,SAASC,eAAe,EAAEC,SAAS,QAAQ,uBAAc"}
|
package/dist/is-function.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
* Checks if the given value is a function.
|
|
3
|
+
*
|
|
4
|
+
* @param maybeFunction - The value to check.
|
|
5
|
+
* @returns True if the value is a function, otherwise false.
|
|
6
|
+
*/
|
|
7
7
|
export declare function isFunction(maybeFunction: unknown): maybeFunction is Function;
|
package/dist/is-function.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Checks if the given value is a function.
|
|
3
|
+
*
|
|
4
|
+
* @param maybeFunction - The value to check.
|
|
5
|
+
* @returns True if the value is a function, otherwise false.
|
|
6
|
+
*/ export function isFunction(maybeFunction) {
|
|
7
|
+
return typeof maybeFunction === 'function';
|
|
4
8
|
}
|
|
5
|
-
|
|
6
|
-
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=is-function.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/is-function.ts"],"sourcesContent":["/**\n * Checks if the given value is a function.\n *\n * @param maybeFunction - The value to check.\n * @returns True if the value is a function, otherwise false.\n */\nexport function isFunction(maybeFunction: unknown): maybeFunction is Function {\n return typeof maybeFunction === 'function';\n}\n"],"names":["isFunction","maybeFunction"],"mappings":"AAAA;;;;;CAKC,GACD,OAAO,SAASA,WAAWC,aAAsB;IAC/C,OAAO,OAAOA,kBAAkB;AAClC"}
|
package/dist/is-primitive.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
* Checks if the given value is a primitive.
|
|
3
|
+
* Primitives include: string, number, boolean, null, undefined, symbol, and bigint.
|
|
4
|
+
* {@link https://developer.mozilla.org/en-US/docs/Glossary/Primitive}
|
|
5
|
+
*
|
|
6
|
+
* @param value - The value to check.
|
|
7
|
+
* @returns Returns true if the value is a primitive, false otherwise.
|
|
8
|
+
*/
|
|
9
9
|
export declare function isPrimitive(value: unknown): boolean;
|
package/dist/is-primitive.js
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Checks if the given value is a primitive.
|
|
3
|
+
* Primitives include: string, number, boolean, null, undefined, symbol, and bigint.
|
|
4
|
+
* {@link https://developer.mozilla.org/en-US/docs/Glossary/Primitive}
|
|
5
|
+
*
|
|
6
|
+
* @param value - The value to check.
|
|
7
|
+
* @returns Returns true if the value is a primitive, false otherwise.
|
|
8
|
+
*/ export function isPrimitive(value) {
|
|
9
|
+
const type = typeof value;
|
|
10
|
+
// "typeof null" returns 'object', so we need to check explicitly for null
|
|
11
|
+
if (value === null) {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
return type === 'string' || type === 'number' || type === 'boolean' || type === 'undefined' || type === 'symbol' || type === 'bigint';
|
|
5
15
|
}
|
|
6
|
-
|
|
7
|
-
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=is-primitive.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/is-primitive.ts"],"sourcesContent":["/**\n * Checks if the given value is a primitive.\n * Primitives include: string, number, boolean, null, undefined, symbol, and bigint.\n * {@link https://developer.mozilla.org/en-US/docs/Glossary/Primitive}\n *\n * @param value - The value to check.\n * @returns Returns true if the value is a primitive, false otherwise.\n */\nexport function isPrimitive(value: unknown): boolean {\n const type = typeof value;\n\n // \"typeof null\" returns 'object', so we need to check explicitly for null\n if (value === null) {\n return true;\n }\n\n return (\n type === 'string' ||\n type === 'number' ||\n type === 'boolean' ||\n type === 'undefined' ||\n type === 'symbol' ||\n type === 'bigint'\n );\n}\n"],"names":["isPrimitive","value","type"],"mappings":"AAAA;;;;;;;CAOC,GACD,OAAO,SAASA,YAAYC,KAAc;IACxC,MAAMC,OAAO,OAAOD;IAEpB,0EAA0E;IAC1E,IAAIA,UAAU,MAAM;QAClB,OAAO;IACT;IAEA,OACEC,SAAS,YACTA,SAAS,YACTA,SAAS,aACTA,SAAS,eACTA,SAAS,YACTA,SAAS;AAEb"}
|
package/dist/is-valid-url.d.ts
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
* @param {unknown} value - The value to be checked.
|
|
14
|
-
* @returns {value is string} - Returns `true` if the value is a valid URL, otherwise `false`.
|
|
15
|
-
*/
|
|
2
|
+
* Checks if a value is a valid URL.
|
|
3
|
+
*
|
|
4
|
+
* A valid URL must:
|
|
5
|
+
* - Be a string.
|
|
6
|
+
* - Start with "http://" or "https://".
|
|
7
|
+
* - Contain a valid domain name.
|
|
8
|
+
* - Not contain spaces in the host part.
|
|
9
|
+
*
|
|
10
|
+
* @param {unknown} value - The value to be checked.
|
|
11
|
+
* @returns {value is string} - Returns `true` if the value is a valid URL, otherwise `false`.
|
|
12
|
+
*/
|
|
16
13
|
export declare function isValidUrl(value: unknown): value is string;
|
package/dist/is-valid-url.js
CHANGED
|
@@ -1,17 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Inspired by: https://github.com/segmentio/is-url
|
|
3
|
+
*/ const protocolAndDomainRE = /^(https?):\/\/(\S+)$/;
|
|
4
|
+
const domainRE = /^[^\s\\.]+\.\S{2,}$/;
|
|
5
|
+
/**
|
|
6
|
+
* Checks if a value is a valid URL.
|
|
7
|
+
*
|
|
8
|
+
* A valid URL must:
|
|
9
|
+
* - Be a string.
|
|
10
|
+
* - Start with "http://" or "https://".
|
|
11
|
+
* - Contain a valid domain name.
|
|
12
|
+
* - Not contain spaces in the host part.
|
|
13
|
+
*
|
|
14
|
+
* @param {unknown} value - The value to be checked.
|
|
15
|
+
* @returns {value is string} - Returns `true` if the value is a valid URL, otherwise `false`.
|
|
16
|
+
*/ export function isValidUrl(value) {
|
|
17
|
+
if (typeof value !== 'string') {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
const match = value.match(protocolAndDomainRE);
|
|
21
|
+
if (!match) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
const everythingAfterProtocol = match[2];
|
|
25
|
+
if (!everythingAfterProtocol) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
if (!domainRE.test(everythingAfterProtocol)) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
// Added for extra safety to prevent XSS attack vectors
|
|
32
|
+
try {
|
|
33
|
+
const url = new URL(value);
|
|
34
|
+
return url.protocol === 'http:' || url.protocol === 'https:';
|
|
35
|
+
} catch (_) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
15
38
|
}
|
|
16
|
-
|
|
17
|
-
|
|
39
|
+
|
|
40
|
+
//# sourceMappingURL=is-valid-url.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/is-valid-url.ts"],"sourcesContent":["/**\n * Inspired by: https://github.com/segmentio/is-url\n */\n\nconst protocolAndDomainRE = /^(https?):\\/\\/(\\S+)$/;\nconst domainRE = /^[^\\s\\\\.]+\\.\\S{2,}$/;\n\n/**\n * Checks if a value is a valid URL.\n *\n * A valid URL must:\n * - Be a string.\n * - Start with \"http://\" or \"https://\".\n * - Contain a valid domain name.\n * - Not contain spaces in the host part.\n *\n * @param {unknown} value - The value to be checked.\n * @returns {value is string} - Returns `true` if the value is a valid URL, otherwise `false`.\n */\nexport function isValidUrl(value: unknown): value is string {\n if (typeof value !== 'string') {\n return false;\n }\n\n const match = value.match(protocolAndDomainRE);\n if (!match) {\n return false;\n }\n\n const everythingAfterProtocol = match[2];\n if (!everythingAfterProtocol) {\n return false;\n }\n\n if (!domainRE.test(everythingAfterProtocol)) {\n return false;\n }\n\n // Added for extra safety to prevent XSS attack vectors\n try {\n const url = new URL(value);\n return url.protocol === 'http:' || url.protocol === 'https:';\n } catch (_) {\n return false;\n }\n}\n"],"names":["protocolAndDomainRE","domainRE","isValidUrl","value","match","everythingAfterProtocol","test","url","URL","protocol","_"],"mappings":"AAAA;;CAEC,GAED,MAAMA,sBAAsB;AAC5B,MAAMC,WAAW;AAEjB;;;;;;;;;;;CAWC,GACD,OAAO,SAASC,WAAWC,KAAc;IACvC,IAAI,OAAOA,UAAU,UAAU;QAC7B,OAAO;IACT;IAEA,MAAMC,QAAQD,MAAMC,KAAK,CAACJ;IAC1B,IAAI,CAACI,OAAO;QACV,OAAO;IACT;IAEA,MAAMC,0BAA0BD,KAAK,CAAC,EAAE;IACxC,IAAI,CAACC,yBAAyB;QAC5B,OAAO;IACT;IAEA,IAAI,CAACJ,SAASK,IAAI,CAACD,0BAA0B;QAC3C,OAAO;IACT;IAEA,uDAAuD;IACvD,IAAI;QACF,MAAME,MAAM,IAAIC,IAAIL;QACpB,OAAOI,IAAIE,QAAQ,KAAK,WAAWF,IAAIE,QAAQ,KAAK;IACtD,EAAE,OAAOC,GAAG;QACV,OAAO;IACT;AACF"}
|
package/dist/iterators.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
* Tests whether all elements in the iterable pass the test implemented by the provided predicate function.
|
|
3
|
+
*
|
|
4
|
+
* @template T - The type of elements in the iterable.
|
|
5
|
+
* @param {Iterable<T>} iterable - The iterable to be tested.
|
|
6
|
+
* @param {(value: T) => boolean} predicate - A function that tests each element of the iterable.
|
|
7
|
+
* @returns {boolean} - Returns `true` if all elements pass the test, otherwise `false`.
|
|
8
|
+
*/
|
|
9
9
|
export declare function every<T>(iterable: Iterable<T>, predicate: (value: T) => boolean): boolean;
|
package/dist/iterators.js
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Tests whether all elements in the iterable pass the test implemented by the provided predicate function.
|
|
3
|
+
*
|
|
4
|
+
* @template T - The type of elements in the iterable.
|
|
5
|
+
* @param {Iterable<T>} iterable - The iterable to be tested.
|
|
6
|
+
* @param {(value: T) => boolean} predicate - A function that tests each element of the iterable.
|
|
7
|
+
* @returns {boolean} - Returns `true` if all elements pass the test, otherwise `false`.
|
|
8
|
+
*/ export function every(iterable, predicate) {
|
|
9
|
+
for (const item of iterable){
|
|
10
|
+
if (!predicate(item)) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return true;
|
|
5
15
|
}
|
|
6
|
-
|
|
7
|
-
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=iterators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/iterators.ts"],"sourcesContent":["/**\n * Tests whether all elements in the iterable pass the test implemented by the provided predicate function.\n *\n * @template T - The type of elements in the iterable.\n * @param {Iterable<T>} iterable - The iterable to be tested.\n * @param {(value: T) => boolean} predicate - A function that tests each element of the iterable.\n * @returns {boolean} - Returns `true` if all elements pass the test, otherwise `false`.\n */\nexport function every<T>(\n iterable: Iterable<T>,\n predicate: (value: T) => boolean\n): boolean {\n for (const item of iterable) {\n if (!predicate(item)) {\n return false;\n }\n }\n return true;\n}\n"],"names":["every","iterable","predicate","item"],"mappings":"AAAA;;;;;;;CAOC,GACD,OAAO,SAASA,MACdC,QAAqB,EACrBC,SAAgC;IAEhC,KAAK,MAAMC,QAAQF,SAAU;QAC3B,IAAI,CAACC,UAAUC,OAAO;YACpB,OAAO;QACT;IACF;IACA,OAAO;AACT"}
|
package/dist/math.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
* Determines if a number is even.
|
|
3
|
+
*
|
|
4
|
+
* @param value - The number to check.
|
|
5
|
+
* @returns `true` if the number is even, otherwise `false`.
|
|
6
|
+
*/
|
|
7
7
|
export declare function isEven(value: number): boolean;
|
|
8
8
|
/**
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
* Determines if a number is odd.
|
|
10
|
+
*
|
|
11
|
+
* @param value - The number to check.
|
|
12
|
+
* @returns `true` if the number is odd, otherwise `false`.
|
|
13
|
+
*/
|
|
14
14
|
export declare function isOdd(value: number): boolean;
|
package/dist/math.js
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Determines if a number is even.
|
|
3
|
+
*
|
|
4
|
+
* @param value - The number to check.
|
|
5
|
+
* @returns `true` if the number is even, otherwise `false`.
|
|
6
|
+
*/ export function isEven(value) {
|
|
7
|
+
return value % 2 === 0;
|
|
4
8
|
}
|
|
5
|
-
|
|
6
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Determines if a number is odd.
|
|
11
|
+
*
|
|
12
|
+
* @param value - The number to check.
|
|
13
|
+
* @returns `true` if the number is odd, otherwise `false`.
|
|
14
|
+
*/ export function isOdd(value) {
|
|
15
|
+
return !isEven(value);
|
|
7
16
|
}
|
|
8
|
-
|
|
9
|
-
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=math.js.map
|
package/dist/math.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/math.ts"],"sourcesContent":["/**\n * Determines if a number is even.\n *\n * @param value - The number to check.\n * @returns `true` if the number is even, otherwise `false`.\n */\nexport function isEven(value: number): boolean {\n return value % 2 === 0;\n}\n\n/**\n * Determines if a number is odd.\n *\n * @param value - The number to check.\n * @returns `true` if the number is odd, otherwise `false`.\n */\nexport function isOdd(value: number): boolean {\n return !isEven(value);\n}\n"],"names":["isEven","value","isOdd"],"mappings":"AAAA;;;;;CAKC,GACD,OAAO,SAASA,OAAOC,KAAa;IAClC,OAAOA,QAAQ,MAAM;AACvB;AAEA;;;;;CAKC,GACD,OAAO,SAASC,MAAMD,KAAa;IACjC,OAAO,CAACD,OAAOC;AACjB"}
|
package/dist/random.d.ts
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
* Generates a random string of the specified length using alphanumeric characters.
|
|
3
|
+
*
|
|
4
|
+
* @param {number} length - The length of the random string to generate. Must be greater than 0.
|
|
5
|
+
* @returns {string} A random string of the specified length.
|
|
6
|
+
* @throws {Error} If the length is less than 1.
|
|
7
|
+
*/
|
|
8
8
|
export declare function randomString(length: number): string;
|
|
9
9
|
/**
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
* Returns a random element from the given array.
|
|
11
|
+
*
|
|
12
|
+
* @template T - The type of elements in the array.
|
|
13
|
+
* @param {T[]} array - The array from which to select a random element.
|
|
14
|
+
* @returns {T} A random element from the array.
|
|
15
|
+
*/
|
|
16
16
|
export declare function randomElement<T>(array: readonly T[]): T;
|
|
17
17
|
/**
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
* Returns a random integer between minInclusive and maxExclusive.
|
|
19
|
+
*
|
|
20
|
+
* @param minInclusive
|
|
21
|
+
* @param maxExclusive
|
|
22
|
+
* @returns
|
|
23
|
+
*/
|
|
24
24
|
export declare function randomInteger(minInclusive: number, maxExclusive: number): number;
|
|
25
25
|
/**
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
* Generates a random float within the given range [min, max).
|
|
27
|
+
*
|
|
28
|
+
* @param {number} minInclusive - The minimum value (inclusive).
|
|
29
|
+
* @param {number} maxExclusive - The maximum value (exclusive).
|
|
30
|
+
* @returns {number} A random float within the range [min, max).
|
|
31
|
+
*/
|
|
32
32
|
export declare function randomFloat(minInclusive: number, maxExclusive: number): number;
|