@inrixia/helpers 3.0.0 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/conv.d.ts +27 -27
- package/dist/conv.d.ts.map +1 -1
- package/dist/conv.js +41 -41
- package/dist/fn/Promize.d.ts +15 -15
- package/dist/fn/Promize.js +24 -24
- package/dist/fn/Semaphore.d.ts +6 -6
- package/dist/fn/Semaphore.js +30 -30
- package/dist/fn/Semaphore.js.map +1 -1
- package/dist/fn/asyncDebounce.d.ts +1 -1
- package/dist/fn/asyncDebounce.d.ts.map +1 -1
- package/dist/fn/asyncDebounce.js +25 -25
- package/dist/fn/asyncDebounce.js.map +1 -1
- package/dist/fn/debounce.d.ts +1 -1
- package/dist/fn/debounce.d.ts.map +1 -1
- package/dist/fn/debounce.js +12 -12
- package/dist/fn/loopError.d.ts +10 -10
- package/dist/fn/loopError.d.ts.map +1 -1
- package/dist/fn/loopError.js +13 -13
- package/dist/fn/memoize.d.ts +3 -1
- package/dist/fn/memoize.d.ts.map +1 -1
- package/dist/fn/memoize.js +14 -17
- package/dist/fn/memoize.js.map +1 -1
- package/dist/fn/retry.d.ts +6 -7
- package/dist/fn/retry.d.ts.map +1 -1
- package/dist/fn/retry.js +25 -25
- package/dist/fn/retry.js.map +1 -1
- package/dist/fn/runFor.d.ts +1 -1
- package/dist/fn/runFor.d.ts.map +1 -1
- package/dist/fn/runFor.js +10 -10
- package/dist/fn/runFor.js.map +1 -1
- package/dist/fn/toBase64Image.d.ts +1 -1
- package/dist/fn/toBase64Image.d.ts.map +1 -1
- package/dist/fn/toBase64Image.js +13 -13
- package/dist/fn/toRange.d.ts +8 -8
- package/dist/fn/toRange.d.ts.map +1 -1
- package/dist/fn/toRange.js +25 -25
- package/dist/fn/toRange.js.map +1 -1
- package/dist/fs/exists.d.ts +1 -1
- package/dist/fs/exists.d.ts.map +1 -1
- package/dist/fs/exists.js +11 -11
- package/dist/fs/exists.js.map +1 -1
- package/dist/geo.d.ts +18 -18
- package/dist/geo.d.ts.map +1 -1
- package/dist/geo.js +31 -31
- package/dist/index.d.ts +36 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +36 -3
- package/dist/index.js.map +1 -1
- package/dist/math/angleDifference.d.ts +8 -8
- package/dist/math/angleDifference.d.ts.map +1 -1
- package/dist/math/angleDifference.js +15 -15
- package/dist/math/nPad.d.ts +13 -13
- package/dist/math/nPad.d.ts.map +1 -1
- package/dist/math/nPad.js +18 -18
- package/dist/math/qRnd.d.ts +7 -7
- package/dist/math/qRnd.d.ts.map +1 -1
- package/dist/math/qRnd.js +10 -10
- package/dist/math/to360.d.ts +6 -6
- package/dist/math/to360.d.ts.map +1 -1
- package/dist/math/to360.js +9 -9
- package/dist/obj/RecursiveUpdateOptions.d.ts +14 -14
- package/dist/obj/RecursiveUpdateOptions.d.ts.map +1 -1
- package/dist/obj/RecursiveUpdateOptions.js +22 -22
- package/dist/obj/RecursiveUpdateOptions.js.map +1 -1
- package/dist/obj/chunkArray.d.ts +8 -8
- package/dist/obj/chunkArray.d.ts.map +1 -1
- package/dist/obj/chunkArray.js +16 -16
- package/dist/obj/compare.d.ts +23 -23
- package/dist/obj/compare.d.ts.map +1 -1
- package/dist/obj/compare.js +58 -58
- package/dist/obj/compare.js.map +1 -1
- package/dist/obj/deepGet.d.ts +16 -16
- package/dist/obj/deepGet.d.ts.map +1 -1
- package/dist/obj/deepGet.js +20 -20
- package/dist/obj/deepMerge.d.ts +7 -7
- package/dist/obj/deepMerge.d.ts.map +1 -1
- package/dist/obj/deepMerge.js +22 -22
- package/dist/obj/deepMerge.js.map +1 -1
- package/dist/obj/envOrThrow.d.ts +4 -4
- package/dist/obj/envOrThrow.d.ts.map +1 -1
- package/dist/obj/envOrThrow.js +9 -9
- package/dist/obj/fillTemplate.d.ts +17 -17
- package/dist/obj/fillTemplate.d.ts.map +1 -1
- package/dist/obj/fillTemplate.js +26 -26
- package/dist/obj/fillTemplate.js.map +1 -1
- package/dist/obj/getEnv.d.ts +10 -10
- package/dist/obj/getEnv.js +42 -42
- package/dist/obj/getEnv.js.map +1 -1
- package/dist/obj/hash.d.ts +1 -1
- package/dist/obj/hash.d.ts.map +1 -1
- package/dist/obj/hash.js +11 -11
- package/dist/obj/inspect.d.ts +25 -25
- package/dist/obj/inspect.d.ts.map +1 -1
- package/dist/obj/inspect.js +35 -35
- package/dist/obj/objectify.d.ts +14 -14
- package/dist/obj/objectify.d.ts.map +1 -1
- package/dist/obj/objectify.js +13 -13
- package/dist/obj/rebuildTypes.d.ts +5 -5
- package/dist/obj/rebuildTypes.d.ts.map +1 -1
- package/dist/obj/rebuildTypes.js +23 -23
- package/dist/obj/rebuildTypes.js.map +1 -1
- package/dist/test.d.ts +26 -26
- package/dist/test.d.ts.map +1 -1
- package/dist/test.js +68 -68
- package/dist/test.js.map +1 -1
- package/dist/ts/isKeyOf.d.ts +5 -5
- package/dist/ts/isKeyOf.d.ts.map +1 -1
- package/dist/ts/isKeyOf.js +4 -4
- package/dist/ts/isTypeOf.d.ts +11 -11
- package/dist/ts/isTypeOf.d.ts.map +1 -1
- package/dist/ts/isTypeOf.js +11 -11
- package/dist/ts/math.d.ts +11 -11
- package/dist/ts/math.js +1 -1
- package/dist/ts/numRange.d.ts +11 -11
- package/dist/ts/numRange.js +1 -1
- package/dist/ts/typeOf.d.ts +23 -23
- package/dist/ts/typeOf.d.ts.map +1 -1
- package/dist/ts/typeOf.js +27 -27
- package/dist/ts/typeOf.js.map +1 -1
- package/dist/ts/types.d.ts +30 -30
- package/dist/ts/types.js +1 -1
- package/package.json +5 -29
- package/dist/fn/index.d.ts +0 -11
- package/dist/fn/index.d.ts.map +0 -1
- package/dist/fn/index.js +0 -11
- package/dist/fn/index.js.map +0 -1
- package/dist/fs/index.d.ts +0 -2
- package/dist/fs/index.d.ts.map +0 -1
- package/dist/fs/index.js +0 -2
- package/dist/fs/index.js.map +0 -1
- package/dist/math/index.d.ts +0 -5
- package/dist/math/index.d.ts.map +0 -1
- package/dist/math/index.js +0 -5
- package/dist/math/index.js.map +0 -1
- package/dist/obj/index.d.ts +0 -13
- package/dist/obj/index.d.ts.map +0 -1
- package/dist/obj/index.js +0 -13
- package/dist/obj/index.js.map +0 -1
- package/dist/ts/index.d.ts +0 -7
- package/dist/ts/index.d.ts.map +0 -1
- package/dist/ts/index.js +0 -7
- package/dist/ts/index.js.map +0 -1
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { UnknownRecord } from "../ts/types.js";
|
|
2
|
-
type RecursiveUpdateOptions = {
|
|
3
|
-
setUndefined?: boolean;
|
|
4
|
-
setDefined?: boolean;
|
|
5
|
-
};
|
|
6
|
-
/**
|
|
7
|
-
* Recursively update properties of a object with another.
|
|
8
|
-
* @param targetObject Object to update.
|
|
9
|
-
* @param newObject Object with new values to write to `targetObject`.
|
|
10
|
-
* @param options.setUndefined Defaults to `true` Set properties that are undefined on `targetObject`.
|
|
11
|
-
* @param options.setDefined Defaults to `false`. Overwrite properties that are not undefined on `targetObject`.
|
|
12
|
-
*/
|
|
13
|
-
export declare const recursiveUpdate: (targetObject: UnknownRecord, newObject: UnknownRecord, options?: RecursiveUpdateOptions) => void;
|
|
14
|
-
export {};
|
|
1
|
+
import { UnknownRecord } from "../ts/types.js";
|
|
2
|
+
type RecursiveUpdateOptions = {
|
|
3
|
+
setUndefined?: boolean;
|
|
4
|
+
setDefined?: boolean;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Recursively update properties of a object with another.
|
|
8
|
+
* @param targetObject Object to update.
|
|
9
|
+
* @param newObject Object with new values to write to `targetObject`.
|
|
10
|
+
* @param options.setUndefined Defaults to `true` Set properties that are undefined on `targetObject`.
|
|
11
|
+
* @param options.setDefined Defaults to `false`. Overwrite properties that are not undefined on `targetObject`.
|
|
12
|
+
*/
|
|
13
|
+
export declare const recursiveUpdate: (targetObject: UnknownRecord, newObject: UnknownRecord, options?: RecursiveUpdateOptions) => void;
|
|
14
|
+
export {};
|
|
15
15
|
//# sourceMappingURL=RecursiveUpdateOptions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RecursiveUpdateOptions.d.ts","sourceRoot":"","sources":["../../src/obj/RecursiveUpdateOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAG/C,KAAK,sBAAsB,GAAG;IAAE,YAAY,CAAC,EAAE,OAAO,CAAC;IAAC,UAAU,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAE/E;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"RecursiveUpdateOptions.d.ts","sourceRoot":"","sources":["../../src/obj/RecursiveUpdateOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAG/C,KAAK,sBAAsB,GAAG;IAAE,YAAY,CAAC,EAAE,OAAO,CAAC;IAAC,UAAU,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAE/E;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,GAC3B,cAAc,aAAa,EAC3B,WAAW,aAAa,EACxB,UAAS,sBAAkE,KACzE,IAQF,CAAC"}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { isObject } from "../ts/isTypeOf.js";
|
|
2
|
-
/**
|
|
3
|
-
* Recursively update properties of a object with another.
|
|
4
|
-
* @param targetObject Object to update.
|
|
5
|
-
* @param newObject Object with new values to write to `targetObject`.
|
|
6
|
-
* @param options.setUndefined Defaults to `true` Set properties that are undefined on `targetObject`.
|
|
7
|
-
* @param options.setDefined Defaults to `false`. Overwrite properties that are not undefined on `targetObject`.
|
|
8
|
-
*/
|
|
9
|
-
export const recursiveUpdate = (targetObject, newObject, options = { setUndefined: true, setDefined: false }) => {
|
|
10
|
-
if (!isObject(targetObject))
|
|
11
|
-
throw new Error("targetObject is not an object!");
|
|
12
|
-
if (!isObject(newObject))
|
|
13
|
-
throw new Error("newObject is not an object!");
|
|
14
|
-
for (const key in newObject) {
|
|
15
|
-
if (isObject(targetObject[key]) && isObject(newObject[key]))
|
|
16
|
-
recursiveUpdate(targetObject[key], newObject[key], options);
|
|
17
|
-
else if (options.setUndefined && targetObject[key] === undefined)
|
|
18
|
-
targetObject[key] = newObject[key];
|
|
19
|
-
else if (options.setDefined && targetObject[key] !== undefined)
|
|
20
|
-
targetObject[key] = newObject[key];
|
|
21
|
-
}
|
|
22
|
-
};
|
|
1
|
+
import { isObject } from "../ts/isTypeOf.js";
|
|
2
|
+
/**
|
|
3
|
+
* Recursively update properties of a object with another.
|
|
4
|
+
* @param targetObject Object to update.
|
|
5
|
+
* @param newObject Object with new values to write to `targetObject`.
|
|
6
|
+
* @param options.setUndefined Defaults to `true` Set properties that are undefined on `targetObject`.
|
|
7
|
+
* @param options.setDefined Defaults to `false`. Overwrite properties that are not undefined on `targetObject`.
|
|
8
|
+
*/
|
|
9
|
+
export const recursiveUpdate = (targetObject, newObject, options = { setUndefined: true, setDefined: false }) => {
|
|
10
|
+
if (!isObject(targetObject))
|
|
11
|
+
throw new Error("targetObject is not an object!");
|
|
12
|
+
if (!isObject(newObject))
|
|
13
|
+
throw new Error("newObject is not an object!");
|
|
14
|
+
for (const key in newObject) {
|
|
15
|
+
if (isObject(targetObject[key]) && isObject(newObject[key]))
|
|
16
|
+
recursiveUpdate(targetObject[key], newObject[key], options);
|
|
17
|
+
else if (options.setUndefined && targetObject[key] === undefined)
|
|
18
|
+
targetObject[key] = newObject[key];
|
|
19
|
+
else if (options.setDefined && targetObject[key] !== undefined)
|
|
20
|
+
targetObject[key] = newObject[key];
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
23
|
//# sourceMappingURL=RecursiveUpdateOptions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RecursiveUpdateOptions.js","sourceRoot":"","sources":["../../src/obj/RecursiveUpdateOptions.ts"],"names":[],"mappings":"AACA,OAAO,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AC,GAAG,CAAC,KAAK,SAAS;YAAE,YAAY,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;aAChG,IAAI,OAAO,CAAC,UAAU,IAAI,YAAY,CAAC,GAAG,CAAC,KAAK,SAAS;YAAE,YAAY,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;IACpG,CAAC;AACF,CAAC,CAAC"}
|
package/dist/obj/chunkArray.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Breaks `array` into smaller chunks based on `chunkSize`
|
|
3
|
-
* @param array Array to break up.
|
|
4
|
-
* @param chunkSize Maximum size of array chunks.
|
|
5
|
-
*
|
|
6
|
-
* @returns Array containing array chunks.
|
|
7
|
-
*/
|
|
8
|
-
export declare const chunkArray: <T extends
|
|
1
|
+
/**
|
|
2
|
+
* Breaks `array` into smaller chunks based on `chunkSize`
|
|
3
|
+
* @param array Array to break up.
|
|
4
|
+
* @param chunkSize Maximum size of array chunks.
|
|
5
|
+
*
|
|
6
|
+
* @returns Array containing array chunks.
|
|
7
|
+
*/
|
|
8
|
+
export declare const chunkArray: <T extends unknown[] | string>(array: T, chunkSize: number) => T[];
|
|
9
9
|
//# sourceMappingURL=chunkArray.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chunkArray.d.ts","sourceRoot":"","sources":["../../src/obj/chunkArray.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"chunkArray.d.ts","sourceRoot":"","sources":["../../src/obj/chunkArray.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,eAAO,MAAM,UAAU,GAAI,CAAC,SAAS,OAAO,EAAE,GAAG,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,MAAM,KAAG,CAAC,EAMvF,CAAC"}
|
package/dist/obj/chunkArray.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Breaks `array` into smaller chunks based on `chunkSize`
|
|
3
|
-
* @param array Array to break up.
|
|
4
|
-
* @param chunkSize Maximum size of array chunks.
|
|
5
|
-
*
|
|
6
|
-
* @returns Array containing array chunks.
|
|
7
|
-
*/
|
|
8
|
-
export const chunkArray = (array, chunkSize) => {
|
|
9
|
-
if (array.length < chunkSize)
|
|
10
|
-
return [array];
|
|
11
|
-
let i, j;
|
|
12
|
-
const returnArray = [];
|
|
13
|
-
for (i = 0, j = array.length; i < j; i += chunkSize)
|
|
14
|
-
returnArray.push(array.slice(i, i + chunkSize));
|
|
15
|
-
return returnArray;
|
|
16
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* Breaks `array` into smaller chunks based on `chunkSize`
|
|
3
|
+
* @param array Array to break up.
|
|
4
|
+
* @param chunkSize Maximum size of array chunks.
|
|
5
|
+
*
|
|
6
|
+
* @returns Array containing array chunks.
|
|
7
|
+
*/
|
|
8
|
+
export const chunkArray = (array, chunkSize) => {
|
|
9
|
+
if (array.length < chunkSize)
|
|
10
|
+
return [array];
|
|
11
|
+
let i, j;
|
|
12
|
+
const returnArray = [];
|
|
13
|
+
for (i = 0, j = array.length; i < j; i += chunkSize)
|
|
14
|
+
returnArray.push(array.slice(i, i + chunkSize));
|
|
15
|
+
return returnArray;
|
|
16
|
+
};
|
|
17
17
|
//# sourceMappingURL=chunkArray.js.map
|
package/dist/obj/compare.d.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { UnknownRecord } from "../ts/types.js";
|
|
2
|
-
export type TypeCompareResult = boolean | {
|
|
3
|
-
expectedType: string;
|
|
4
|
-
received: string;
|
|
5
|
-
location: string;
|
|
6
|
-
};
|
|
7
|
-
export type ObjTypes = {
|
|
8
|
-
[key: string]: string | string[] | ObjTypes | ObjTypes[];
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* Take in a target `object` and a `types` object with identical keys but values as array of types those keys should be.
|
|
12
|
-
* @param target Object
|
|
13
|
-
* @param types Object identical to `target` but values are types
|
|
14
|
-
* @returns `object` if the types dont match. `True` if they do.
|
|
15
|
-
*/
|
|
16
|
-
export declare const deepTypeCompare: (target: UnknownRecord, types: ObjTypes, location?: string) => TypeCompareResult;
|
|
17
|
-
/**
|
|
18
|
-
* Helper function for `deepTypeCompare` to compare a item to a type or set of types.
|
|
19
|
-
* @param expectedTypes Expected type/types
|
|
20
|
-
* @param receivedValue Object given
|
|
21
|
-
* @param location Location of `got` given
|
|
22
|
-
*/
|
|
23
|
-
export declare const compareTwo: (expectedTypes: string | string[], receivedValue: unknown, location: string) => TypeCompareResult;
|
|
1
|
+
import { UnknownRecord } from "../ts/types.js";
|
|
2
|
+
export type TypeCompareResult = boolean | {
|
|
3
|
+
expectedType: string;
|
|
4
|
+
received: string;
|
|
5
|
+
location: string;
|
|
6
|
+
};
|
|
7
|
+
export type ObjTypes = {
|
|
8
|
+
[key: string]: string | string[] | ObjTypes | ObjTypes[];
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Take in a target `object` and a `types` object with identical keys but values as array of types those keys should be.
|
|
12
|
+
* @param target Object
|
|
13
|
+
* @param types Object identical to `target` but values are types
|
|
14
|
+
* @returns `object` if the types dont match. `True` if they do.
|
|
15
|
+
*/
|
|
16
|
+
export declare const deepTypeCompare: (target: UnknownRecord, types: ObjTypes, location?: string) => TypeCompareResult;
|
|
17
|
+
/**
|
|
18
|
+
* Helper function for `deepTypeCompare` to compare a item to a type or set of types.
|
|
19
|
+
* @param expectedTypes Expected type/types
|
|
20
|
+
* @param receivedValue Object given
|
|
21
|
+
* @param location Location of `got` given
|
|
22
|
+
*/
|
|
23
|
+
export declare const compareTwo: (expectedTypes: string | string[], receivedValue: unknown, location: string) => TypeCompareResult;
|
|
24
24
|
//# sourceMappingURL=compare.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compare.d.ts","sourceRoot":"","sources":["../../src/obj/compare.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAG/C,MAAM,MAAM,iBAAiB,GAAG,OAAO,GAAG;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AACvG,MAAM,MAAM,QAAQ,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,QAAQ,GAAG,QAAQ,EAAE,CAAA;CAAE,CAAC;AAEpF;;;;;GAKG;AACH,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"compare.d.ts","sourceRoot":"","sources":["../../src/obj/compare.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAG/C,MAAM,MAAM,iBAAiB,GAAG,OAAO,GAAG;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AACvG,MAAM,MAAM,QAAQ,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,QAAQ,GAAG,QAAQ,EAAE,CAAA;CAAE,CAAC;AAEpF;;;;;GAKG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,aAAa,EAAE,OAAO,QAAQ,EAAE,iBAAmB,KAAG,iBA0B7F,CAAC;AAEF;;;;;GAKG;AAEH,eAAO,MAAM,UAAU,GAAI,eAAe,MAAM,GAAG,MAAM,EAAE,EAAE,eAAe,OAAO,EAAE,UAAU,MAAM,KAAG,iBAOvG,CAAC"}
|
package/dist/obj/compare.js
CHANGED
|
@@ -1,59 +1,59 @@
|
|
|
1
|
-
import { isObject } from "../ts/isTypeOf.js";
|
|
2
|
-
import { typeOf } from "../ts/typeOf.js";
|
|
3
|
-
/**
|
|
4
|
-
* Take in a target `object` and a `types` object with identical keys but values as array of types those keys should be.
|
|
5
|
-
* @param target Object
|
|
6
|
-
* @param types Object identical to `target` but values are types
|
|
7
|
-
* @returns `object` if the types dont match. `True` if they do.
|
|
8
|
-
*/
|
|
9
|
-
export const deepTypeCompare = (target, types, location = "target") => {
|
|
10
|
-
if (!(isObject(target) && isObject(types)))
|
|
11
|
-
return { location, expectedType: "object", received: `${target}:${typeOf(target)}` };
|
|
12
|
-
for (const key in target) {
|
|
13
|
-
const targetValue = target[key];
|
|
14
|
-
if (isObject(targetValue)) {
|
|
15
|
-
// If target.property is a object then check its child properties
|
|
16
|
-
const same = deepTypeCompare(targetValue, types[key], `${location}.${key}`);
|
|
17
|
-
if (same !== true)
|
|
18
|
-
return same;
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
if (Array.isArray(targetValue) && Array.isArray(types[key])) {
|
|
22
|
-
// target.property and types.property are arrays
|
|
23
|
-
// Check each item in target.property against types.property[0]
|
|
24
|
-
const childCheckType = types[key];
|
|
25
|
-
for (const targetItem of targetValue) {
|
|
26
|
-
const targetType = typeOf(targetItem);
|
|
27
|
-
// If the array entry is a object then check it
|
|
28
|
-
if (targetType === "object")
|
|
29
|
-
return deepTypeCompare(targetItem, childCheckType, `${location}.${key}`);
|
|
30
|
-
else
|
|
31
|
-
return compareTwo(childCheckType, targetItem, `${location}.${key}`);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
const same = compareTwo(types[key], target[key], `${location}.${key}`);
|
|
36
|
-
if (same !== true)
|
|
37
|
-
return same;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return true;
|
|
42
|
-
};
|
|
43
|
-
/**
|
|
44
|
-
* Helper function for `deepTypeCompare` to compare a item to a type or set of types.
|
|
45
|
-
* @param expectedTypes Expected type/types
|
|
46
|
-
* @param receivedValue Object given
|
|
47
|
-
* @param location Location of `got` given
|
|
48
|
-
*/
|
|
49
|
-
export const compareTwo = (expectedTypes, receivedValue, location) => {
|
|
50
|
-
if (!Array.isArray(expectedTypes))
|
|
51
|
-
expectedTypes = [expectedTypes];
|
|
52
|
-
const gotType = typeOf(receivedValue);
|
|
53
|
-
for (const expectedType of expectedTypes) {
|
|
54
|
-
if (gotType !== expectedType)
|
|
55
|
-
return { location, expectedType, received: `${receivedValue}:${gotType}` };
|
|
56
|
-
}
|
|
57
|
-
return true;
|
|
58
|
-
};
|
|
1
|
+
import { isObject } from "../ts/isTypeOf.js";
|
|
2
|
+
import { typeOf } from "../ts/typeOf.js";
|
|
3
|
+
/**
|
|
4
|
+
* Take in a target `object` and a `types` object with identical keys but values as array of types those keys should be.
|
|
5
|
+
* @param target Object
|
|
6
|
+
* @param types Object identical to `target` but values are types
|
|
7
|
+
* @returns `object` if the types dont match. `True` if they do.
|
|
8
|
+
*/
|
|
9
|
+
export const deepTypeCompare = (target, types, location = "target") => {
|
|
10
|
+
if (!(isObject(target) && isObject(types)))
|
|
11
|
+
return { location, expectedType: "object", received: `${target}:${typeOf(target)}` };
|
|
12
|
+
for (const key in target) {
|
|
13
|
+
const targetValue = target[key];
|
|
14
|
+
if (isObject(targetValue)) {
|
|
15
|
+
// If target.property is a object then check its child properties
|
|
16
|
+
const same = deepTypeCompare(targetValue, types[key], `${location}.${key}`);
|
|
17
|
+
if (same !== true)
|
|
18
|
+
return same;
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
if (Array.isArray(targetValue) && Array.isArray(types[key])) {
|
|
22
|
+
// target.property and types.property are arrays
|
|
23
|
+
// Check each item in target.property against types.property[0]
|
|
24
|
+
const childCheckType = types[key];
|
|
25
|
+
for (const targetItem of targetValue) {
|
|
26
|
+
const targetType = typeOf(targetItem);
|
|
27
|
+
// If the array entry is a object then check it
|
|
28
|
+
if (targetType === "object")
|
|
29
|
+
return deepTypeCompare(targetItem, childCheckType, `${location}.${key}`);
|
|
30
|
+
else
|
|
31
|
+
return compareTwo(childCheckType, targetItem, `${location}.${key}`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
const same = compareTwo(types[key], target[key], `${location}.${key}`);
|
|
36
|
+
if (same !== true)
|
|
37
|
+
return same;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return true;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Helper function for `deepTypeCompare` to compare a item to a type or set of types.
|
|
45
|
+
* @param expectedTypes Expected type/types
|
|
46
|
+
* @param receivedValue Object given
|
|
47
|
+
* @param location Location of `got` given
|
|
48
|
+
*/
|
|
49
|
+
export const compareTwo = (expectedTypes, receivedValue, location) => {
|
|
50
|
+
if (!Array.isArray(expectedTypes))
|
|
51
|
+
expectedTypes = [expectedTypes];
|
|
52
|
+
const gotType = typeOf(receivedValue);
|
|
53
|
+
for (const expectedType of expectedTypes) {
|
|
54
|
+
if (gotType !== expectedType)
|
|
55
|
+
return { location, expectedType, received: `${receivedValue}:${gotType}` };
|
|
56
|
+
}
|
|
57
|
+
return true;
|
|
58
|
+
};
|
|
59
59
|
//# sourceMappingURL=compare.js.map
|
package/dist/obj/compare.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compare.js","sourceRoot":"","sources":["../../src/obj/compare.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAKzC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,MAAqB,EAAE,KAAe,EAAE,QAAQ,GAAG,QAAQ,EAAqB,EAAE;IACjH,IAAI,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAC;QAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,MAAM,IAA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
|
4
|
-
* @param obj
|
|
5
|
-
* @param property
|
|
6
|
-
* @param delimiter
|
|
7
|
-
* @example
|
|
8
|
-
* const object = {
|
|
9
|
-
* a: {
|
|
10
|
-
* child: "Hello World"
|
|
11
|
-
* }
|
|
12
|
-
* }
|
|
13
|
-
* const wantedProperty = "a.child"
|
|
14
|
-
* console.log(deepGet(object, wantedProperty)) // -> "Hello World"
|
|
15
|
-
*/
|
|
16
|
-
export declare const deepGet: <T = unknown>(obj: UnknownRecord, property: string, delimiter?: string) => T | undefined;
|
|
1
|
+
import { UnknownRecord } from "../ts/types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Returns the `property` requested from `obj`
|
|
4
|
+
* @param obj
|
|
5
|
+
* @param property
|
|
6
|
+
* @param delimiter
|
|
7
|
+
* @example
|
|
8
|
+
* const object = {
|
|
9
|
+
* a: {
|
|
10
|
+
* child: "Hello World"
|
|
11
|
+
* }
|
|
12
|
+
* }
|
|
13
|
+
* const wantedProperty = "a.child"
|
|
14
|
+
* console.log(deepGet(object, wantedProperty)) // -> "Hello World"
|
|
15
|
+
*/
|
|
16
|
+
export declare const deepGet: <T = unknown>(obj: UnknownRecord, property: string, delimiter?: string) => T | undefined;
|
|
17
17
|
//# sourceMappingURL=deepGet.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deepGet.d.ts","sourceRoot":"","sources":["../../src/obj/deepGet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C;;;;;;;;;;;;;GAaG;AAEH,eAAO,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"deepGet.d.ts","sourceRoot":"","sources":["../../src/obj/deepGet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C;;;;;;;;;;;;;GAaG;AAEH,eAAO,MAAM,OAAO,GAAI,CAAC,GAAG,OAAO,EAAE,KAAK,aAAa,EAAE,UAAU,MAAM,EAAE,kBAAe,KAAG,CAAC,GAAG,SAIhG,CAAC"}
|
package/dist/obj/deepGet.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns the `property` requested from `obj`
|
|
3
|
-
* @param obj
|
|
4
|
-
* @param property
|
|
5
|
-
* @param delimiter
|
|
6
|
-
* @example
|
|
7
|
-
* const object = {
|
|
8
|
-
* a: {
|
|
9
|
-
* child: "Hello World"
|
|
10
|
-
* }
|
|
11
|
-
* }
|
|
12
|
-
* const wantedProperty = "a.child"
|
|
13
|
-
* console.log(deepGet(object, wantedProperty)) // -> "Hello World"
|
|
14
|
-
*/
|
|
15
|
-
export const deepGet = (obj, property, delimiter = ".") => {
|
|
16
|
-
const arr = property.split(delimiter);
|
|
17
|
-
while (arr.length && (obj = obj[arr.shift()]))
|
|
18
|
-
;
|
|
19
|
-
return obj;
|
|
20
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* Returns the `property` requested from `obj`
|
|
3
|
+
* @param obj
|
|
4
|
+
* @param property
|
|
5
|
+
* @param delimiter
|
|
6
|
+
* @example
|
|
7
|
+
* const object = {
|
|
8
|
+
* a: {
|
|
9
|
+
* child: "Hello World"
|
|
10
|
+
* }
|
|
11
|
+
* }
|
|
12
|
+
* const wantedProperty = "a.child"
|
|
13
|
+
* console.log(deepGet(object, wantedProperty)) // -> "Hello World"
|
|
14
|
+
*/
|
|
15
|
+
export const deepGet = (obj, property, delimiter = ".") => {
|
|
16
|
+
const arr = property.split(delimiter);
|
|
17
|
+
while (arr.length && (obj = obj[arr.shift()]))
|
|
18
|
+
;
|
|
19
|
+
return obj;
|
|
20
|
+
};
|
|
21
21
|
//# sourceMappingURL=deepGet.js.map
|
package/dist/obj/deepMerge.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { UnknownRecord } from "../ts/types.js";
|
|
2
|
-
/**
|
|
3
|
-
* Deep merge objects into target. Without modifying target.
|
|
4
|
-
* @param target
|
|
5
|
-
* @param source
|
|
6
|
-
*/
|
|
7
|
-
export declare const deepMerge: <T extends S, S extends UnknownRecord = Partial<T>>(target: T, source: S) => T & S;
|
|
1
|
+
import { UnknownRecord } from "../ts/types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Deep merge objects into target. Without modifying target.
|
|
4
|
+
* @param target
|
|
5
|
+
* @param source
|
|
6
|
+
*/
|
|
7
|
+
export declare const deepMerge: <T extends S, S extends UnknownRecord = Partial<T>>(target: T, source: S) => T & S;
|
|
8
8
|
//# sourceMappingURL=deepMerge.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deepMerge.d.ts","sourceRoot":"","sources":["../../src/obj/deepMerge.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C;;;;GAIG;AAEH,eAAO,MAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"deepMerge.d.ts","sourceRoot":"","sources":["../../src/obj/deepMerge.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C;;;;GAIG;AAEH,eAAO,MAAM,SAAS,GAAI,CAAC,SAAS,CAAC,EAAE,CAAC,SAAS,aAAa,GAAG,OAAO,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,EAAE,QAAQ,CAAC,KAAG,CAAC,GAAG,CAWvG,CAAC"}
|
package/dist/obj/deepMerge.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { isObject } from "../ts/isTypeOf.js";
|
|
2
|
-
/**
|
|
3
|
-
* Deep merge objects into target. Without modifying target.
|
|
4
|
-
* @param target
|
|
5
|
-
* @param source
|
|
6
|
-
*/
|
|
7
|
-
export const deepMerge = (target, source) => {
|
|
8
|
-
const output = Object.assign({}, target);
|
|
9
|
-
if (isObject(target) && isObject(source)) {
|
|
10
|
-
Object.keys(source).forEach((key) => {
|
|
11
|
-
if (isObject(source[key])) {
|
|
12
|
-
if (!(key in target))
|
|
13
|
-
Object.assign(output, { [key]: source[key] });
|
|
14
|
-
else
|
|
15
|
-
output[key] = deepMerge(target[key], source[key]);
|
|
16
|
-
}
|
|
17
|
-
else
|
|
18
|
-
Object.assign(output, { [key]: source[key] });
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
return output;
|
|
22
|
-
};
|
|
1
|
+
import { isObject } from "../ts/isTypeOf.js";
|
|
2
|
+
/**
|
|
3
|
+
* Deep merge objects into target. Without modifying target.
|
|
4
|
+
* @param target
|
|
5
|
+
* @param source
|
|
6
|
+
*/
|
|
7
|
+
export const deepMerge = (target, source) => {
|
|
8
|
+
const output = Object.assign({}, target);
|
|
9
|
+
if (isObject(target) && isObject(source)) {
|
|
10
|
+
Object.keys(source).forEach((key) => {
|
|
11
|
+
if (isObject(source[key])) {
|
|
12
|
+
if (!(key in target))
|
|
13
|
+
Object.assign(output, { [key]: source[key] });
|
|
14
|
+
else
|
|
15
|
+
output[key] = deepMerge(target[key], source[key]);
|
|
16
|
+
}
|
|
17
|
+
else
|
|
18
|
+
Object.assign(output, { [key]: source[key] });
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return output;
|
|
22
|
+
};
|
|
23
23
|
//# sourceMappingURL=deepMerge.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deepMerge.js","sourceRoot":"","sources":["../../src/obj/deepMerge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C;;;;GAIG;AAEH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAoD,MAAS,EAAE,MAAS,EAAS,EAAE;IAC3G,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;IACzC,IAAI,QAAQ,CAAC,MAAM,CAAC,IAAI,QAAQ,CAAC,MAAM,CAAC,EAAE;
|
|
1
|
+
{"version":3,"file":"deepMerge.js","sourceRoot":"","sources":["../../src/obj/deepMerge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C;;;;GAIG;AAEH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAoD,MAAS,EAAE,MAAS,EAAS,EAAE;IAC3G,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;IACzC,IAAI,QAAQ,CAAC,MAAM,CAAC,IAAI,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QAC1C,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;YACnC,IAAI,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;gBAC3B,IAAI,CAAC,CAAC,GAAG,IAAI,MAAM,CAAC;oBAAE,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;;oBAC/C,MAAO,CAAC,GAAG,CAAC,GAAG,SAAS,CAAgB,MAAM,CAAC,GAAG,CAAC,EAAiB,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;YACvG,CAAC;;gBAAM,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACtD,CAAC,CAAC,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC;AACf,CAAC,CAAC"}
|
package/dist/obj/envOrThrow.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Fetch process.env[envName] or throw if its undefined
|
|
3
|
-
*/
|
|
4
|
-
export declare const envOrThrow: (envName: string) => string;
|
|
1
|
+
/**
|
|
2
|
+
* Fetch process.env[envName] or throw if its undefined
|
|
3
|
+
*/
|
|
4
|
+
export declare const envOrThrow: (envName: string) => string;
|
|
5
5
|
//# sourceMappingURL=envOrThrow.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"envOrThrow.d.ts","sourceRoot":"","sources":["../../src/obj/envOrThrow.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"envOrThrow.d.ts","sourceRoot":"","sources":["../../src/obj/envOrThrow.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,UAAU,GAAI,SAAS,MAAM,KAAG,MAI5C,CAAC"}
|
package/dist/obj/envOrThrow.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Fetch process.env[envName] or throw if its undefined
|
|
3
|
-
*/
|
|
4
|
-
export const envOrThrow = (envName) => {
|
|
5
|
-
const envValue = process.env[envName];
|
|
6
|
-
if (envValue === undefined)
|
|
7
|
-
throw new Error(`Enviroment variable "${envName}" is undefined!`);
|
|
8
|
-
return envValue;
|
|
9
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* Fetch process.env[envName] or throw if its undefined
|
|
3
|
+
*/
|
|
4
|
+
export const envOrThrow = (envName) => {
|
|
5
|
+
const envValue = process.env[envName];
|
|
6
|
+
if (envValue === undefined)
|
|
7
|
+
throw new Error(`Enviroment variable "${envName}" is undefined!`);
|
|
8
|
+
return envValue;
|
|
9
|
+
};
|
|
10
10
|
//# sourceMappingURL=envOrThrow.js.map
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { UnknownRecord } from "../ts/types.js";
|
|
2
|
-
/**
|
|
3
|
-
* Replaces values in a given `templatestring` with contentKeys from a given `contentKeys` object.
|
|
4
|
-
* @param contentKeys Object containing key value pairs of contentKeys to fill template string with
|
|
5
|
-
* @param templatestring string containing templates to fill
|
|
6
|
-
* @example
|
|
7
|
-
* const contentKeys = {
|
|
8
|
-
* "title": "This is a title",
|
|
9
|
-
* "info": {
|
|
10
|
-
* "desc": "This is some info!"
|
|
11
|
-
* }
|
|
12
|
-
* }
|
|
13
|
-
* const template = "Wow! {title}... Here is some info: {info.desc}"
|
|
14
|
-
*
|
|
15
|
-
* fillTemplate(contentKeys, template) // => Wow! This is a title... Here is some info: This is some info!"
|
|
16
|
-
*/
|
|
17
|
-
export declare const fillTemplate: (contentKeys: UnknownRecord, templatestring: string, parent?: string) => string;
|
|
1
|
+
import { UnknownRecord } from "../ts/types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Replaces values in a given `templatestring` with contentKeys from a given `contentKeys` object.
|
|
4
|
+
* @param contentKeys Object containing key value pairs of contentKeys to fill template string with
|
|
5
|
+
* @param templatestring string containing templates to fill
|
|
6
|
+
* @example
|
|
7
|
+
* const contentKeys = {
|
|
8
|
+
* "title": "This is a title",
|
|
9
|
+
* "info": {
|
|
10
|
+
* "desc": "This is some info!"
|
|
11
|
+
* }
|
|
12
|
+
* }
|
|
13
|
+
* const template = "Wow! {title}... Here is some info: {info.desc}"
|
|
14
|
+
*
|
|
15
|
+
* fillTemplate(contentKeys, template) // => Wow! This is a title... Here is some info: This is some info!"
|
|
16
|
+
*/
|
|
17
|
+
export declare const fillTemplate: (contentKeys: UnknownRecord, templatestring: string, parent?: string) => string;
|
|
18
18
|
//# sourceMappingURL=fillTemplate.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fillTemplate.d.ts","sourceRoot":"","sources":["../../src/obj/fillTemplate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAG/C;;;;;;;;;;;;;;GAcG;AAEH,eAAO,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"fillTemplate.d.ts","sourceRoot":"","sources":["../../src/obj/fillTemplate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAG/C;;;;;;;;;;;;;;GAcG;AAEH,eAAO,MAAM,YAAY,GAAI,aAAa,aAAa,EAAE,gBAAgB,MAAM,EAAE,eAAW,KAAG,MAO9F,CAAC"}
|
package/dist/obj/fillTemplate.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { isObject } from "../ts/isTypeOf.js";
|
|
2
|
-
/**
|
|
3
|
-
* Replaces values in a given `templatestring` with contentKeys from a given `contentKeys` object.
|
|
4
|
-
* @param contentKeys Object containing key value pairs of contentKeys to fill template string with
|
|
5
|
-
* @param templatestring string containing templates to fill
|
|
6
|
-
* @example
|
|
7
|
-
* const contentKeys = {
|
|
8
|
-
* "title": "This is a title",
|
|
9
|
-
* "info": {
|
|
10
|
-
* "desc": "This is some info!"
|
|
11
|
-
* }
|
|
12
|
-
* }
|
|
13
|
-
* const template = "Wow! {title}... Here is some info: {info.desc}"
|
|
14
|
-
*
|
|
15
|
-
* fillTemplate(contentKeys, template) // => Wow! This is a title... Here is some info: This is some info!"
|
|
16
|
-
*/
|
|
17
|
-
export const fillTemplate = (contentKeys, templatestring, parent = "") => {
|
|
18
|
-
for (const key in contentKeys) {
|
|
19
|
-
const value = contentKeys[key];
|
|
20
|
-
if (isObject(value))
|
|
21
|
-
templatestring = fillTemplate(value, templatestring, `${parent}${key}.`);
|
|
22
|
-
else
|
|
23
|
-
templatestring = templatestring.replaceAll(new RegExp(`{${parent}${key}}`, "g"), String(value));
|
|
24
|
-
}
|
|
25
|
-
return templatestring;
|
|
26
|
-
};
|
|
1
|
+
import { isObject } from "../ts/isTypeOf.js";
|
|
2
|
+
/**
|
|
3
|
+
* Replaces values in a given `templatestring` with contentKeys from a given `contentKeys` object.
|
|
4
|
+
* @param contentKeys Object containing key value pairs of contentKeys to fill template string with
|
|
5
|
+
* @param templatestring string containing templates to fill
|
|
6
|
+
* @example
|
|
7
|
+
* const contentKeys = {
|
|
8
|
+
* "title": "This is a title",
|
|
9
|
+
* "info": {
|
|
10
|
+
* "desc": "This is some info!"
|
|
11
|
+
* }
|
|
12
|
+
* }
|
|
13
|
+
* const template = "Wow! {title}... Here is some info: {info.desc}"
|
|
14
|
+
*
|
|
15
|
+
* fillTemplate(contentKeys, template) // => Wow! This is a title... Here is some info: This is some info!"
|
|
16
|
+
*/
|
|
17
|
+
export const fillTemplate = (contentKeys, templatestring, parent = "") => {
|
|
18
|
+
for (const key in contentKeys) {
|
|
19
|
+
const value = contentKeys[key];
|
|
20
|
+
if (isObject(value))
|
|
21
|
+
templatestring = fillTemplate(value, templatestring, `${parent}${key}.`);
|
|
22
|
+
else
|
|
23
|
+
templatestring = templatestring.replaceAll(new RegExp(`{${parent}${key}}`, "g"), String(value));
|
|
24
|
+
}
|
|
25
|
+
return templatestring;
|
|
26
|
+
};
|
|
27
27
|
//# sourceMappingURL=fillTemplate.js.map
|