@inrixia/helpers 2.0.11 → 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.
Files changed (173) hide show
  1. package/dist/{logic.d.ts → fn/Promize.d.ts} +1 -8
  2. package/dist/fn/Promize.d.ts.map +1 -0
  3. package/dist/fn/Promize.js +25 -0
  4. package/dist/fn/Promize.js.map +1 -0
  5. package/dist/fn/Semaphore.d.ts +7 -0
  6. package/dist/fn/Semaphore.d.ts.map +1 -0
  7. package/dist/fn/Semaphore.js +31 -0
  8. package/dist/fn/Semaphore.js.map +1 -0
  9. package/dist/fn/asyncDebounce.d.ts +2 -0
  10. package/dist/fn/asyncDebounce.d.ts.map +1 -0
  11. package/dist/fn/asyncDebounce.js +26 -0
  12. package/dist/fn/asyncDebounce.js.map +1 -0
  13. package/dist/fn/debounce.d.ts +2 -0
  14. package/dist/fn/debounce.d.ts.map +1 -0
  15. package/dist/fn/debounce.js +13 -0
  16. package/dist/fn/debounce.js.map +1 -0
  17. package/dist/fn/index.d.ts +11 -0
  18. package/dist/fn/index.d.ts.map +1 -0
  19. package/dist/fn/index.js +11 -0
  20. package/dist/fn/index.js.map +1 -0
  21. package/dist/fn/loopError.d.ts +11 -0
  22. package/dist/fn/loopError.d.ts.map +1 -0
  23. package/dist/fn/loopError.js +14 -0
  24. package/dist/fn/loopError.js.map +1 -0
  25. package/dist/fn/memoize.d.ts +2 -0
  26. package/dist/fn/memoize.d.ts.map +1 -0
  27. package/dist/fn/memoize.js +18 -0
  28. package/dist/fn/memoize.js.map +1 -0
  29. package/dist/fn/retry.d.ts +8 -0
  30. package/dist/fn/retry.d.ts.map +1 -0
  31. package/dist/{logic.js → fn/retry.js} +1 -25
  32. package/dist/fn/retry.js.map +1 -0
  33. package/dist/fn/runFor.d.ts +2 -0
  34. package/dist/fn/runFor.d.ts.map +1 -0
  35. package/dist/fn/runFor.js +11 -0
  36. package/dist/fn/runFor.js.map +1 -0
  37. package/dist/{react.d.ts → fn/toBase64Image.d.ts} +1 -1
  38. package/dist/fn/toBase64Image.d.ts.map +1 -0
  39. package/dist/{react.js → fn/toBase64Image.js} +1 -1
  40. package/dist/fn/toBase64Image.js.map +1 -0
  41. package/dist/fn/toRange.d.ts +9 -0
  42. package/dist/fn/toRange.d.ts.map +1 -0
  43. package/dist/fn/toRange.js +26 -0
  44. package/dist/fn/toRange.js.map +1 -0
  45. package/dist/fs/exists.d.ts +2 -0
  46. package/dist/fs/exists.d.ts.map +1 -0
  47. package/dist/fs/exists.js +12 -0
  48. package/dist/fs/exists.js.map +1 -0
  49. package/dist/fs/index.d.ts +2 -0
  50. package/dist/fs/index.d.ts.map +1 -0
  51. package/dist/fs/index.js +2 -0
  52. package/dist/fs/index.js.map +1 -0
  53. package/dist/index.d.ts +0 -5
  54. package/dist/index.d.ts.map +1 -1
  55. package/dist/index.js +0 -5
  56. package/dist/index.js.map +1 -1
  57. package/dist/math/angleDifference.d.ts +9 -0
  58. package/dist/math/angleDifference.d.ts.map +1 -0
  59. package/dist/math/angleDifference.js +16 -0
  60. package/dist/math/angleDifference.js.map +1 -0
  61. package/dist/math/index.d.ts +5 -0
  62. package/dist/math/index.d.ts.map +1 -0
  63. package/dist/math/index.js +5 -0
  64. package/dist/math/index.js.map +1 -0
  65. package/dist/math/nPad.d.ts +14 -0
  66. package/dist/math/nPad.d.ts.map +1 -0
  67. package/dist/math/nPad.js +19 -0
  68. package/dist/math/nPad.js.map +1 -0
  69. package/dist/math/qRnd.d.ts +8 -0
  70. package/dist/math/qRnd.d.ts.map +1 -0
  71. package/dist/math/qRnd.js +11 -0
  72. package/dist/math/qRnd.js.map +1 -0
  73. package/dist/math/to360.d.ts +7 -0
  74. package/dist/math/to360.d.ts.map +1 -0
  75. package/dist/math/to360.js +10 -0
  76. package/dist/math/to360.js.map +1 -0
  77. package/dist/obj/RecursiveUpdateOptions.d.ts +15 -0
  78. package/dist/obj/RecursiveUpdateOptions.d.ts.map +1 -0
  79. package/dist/obj/RecursiveUpdateOptions.js +23 -0
  80. package/dist/obj/RecursiveUpdateOptions.js.map +1 -0
  81. package/dist/obj/chunkArray.d.ts +9 -0
  82. package/dist/obj/chunkArray.d.ts.map +1 -0
  83. package/dist/obj/chunkArray.js +17 -0
  84. package/dist/obj/chunkArray.js.map +1 -0
  85. package/dist/obj/compare.d.ts +24 -0
  86. package/dist/obj/compare.d.ts.map +1 -0
  87. package/dist/obj/compare.js +59 -0
  88. package/dist/obj/compare.js.map +1 -0
  89. package/dist/obj/deepGet.d.ts +17 -0
  90. package/dist/obj/deepGet.d.ts.map +1 -0
  91. package/dist/obj/deepGet.js +21 -0
  92. package/dist/obj/deepGet.js.map +1 -0
  93. package/dist/obj/deepMerge.d.ts +8 -0
  94. package/dist/obj/deepMerge.d.ts.map +1 -0
  95. package/dist/obj/deepMerge.js +23 -0
  96. package/dist/obj/deepMerge.js.map +1 -0
  97. package/dist/obj/envOrThrow.d.ts +5 -0
  98. package/dist/obj/envOrThrow.d.ts.map +1 -0
  99. package/dist/obj/envOrThrow.js +10 -0
  100. package/dist/obj/envOrThrow.js.map +1 -0
  101. package/dist/obj/fillTemplate.d.ts +18 -0
  102. package/dist/obj/fillTemplate.d.ts.map +1 -0
  103. package/dist/obj/fillTemplate.js +27 -0
  104. package/dist/obj/fillTemplate.js.map +1 -0
  105. package/dist/obj/getEnv.d.ts +11 -0
  106. package/dist/obj/getEnv.d.ts.map +1 -0
  107. package/dist/obj/getEnv.js +43 -0
  108. package/dist/obj/getEnv.js.map +1 -0
  109. package/dist/obj/hash.d.ts +2 -0
  110. package/dist/obj/hash.d.ts.map +1 -0
  111. package/dist/obj/hash.js +12 -0
  112. package/dist/obj/hash.js.map +1 -0
  113. package/dist/obj/index.d.ts +13 -0
  114. package/dist/obj/index.d.ts.map +1 -0
  115. package/dist/obj/index.js +13 -0
  116. package/dist/obj/index.js.map +1 -0
  117. package/dist/{inspect.d.ts → obj/inspect.d.ts} +1 -1
  118. package/dist/obj/inspect.d.ts.map +1 -0
  119. package/dist/obj/inspect.js.map +1 -0
  120. package/dist/obj/objectify.d.ts +15 -0
  121. package/dist/obj/objectify.d.ts.map +1 -0
  122. package/dist/obj/objectify.js +14 -0
  123. package/dist/obj/objectify.js.map +1 -0
  124. package/dist/obj/rebuildTypes.d.ts +6 -0
  125. package/dist/obj/rebuildTypes.d.ts.map +1 -0
  126. package/dist/obj/rebuildTypes.js +24 -0
  127. package/dist/obj/rebuildTypes.js.map +1 -0
  128. package/dist/test.d.ts +3 -3
  129. package/dist/test.d.ts.map +1 -1
  130. package/dist/ts/index.d.ts +7 -0
  131. package/dist/ts/index.d.ts.map +1 -0
  132. package/dist/ts/index.js +7 -0
  133. package/dist/ts/index.js.map +1 -0
  134. package/dist/ts/isKeyOf.d.ts +6 -0
  135. package/dist/ts/isKeyOf.d.ts.map +1 -0
  136. package/dist/ts/isKeyOf.js +5 -0
  137. package/dist/ts/isKeyOf.js.map +1 -0
  138. package/dist/ts/isTypeOf.d.ts +12 -0
  139. package/dist/ts/isTypeOf.d.ts.map +1 -0
  140. package/dist/ts/isTypeOf.js +12 -0
  141. package/dist/ts/isTypeOf.js.map +1 -0
  142. package/dist/ts/math.d.ts +10 -10
  143. package/dist/ts/math.d.ts.map +1 -1
  144. package/dist/ts/numRange.d.ts +6 -6
  145. package/dist/ts/numRange.d.ts.map +1 -1
  146. package/dist/ts/typeOf.d.ts +24 -0
  147. package/dist/ts/typeOf.d.ts.map +1 -0
  148. package/dist/ts/typeOf.js +28 -0
  149. package/dist/ts/typeOf.js.map +1 -0
  150. package/dist/ts/types.d.ts +31 -0
  151. package/dist/ts/types.d.ts.map +1 -0
  152. package/dist/ts/types.js +2 -0
  153. package/dist/ts/types.js.map +1 -0
  154. package/package.json +47 -62
  155. package/dist/inspect.d.ts.map +0 -1
  156. package/dist/inspect.js.map +0 -1
  157. package/dist/logic.d.ts.map +0 -1
  158. package/dist/logic.js.map +0 -1
  159. package/dist/math.d.ts +0 -35
  160. package/dist/math.d.ts.map +0 -1
  161. package/dist/math.js +0 -53
  162. package/dist/math.js.map +0 -1
  163. package/dist/object.d.ts +0 -142
  164. package/dist/object.d.ts.map +0 -1
  165. package/dist/object.js +0 -315
  166. package/dist/object.js.map +0 -1
  167. package/dist/react.d.ts.map +0 -1
  168. package/dist/react.js.map +0 -1
  169. package/dist/ts.d.ts +0 -29
  170. package/dist/ts.d.ts.map +0 -1
  171. package/dist/ts.js +0 -6
  172. package/dist/ts.js.map +0 -1
  173. /package/dist/{inspect.js → obj/inspect.js} +0 -0
package/dist/object.d.ts DELETED
@@ -1,142 +0,0 @@
1
- import { UnknownRecord } from "./ts.js";
2
- export declare const isDuplicate: (key: unknown) => boolean;
3
- /**
4
- * Simple object check.
5
- * @param item
6
- * @returns {boolean}
7
- */
8
- export declare const isObject: (item: unknown) => item is UnknownRecord;
9
- /**
10
- * Deep merge objects into target. Without modifying target.
11
- * @param target
12
- * @param source
13
- */
14
- export declare const deepMerge: <T extends S, S extends UnknownRecord = Partial<T>>(target: T, source: S) => T & S;
15
- export declare type Types = {
16
- [key: string]: string | string[] | Types | Types[];
17
- };
18
- export declare type TypeCompareResult = boolean | {
19
- expectedType: string;
20
- received: string;
21
- location: string;
22
- };
23
- /**
24
- * Take in a target `object` and a `types` object with identical keys but values as array of types those keys should be.
25
- * @param target Object
26
- * @param types Object identical to `target` but values are types
27
- * @returns `object` if the types dont match. `True` if they do.
28
- */
29
- export declare const deepTypeCompare: (target: UnknownRecord, types: Types, location?: string) => TypeCompareResult;
30
- /**
31
- * Helper function for `deepTypeCompare` to compare a item to a type or set of types.
32
- * @param expectedTypes Expected type/types
33
- * @param receivedValue Object given
34
- * @param location Location of `got` given
35
- */
36
- export declare const compareTwo: (expectedTypes: string | string[], receivedValue: unknown, location: string) => TypeCompareResult;
37
- /**
38
- * Returns the type of `item` respecting `Array`, `null` and `undefined` unlike typeof.
39
- * @param item
40
- * @returns Type of item
41
- */
42
- export declare const type: (item: unknown) => string;
43
- /**
44
- * Breaks `array` into smaller chunks based on `chunkSize`
45
- * @param array Array to break up.
46
- * @param chunkSize Maximum size of array chunks.
47
- *
48
- * @returns Array containing array chunks.
49
- */
50
- export declare const chunkArray: <T extends string | unknown[]>(array: T, chunkSize: number) => T[];
51
- /**
52
- * stringifies and then parses a object to convert it to a JSON supported object.
53
- * @param obj Object to convert.
54
- * @example
55
- * const obj = {
56
- * a: 1,
57
- * b: [2, 7]
58
- * }
59
- * const a = objectify(obj)
60
- * const b = JSON.parse(JSON.stringify(obj))
61
- * console.log(a == b) -> true
62
- */
63
- export declare const objectify: (obj: UnknownRecord) => UnknownRecord;
64
- declare type AsyncFunction = (...args: unknown[]) => Promise<unknown>;
65
- declare type ErrorHandler = (err: Error) => Promise<void>;
66
- /**
67
- * Recursively runs `func` and handles errors with `errorHandler` until `func` successfully finishes.
68
- * @param func Function to execute
69
- * @param errorHandler Function to execute when a error occours
70
- * @returns Return value of `func` on success
71
- */
72
- export declare const loopError: <F extends AsyncFunction>(func: F, errorHandler?: ErrorHandler) => ReturnType<F>;
73
- /**
74
- * @param array
75
- * @returns string containing ranges of numbers.
76
- * @example
77
- * const range = toRange([1, 2, 3, 12, 6,7, 5, 27, 28, 29, 40, 41, 25, 42, 12])
78
- * // range = "1-3 & 5-7 & 12 & 25 & 27-29 & 40-42"
79
- */
80
- export declare const toRange: (array: number[]) => string;
81
- /**
82
- * Returns the `property` requested from `obj`
83
- * @param obj
84
- * @param property
85
- * @param delimiter
86
- * @example
87
- * const object = {
88
- * a: {
89
- * child: "Hello World"
90
- * }
91
- * }
92
- * const wantedProperty = "a.child"
93
- * console.log(deepGet(object, wantedProperty)) // -> "Hello World"
94
- */
95
- export declare const deepGet: <T = unknown>(obj: UnknownRecord, property: string, delimiter?: string) => T | undefined;
96
- /**
97
- * Replaces values in a given `templatestring` with contentKeys from a given `contentKeys` object.
98
- * @param contentKeys Object containing key value pairs of contentKeys to fill template string with
99
- * @param templatestring string containing templates to fill
100
- * @example
101
- * const contentKeys = {
102
- * "title": "This is a title",
103
- * "info": {
104
- * "desc": "This is some info!"
105
- * }
106
- * }
107
- * const template = "Wow! {title}... Here is some info: {info.desc}"
108
- *
109
- * fillTemplate(contentKeys, template) // => Wow! This is a title... Here is some info: This is some info!"
110
- */
111
- export declare const fillTemplate: (contentKeys: UnknownRecord, templatestring: string, parent?: string) => string;
112
- declare type EnvDict = {
113
- [key: string]: string | EnvDict;
114
- };
115
- /**
116
- * Converts process.env variables into a object
117
- * @example process.env["some_subproperty"] = "hello"
118
- * returns { some: { subProperty: "hello" } }
119
- */
120
- export declare const getEnv: () => EnvDict;
121
- declare type RecursiveUpdateOptions = {
122
- setUndefined?: boolean;
123
- setDefined?: boolean;
124
- };
125
- /**
126
- * Recursively update properties of a object with another.
127
- * @param targetObject Object to update.
128
- * @param newObject Object with new values to write to `targetObject`.
129
- * @param options.setUndefined Defaults to `true` Set properties that are undefined on `targetObject`.
130
- * @param options.setDefined Defaults to `false`. Overwrite properties that are not undefined on `targetObject`.
131
- */
132
- export declare const recursiveUpdate: (targetObject: UnknownRecord, newObject: UnknownRecord, options?: RecursiveUpdateOptions) => void;
133
- /**
134
- * Set the types of a given `object` based on the types of an identical `types` object. Usful in conjunction with `getEnv` to convert a object only containing strings/objects to actual types.
135
- */
136
- export declare const rebuildTypes: (object: UnknownRecord, types: UnknownRecord) => void;
137
- /**
138
- * Fetch process.env[envName] or throw if its undefined
139
- */
140
- export declare const envOrThrow: (envName: string) => string;
141
- export {};
142
- //# sourceMappingURL=object.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"object.d.ts","sourceRoot":"","sources":["../src/object.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAMxC,eAAO,MAAM,WAAW,QAAS,OAAO,KAAG,OAI1C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,QAAQ,SAAU,OAAO,0BAAkG,CAAC;AAEzI;;;;GAIG;AACH,eAAO,MAAM,SAAS,oFAWr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AAEF,aAAK,OAAO,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAA;CAAE,CAAC;AAEnD;;;;GAIG;AACH,eAAO,MAAM,MAAM,QAAO,OA+BzB,CAAC;AAEF,aAAK,sBAAsB,GAAG;IAAE,YAAY,CAAC,EAAE,OAAO,CAAC;IAAC,UAAU,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAE/E;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,iBACb,aAAa,aAChB,aAAa,YACf,sBAAsB,KAC7B,IAQF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,WAAY,aAAa,SAAS,aAAa,KAAG,IAkB1E,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,UAAU,YAAa,MAAM,KAAG,MAI5C,CAAC"}
package/dist/object.js DELETED
@@ -1,315 +0,0 @@
1
- /**
2
- * Checks if `key` has been seen before.
3
- */
4
- const hash = new Map();
5
- export const isDuplicate = (key) => {
6
- if (!hash.has(key))
7
- hash.set(key, true);
8
- else
9
- return true;
10
- return false;
11
- };
12
- /**
13
- * Simple object check.
14
- * @param item
15
- * @returns {boolean}
16
- */
17
- export const isObject = (item) => item !== undefined && typeof item === "object" && !Array.isArray(item);
18
- /**
19
- * Deep merge objects into target. Without modifying target.
20
- * @param target
21
- * @param source
22
- */
23
- export const deepMerge = (target, source) => {
24
- const output = Object.assign({}, target);
25
- if (isObject(target) && isObject(source)) {
26
- Object.keys(source).forEach((key) => {
27
- if (isObject(source[key])) {
28
- if (!(key in target))
29
- Object.assign(output, { [key]: source[key] });
30
- else
31
- output[key] = deepMerge(target[key], source[key]);
32
- }
33
- else
34
- Object.assign(output, { [key]: source[key] });
35
- });
36
- }
37
- return output;
38
- };
39
- /**
40
- * Take in a target `object` and a `types` object with identical keys but values as array of types those keys should be.
41
- * @param target Object
42
- * @param types Object identical to `target` but values are types
43
- * @returns `object` if the types dont match. `True` if they do.
44
- */
45
- export const deepTypeCompare = (target, types, location = "target") => {
46
- if (!(isObject(target) && isObject(types)))
47
- return { location, expectedType: "object", received: `${target}:${type(target)}` };
48
- for (const key in target) {
49
- const targetValue = target[key];
50
- if (isObject(targetValue)) {
51
- // If target.property is a object then check its child properties
52
- const same = deepTypeCompare(targetValue, types[key], `${location}.${key}`);
53
- if (same !== true)
54
- return same;
55
- }
56
- else {
57
- if (Array.isArray(targetValue) && Array.isArray(types[key])) {
58
- // target.property and types.property are arrays
59
- // Check each item in target.property against types.property[0]
60
- const childCheckType = types[key];
61
- for (const targetItem of targetValue) {
62
- const targetType = type(targetItem);
63
- // If the array entry is a object then check it
64
- if (targetType === "object")
65
- return deepTypeCompare(targetItem, childCheckType, `${location}.${key}`);
66
- else
67
- return compareTwo(childCheckType, targetItem, `${location}.${key}`);
68
- }
69
- }
70
- else {
71
- const same = compareTwo(types[key], target[key], `${location}.${key}`);
72
- if (same !== true)
73
- return same;
74
- }
75
- }
76
- }
77
- return true;
78
- };
79
- /**
80
- * Helper function for `deepTypeCompare` to compare a item to a type or set of types.
81
- * @param expectedTypes Expected type/types
82
- * @param receivedValue Object given
83
- * @param location Location of `got` given
84
- */
85
- export const compareTwo = (expectedTypes, receivedValue, location) => {
86
- if (!Array.isArray(expectedTypes))
87
- expectedTypes = [expectedTypes];
88
- const gotType = type(receivedValue);
89
- for (const expectedType of expectedTypes) {
90
- if (gotType !== expectedType)
91
- return { location, expectedType, received: `${receivedValue}:${gotType}` };
92
- }
93
- return true;
94
- };
95
- /**
96
- * Returns the type of `item` respecting `Array`, `null` and `undefined` unlike typeof.
97
- * @param item
98
- * @returns Type of item
99
- */
100
- export const type = (item) => {
101
- if (Array.isArray(item))
102
- return "array";
103
- if (item === null)
104
- return "null";
105
- if (item === undefined)
106
- return "undefined";
107
- return typeof item;
108
- };
109
- /**
110
- * Breaks `array` into smaller chunks based on `chunkSize`
111
- * @param array Array to break up.
112
- * @param chunkSize Maximum size of array chunks.
113
- *
114
- * @returns Array containing array chunks.
115
- */
116
- export const chunkArray = (array, chunkSize) => {
117
- if (array.length < chunkSize)
118
- return [array];
119
- let i, j;
120
- const returnArray = [];
121
- for (i = 0, j = array.length; i < j; i += chunkSize)
122
- returnArray.push(array.slice(i, i + chunkSize));
123
- return returnArray;
124
- };
125
- /**
126
- * stringifies and then parses a object to convert it to a JSON supported object.
127
- * @param obj Object to convert.
128
- * @example
129
- * const obj = {
130
- * a: 1,
131
- * b: [2, 7]
132
- * }
133
- * const a = objectify(obj)
134
- * const b = JSON.parse(JSON.stringify(obj))
135
- * console.log(a == b) -> true
136
- */
137
- export const objectify = (obj) => JSON.parse(JSON.stringify(obj));
138
- /**
139
- * Recursively runs `func` and handles errors with `errorHandler` until `func` successfully finishes.
140
- * @param func Function to execute
141
- * @param errorHandler Function to execute when a error occours
142
- * @returns Return value of `func` on success
143
- */
144
- export const loopError = (func, errorHandler = (err) => new Promise((_res, r) => r(err))) => new Promise((resolve) => {
145
- func()
146
- .then(resolve)
147
- .catch(async (err) => {
148
- errorHandler(err).then(() => resolve(loopError(func, errorHandler)));
149
- });
150
- });
151
- /**
152
- * @param array
153
- * @returns string containing ranges of numbers.
154
- * @example
155
- * const range = toRange([1, 2, 3, 12, 6,7, 5, 27, 28, 29, 40, 41, 25, 42, 12])
156
- * // range = "1-3 & 5-7 & 12 & 25 & 27-29 & 40-42"
157
- */
158
- export const toRange = (array) => {
159
- array = array
160
- .filter((a, pos) => array.indexOf(a) === pos)
161
- .sort((a, b) => a - b)
162
- .map((a) => +a);
163
- let sum = `${array[0]}`;
164
- let lastValue = array[0];
165
- for (let i = 1; i <= array.length; i++) {
166
- if (!(array[i] - 1 === array[i - 1])) {
167
- if (array[i - 1] !== lastValue)
168
- sum += `-${array[i - 1]}`;
169
- if (array[i] !== undefined)
170
- sum += ` & ${array[i]}`;
171
- lastValue = array[i];
172
- }
173
- }
174
- return sum;
175
- };
176
- /**
177
- * Returns the `property` requested from `obj`
178
- * @param obj
179
- * @param property
180
- * @param delimiter
181
- * @example
182
- * const object = {
183
- * a: {
184
- * child: "Hello World"
185
- * }
186
- * }
187
- * const wantedProperty = "a.child"
188
- * console.log(deepGet(object, wantedProperty)) // -> "Hello World"
189
- */
190
- export const deepGet = (obj, property, delimiter = ".") => {
191
- const arr = property.split(delimiter);
192
- while (arr.length && (obj = obj[arr.shift()]))
193
- ;
194
- return obj;
195
- };
196
- /**
197
- * Replaces values in a given `templatestring` with contentKeys from a given `contentKeys` object.
198
- * @param contentKeys Object containing key value pairs of contentKeys to fill template string with
199
- * @param templatestring string containing templates to fill
200
- * @example
201
- * const contentKeys = {
202
- * "title": "This is a title",
203
- * "info": {
204
- * "desc": "This is some info!"
205
- * }
206
- * }
207
- * const template = "Wow! {title}... Here is some info: {info.desc}"
208
- *
209
- * fillTemplate(contentKeys, template) // => Wow! This is a title... Here is some info: This is some info!"
210
- */
211
- export const fillTemplate = (contentKeys, templatestring, parent = "") => {
212
- for (const key in contentKeys) {
213
- const value = contentKeys[key];
214
- if (isObject(value))
215
- templatestring = fillTemplate(value, templatestring, `${parent}${key}.`);
216
- else
217
- templatestring = templatestring.replaceAll(new RegExp(`{${parent}${key}}`, "g"), String(value));
218
- }
219
- return templatestring;
220
- };
221
- /**
222
- * Converts process.env variables into a object
223
- * @example process.env["some_subproperty"] = "hello"
224
- * returns { some: { subProperty: "hello" } }
225
- */
226
- export const getEnv = () => {
227
- // Define our return object env variables are applied to.
228
- const envObject = {};
229
- // Iterate over env keys
230
- for (const envKey in process.env) {
231
- // Set our reference object to be equal to the envObject to begin with.
232
- let objRef = envObject;
233
- // Reference to parent object to allow reassigning values that should be objects.
234
- let pObjRef = undefined;
235
- // Break apart the envKey into its keys. Ex some_subProperty = ["some", "subProperty"]
236
- // This regex handles cases where _ is in the key, it only matches the first _ per key allowing for keys with one or more _ in them
237
- const keys = envKey.split(/(?<=[^__])_/g);
238
- // For every key except the last...
239
- for (let i = 0; i < keys.length - 1; i++) {
240
- // Set the key on the objRef to a empty object if its undefined.
241
- if (!isObject(objRef)) {
242
- // If objRef is not a object. Use the parent object to set it to a object containing itself as _.
243
- if (pObjRef !== undefined)
244
- objRef = pObjRef[0][pObjRef[1]] = { _: objRef };
245
- pObjRef = [objRef, keys[i]];
246
- }
247
- else {
248
- pObjRef = [objRef, keys[i]];
249
- objRef = (objRef[keys[i]] ??= {});
250
- }
251
- }
252
- // Set the last key to equal the original value
253
- // If objRef is not a object. Use the parent object to set it to a object containing itself as _.
254
- if (!isObject(objRef) && pObjRef !== undefined)
255
- objRef = pObjRef[0][pObjRef[1]] = { _: objRef };
256
- const envValue = process.env[envKey];
257
- if (envValue !== undefined)
258
- objRef[keys[keys.length - 1]] = envValue;
259
- }
260
- return envObject;
261
- };
262
- /**
263
- * Recursively update properties of a object with another.
264
- * @param targetObject Object to update.
265
- * @param newObject Object with new values to write to `targetObject`.
266
- * @param options.setUndefined Defaults to `true` Set properties that are undefined on `targetObject`.
267
- * @param options.setDefined Defaults to `false`. Overwrite properties that are not undefined on `targetObject`.
268
- */
269
- export const recursiveUpdate = (targetObject, newObject, options = { setUndefined: true, setDefined: false }) => {
270
- if (!isObject(targetObject))
271
- throw new Error("targetObject is not an object!");
272
- if (!isObject(newObject))
273
- throw new Error("newObject is not an object!");
274
- for (const key in newObject) {
275
- if (isObject(targetObject[key]) && isObject(newObject[key]))
276
- recursiveUpdate(targetObject[key], newObject[key], options);
277
- else if (options.setUndefined && targetObject[key] === undefined)
278
- targetObject[key] = newObject[key];
279
- else if (options.setDefined && targetObject[key] !== undefined)
280
- targetObject[key] = newObject[key];
281
- }
282
- };
283
- /**
284
- * Set the types of a given `object` based on the types of an identical `types` object. Usful in conjunction with `getEnv` to convert a object only containing strings/objects to actual types.
285
- */
286
- export const rebuildTypes = (object, types) => {
287
- for (const key in object) {
288
- if (types[key] === undefined)
289
- continue;
290
- switch (typeof types[key]) {
291
- case "number":
292
- object[key] = +object[key];
293
- break;
294
- case "string":
295
- object[key] = String(object[key]);
296
- break;
297
- case "boolean":
298
- object[key] = object[key] === true || object[key] === "true";
299
- break;
300
- default:
301
- rebuildTypes(object[key], types[key]);
302
- break;
303
- }
304
- }
305
- };
306
- /**
307
- * Fetch process.env[envName] or throw if its undefined
308
- */
309
- export const envOrThrow = (envName) => {
310
- const envValue = process.env[envName];
311
- if (envValue === undefined)
312
- throw new Error(`Enviroment variable "${envName}" is undefined!`);
313
- return envValue;
314
- };
315
- //# sourceMappingURL=object.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"object.js","sourceRoot":"","sources":["../src/object.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,IAAI,GAAG,IAAI,GAAG,EAAE,CAAC;AACvB,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,GAAY,EAAW,EAAE;IACpD,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;QAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;;QACnC,OAAO,IAAI,CAAC;IACjB,OAAO,KAAK,CAAC;AACd,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,IAAa,EAAyB,EAAE,CAAC,IAAI,KAAK,SAAS,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAEzI;;;;GAIG;AACH,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;QACzC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;YACnC,IAAI,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE;gBAC1B,IAAI,CAAC,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,CAAC,GAAG,CAAE,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;gBAC5C,MAAM;YACP,KAAK,SAAS;gBACH,MAAM,CAAC,GAAG,CAAE,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,IAAI,IAAI,MAAM,CAAC,GAAG,CAAC,KAAK,MAAM,CAAC;gBACxE,MAAM;YACP;gBACC,YAAY,CAAgB,MAAM,CAAC,GAAG,CAAC,EAAiB,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;gBACpE,MAAM;SACP;KACD;AACF,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,OAAe,EAAU,EAAE;IACrD,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACtC,IAAI,QAAQ,KAAK,SAAS;QAAE,MAAM,IAAI,KAAK,CAAC,wBAAwB,OAAO,iBAAiB,CAAC,CAAC;IAC9F,OAAO,QAAQ,CAAC;AACjB,CAAC,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../src/react.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ,SAAgB,IAAI,KAAG,QAAQ,MAAM,GAAG,WAAW,CAUvE,CAAC"}
package/dist/react.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"react.js","sourceRoot":"","sources":["../src/react.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,EAAE,IAAU,EAAiC,EAAE;IAC3E,MAAM,WAAW,GAAG,MAAM,IAAI,OAAO,CAA8B,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACtF,MAAM,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;QAChC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAC3B,MAAM,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC7C,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC;IACzB,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC;IACvB,IAAI,WAAW,YAAY,KAAK;QAAE,MAAM,IAAI,KAAK,CAAC,0BAA0B,IAAI,CAAC,IAAI,gBAAgB,WAAW,CAAC,OAAO,EAAE,CAAC,CAAC;IAC5H,IAAI,WAAW,KAAK,SAAS,IAAI,WAAW,KAAK,IAAI;QAAE,MAAM,IAAI,KAAK,CAAC,0BAA0B,IAAI,CAAC,IAAI,aAAa,CAAC,CAAC;IACzH,OAAO,WAAW,CAAC;AACpB,CAAC,CAAC"}
package/dist/ts.d.ts DELETED
@@ -1,29 +0,0 @@
1
- export type { RangeOf, NumRangeInclusive } from "./ts/numRange.js";
2
- export type { AddOne, MinusOne, TimesTen } from "./ts/math.js";
3
- export declare type ValueOf<T> = T[keyof T];
4
- export declare type ValueOfA<T extends unknown[] | readonly unknown[]> = T[number];
5
- export declare type UnionToIntersection<T> = (T extends any ? (x: T) => any : never) extends (x: infer R) => any ? R : never;
6
- export declare type RecursivePartial<T> = {
7
- [P in keyof T]?: T[P] extends (infer U)[] ? RecursivePartial<U>[] : T[P] extends object ? RecursivePartial<T[P]> : T[P];
8
- };
9
- export declare type ToStrUnion<T extends string | number | bigint | boolean | null | undefined> = `${T}`;
10
- export declare type FirstChar<T> = T extends `${infer C}${string}` ? C : never;
11
- export declare type LastChar<T> = T extends `${string}${infer C}` ? C : never;
12
- /**
13
- * Takes in a string padded with 0's and returns the unpadded string;
14
- */
15
- export declare type UnPad<N extends string> = N extends "0" ? "0" : N extends `0${infer A}` ? UnPad<A> : N;
16
- /**
17
- * Returns a type guard to validate a passed key is a keyof given record
18
- */
19
- export declare const generateIsKeyof: <T extends Record<string | number | symbol, unknown>>(record: T) => (key: any) => key is keyof T;
20
- export declare const isDefined: <T>(O: T | undefined) => O is T;
21
- export declare type RequiredKeys<T> = keyof T extends infer K extends PropertyKey ? (K extends K ? (T extends Record<K, unknown> ? K : never) : never) : never;
22
- export declare type OptionalKeys<T> = Exclude<keyof T, RequiredKeys<T>>;
23
- export declare type RequiredOnly<T> = Pick<T, RequiredKeys<T> & keyof T>;
24
- export declare type OptionalOnly<T> = Pick<T, OptionalKeys<T> & keyof T>;
25
- export declare type UnknownRecord = Record<string | number | symbol, unknown>;
26
- export declare type Constructor = abstract new (...args: any) => any;
27
- export declare type Primitives = StringConstructor | NumberConstructor | BooleanConstructor;
28
- export declare type Primitive<T> = T extends string ? string : T extends StringConstructor ? string : T extends number ? number : T extends NumberConstructor ? number : T extends boolean ? boolean : T extends BooleanConstructor ? boolean : T;
29
- //# sourceMappingURL=ts.d.ts.map
package/dist/ts.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"ts.d.ts","sourceRoot":"","sources":["../src/ts.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACnE,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAE/D,oBAAY,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AACpC,oBAAY,QAAQ,CAAC,CAAC,SAAS,OAAO,EAAE,GAAG,SAAS,OAAO,EAAE,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC;AAE3E,oBAAY,mBAAmB,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,GAAG,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK,GAAG,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,EAAE,MAAM,CAAC,KAAK,GAAG,GAAG,CAAC,GAAG,KAAK,CAAC;AAErH,oBAAY,gBAAgB,CAAC,CAAC,IAAI;KAChC,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SA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IAAI,IAAI,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;AACjE,oBAAY,YAAY,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;AAEjE,oBAAY,aAAa,GAAG,MAAM,CAAC,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,OAAO,CAAC,CAAC;AAEtE,oBAAY,WAAW,GAAG,QAAQ,MAAM,GAAG,IAAI,EAAE,GAAG,KAAK,GAAG,CAAC;AAC7D,oBAAY,UAAU,GAAG,iBAAiB,GAAG,iBAAiB,GAAG,kBAAkB,CAAC;AACpF,oBAAY,SAAS,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,GACxC,MAAM,GACN,CAAC,SAAS,iBAAiB,GAC3B,MAAM,GACN,CAAC,SAAS,MAAM,GAChB,MAAM,GACN,CAAC,SAAS,iBAAiB,GAC3B,MAAM,GACN,CAAC,SAAS,OAAO,GACjB,OAAO,GACP,CAAC,SAAS,kBAAkB,GAC5B,OAAO,GACP,CAAC,CAAC"}
package/dist/ts.js DELETED
@@ -1,6 +0,0 @@
1
- /**
2
- * Returns a type guard to validate a passed key is a keyof given record
3
- */
4
- export const generateIsKeyof = (record) => (key) => key in record;
5
- export const isDefined = (O) => O !== undefined;
6
- //# sourceMappingURL=ts.js.map
package/dist/ts.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"ts.js","sourceRoot":"","sources":["../src/ts.ts"],"names":[],"mappings":"AAsBA;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAC3B,CAAsD,MAAS,EAAE,EAAE,CACnE,CAAC,GAAQ,EAAkB,EAAE,CAC5B,GAAG,IAAI,MAAM,CAAC;AAEhB,MAAM,CAAC,MAAM,SAAS,GAAG,CAAI,CAAgB,EAAU,EAAE,CAAC,CAAC,KAAK,SAAS,CAAC"}
File without changes