@sparted/shared-library 0.0.11 → 0.0.13
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/_virtual/_tslib.js +88 -0
- package/_virtual/_tslib.js.map +1 -0
- package/array/array-to-map.d.ts +14 -0
- package/array/array-to-map.js +19 -0
- package/array/array-to-map.js.map +1 -0
- package/array/get-values-from-keys.d.ts +1 -0
- package/array/get-values-from-keys.js +6 -0
- package/array/get-values-from-keys.js.map +1 -0
- package/array/index.d.ts +2 -0
- package/array/index.js +3 -0
- package/array/index.js.map +1 -0
- package/date/constants.d.ts +4 -0
- package/date/constants.js +7 -0
- package/date/constants.js.map +1 -0
- package/date/convert.d.ts +2 -0
- package/date/convert.js +7 -0
- package/date/convert.js.map +1 -0
- package/date/format-minutes.d.ts +1 -0
- package/date/format-minutes.js +12 -0
- package/date/format-minutes.js.map +1 -0
- package/date/get-time-diff-as-string.d.ts +47 -0
- package/date/get-time-diff-as-string.js +126 -0
- package/date/get-time-diff-as-string.js.map +1 -0
- package/date/index.d.ts +4 -0
- package/date/index.js +4 -0
- package/date/index.js.map +1 -0
- package/formatting/format-number.d.ts +1 -0
- package/formatting/format-number.js +14 -0
- package/formatting/format-number.js.map +1 -0
- package/formatting/index.d.ts +1 -0
- package/formatting/index.js +2 -0
- package/formatting/index.js.map +1 -0
- package/fp/index.d.ts +1 -0
- package/fp/index.js +2 -0
- package/fp/index.js.map +1 -0
- package/fp/run-while.d.ts +31 -0
- package/fp/run-while.js +26 -0
- package/fp/run-while.js.map +1 -0
- package/http/encode-search-object.d.ts +7 -0
- package/http/encode-search-object.js +31 -0
- package/http/encode-search-object.js.map +1 -0
- package/http/fetch-with-timeout.d.ts +8 -0
- package/http/fetch-with-timeout.js +18 -0
- package/http/fetch-with-timeout.js.map +1 -0
- package/http/index.d.ts +2 -0
- package/http/index.js +3 -0
- package/http/index.js.map +1 -0
- package/index.d.ts +13 -0
- package/index.js +13 -0
- package/index.js.map +1 -0
- package/linked-list/apply-diff-linked-list.d.ts +2 -0
- package/linked-list/apply-diff-linked-list.js +27 -0
- package/linked-list/apply-diff-linked-list.js.map +1 -0
- package/linked-list/create-linked-list.d.ts +2 -0
- package/linked-list/create-linked-list.js +66 -0
- package/linked-list/create-linked-list.js.map +1 -0
- package/linked-list/find-linked-list.d.ts +2 -0
- package/linked-list/find-linked-list.js +25 -0
- package/linked-list/find-linked-list.js.map +1 -0
- package/linked-list/get-linked-list.d.ts +2 -0
- package/linked-list/get-linked-list.js +9 -0
- package/linked-list/get-linked-list.js.map +1 -0
- package/linked-list/index.d.ts +2 -0
- package/linked-list/index.js +2 -0
- package/linked-list/index.js.map +1 -0
- package/linked-list/insert-linked-list.d.ts +2 -0
- package/linked-list/insert-linked-list.js +30 -0
- package/linked-list/insert-linked-list.js.map +1 -0
- package/linked-list/linked-list-utils.d.ts +23 -0
- package/linked-list/linked-list-utils.js +97 -0
- package/linked-list/linked-list-utils.js.map +1 -0
- package/linked-list/reduce-linked-list.d.ts +2 -0
- package/linked-list/reduce-linked-list.js +17 -0
- package/linked-list/reduce-linked-list.js.map +1 -0
- package/linked-list/remove-linked-list.d.ts +2 -0
- package/linked-list/remove-linked-list.js +25 -0
- package/linked-list/remove-linked-list.js.map +1 -0
- package/linked-list/type.d.ts +34 -0
- package/linked-list/update-linked-list.d.ts +2 -0
- package/linked-list/update-linked-list.js +21 -0
- package/linked-list/update-linked-list.js.map +1 -0
- package/linked-list/walk-list-item-record.d.ts +15 -0
- package/linked-list/while-linked-list.d.ts +2 -0
- package/linked-list/while-linked-list.js +29 -0
- package/linked-list/while-linked-list.js.map +1 -0
- package/math/clamp-number.d.ts +2 -0
- package/math/clamp-number.js +10 -0
- package/math/clamp-number.js.map +1 -0
- package/math/index.d.ts +4 -0
- package/math/index.js +5 -0
- package/math/index.js.map +1 -0
- package/math/interpolate.d.ts +2 -0
- package/math/interpolate.js +16 -0
- package/math/interpolate.js.map +1 -0
- package/math/number-range.d.ts +6 -0
- package/math/number-range.js +13 -0
- package/math/number-range.js.map +1 -0
- package/math/random-number.d.ts +2 -0
- package/math/random-number.js +10 -0
- package/math/random-number.js.map +1 -0
- package/object/index.d.ts +1 -0
- package/object/index.js +2 -0
- package/object/index.js.map +1 -0
- package/object/merge-deep.d.ts +2 -0
- package/object/merge-deep.js +24 -0
- package/object/merge-deep.js.map +1 -0
- package/package.json +4 -2
- package/parsing/index.d.ts +3 -0
- package/parsing/index.js +4 -0
- package/parsing/index.js.map +1 -0
- package/parsing/parse-boolean.d.ts +4 -0
- package/parsing/parse-boolean.js +12 -0
- package/parsing/parse-boolean.js.map +1 -0
- package/parsing/parse-enum.d.ts +5 -0
- package/parsing/parse-enum.js +13 -0
- package/parsing/parse-enum.js.map +1 -0
- package/parsing/parse-number.d.ts +4 -0
- package/parsing/parse-number.js +13 -0
- package/parsing/parse-number.js.map +1 -0
- package/predicates/index.d.ts +5 -0
- package/predicates/index.js +6 -0
- package/predicates/index.js.map +1 -0
- package/predicates/is-function.d.ts +1 -0
- package/predicates/is-function.js +6 -0
- package/predicates/is-function.js.map +1 -0
- package/predicates/is-null.d.ts +1 -0
- package/predicates/is-null.js +6 -0
- package/predicates/is-null.js.map +1 -0
- package/predicates/is-object.d.ts +1 -0
- package/predicates/is-object.js +6 -0
- package/predicates/is-object.js.map +1 -0
- package/predicates/is-primitive.d.ts +3 -0
- package/predicates/is-primitive.js +17 -0
- package/predicates/is-primitive.js.map +1 -0
- package/predicates/is-undefined.d.ts +1 -0
- package/predicates/is-undefined.js +6 -0
- package/predicates/is-undefined.js.map +1 -0
- package/predicates/is-uuid.d.ts +1 -0
- package/promise/delay.d.ts +1 -0
- package/promise/delay.js +6 -0
- package/promise/delay.js.map +1 -0
- package/promise/execute-or-resolve-default.d.ts +5 -0
- package/promise/execute-or-resolve-default.js +10 -0
- package/promise/execute-or-resolve-default.js.map +1 -0
- package/promise/execute-with-delay.d.ts +1 -0
- package/promise/execute-with-delay.js +16 -0
- package/promise/execute-with-delay.js.map +1 -0
- package/promise/index.d.ts +3 -0
- package/promise/index.js +4 -0
- package/promise/index.js.map +1 -0
- package/string/index.d.ts +1 -0
- package/string/index.js +2 -0
- package/string/index.js.map +1 -0
- package/string/replace-in-template.d.ts +14 -0
- package/string/replace-in-template.js +35 -0
- package/string/replace-in-template.js.map +1 -0
- package/types/function.d.ts +1 -0
- package/types/general.d.ts +3 -0
- package/types/index.d.ts +4 -0
- package/types/index.js +2 -0
- package/types/index.js.map +1 -0
- package/types/object.d.ts +35 -0
- package/types/search.d.ts +24 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clamp-number.js","sources":["../../src/math/clamp-number.ts"],"sourcesContent":["import { assertNumberRange } from './number-range';\nimport type { NumberRange } from './number-range';\n\nexport const clampNumber = (num: number, { min, max }: NumberRange) => {\n assertNumberRange({ min, max });\n\n return Math.min(Math.max(num, min), max);\n};"],"names":[],"mappings":";;AAGa,IAAA,WAAW,GAAG,UAAC,GAAW,EAAE,EAAyB,EAAA;QAAvB,GAAG,GAAA,EAAA,CAAA,GAAA,EAAE,GAAG,GAAA,EAAA,CAAA,GAAA,CAAA;IACjD,iBAAiB,CAAC,EAAE,GAAG,EAAA,GAAA,EAAE,GAAG,EAAA,GAAA,EAAE,CAAC,CAAC;AAEhC,IAAA,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;AAC3C;;;;"}
|
package/math/index.d.ts
ADDED
package/math/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { isNumberInRange } from './number-range.js';
|
|
2
|
+
|
|
3
|
+
var interpolate = function (num, inputRange, outputRange) {
|
|
4
|
+
var x1 = inputRange[0], x2 = inputRange[1];
|
|
5
|
+
var y1 = outputRange[0], y2 = outputRange[1];
|
|
6
|
+
if (x1 > x2) {
|
|
7
|
+
throw new Error('interpolate: inputRange[0] should not be superior to inputRange[1]');
|
|
8
|
+
}
|
|
9
|
+
if (!isNumberInRange(num, { min: x1, max: x2 })) {
|
|
10
|
+
throw new Error("interpolate: input number {".concat(num, "} is not in range of {").concat(x1, "}-{").concat(x2, "}"));
|
|
11
|
+
}
|
|
12
|
+
return y1 + ((num - x1) / (x2 - x1)) * (y2 - y1);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export { interpolate };
|
|
16
|
+
//# sourceMappingURL=interpolate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interpolate.js","sources":["../../src/math/interpolate.ts"],"sourcesContent":["import { isNumberInRange } from './number-range';\n\nexport type RangeArray = [number, number];\n\nexport const interpolate = (num: number, inputRange: RangeArray, outputRange: RangeArray) => {\n const [x1, x2] = inputRange;\n const [y1, y2] = outputRange;\n\n if (x1 > x2) {\n throw new Error('interpolate: inputRange[0] should not be superior to inputRange[1]');\n }\n\n if (!isNumberInRange(num, { min: x1, max: x2 })) {\n throw new Error(`interpolate: input number {${num}} is not in range of {${x1}}-{${x2}}`);\n }\n\n return y1 + ((num - x1) / (x2 - x1)) * (y2 - y1);\n};"],"names":[],"mappings":";;IAIa,WAAW,GAAG,UAAC,GAAW,EAAE,UAAsB,EAAE,WAAuB,EAAA;IAC/E,IAAA,EAAE,GAAQ,UAAU,CAAA,CAAA,CAAlB,EAAE,EAAE,GAAI,UAAU,CAAA,CAAA,CAAd,CAAe;IACrB,IAAA,EAAE,GAAQ,WAAW,CAAA,CAAA,CAAnB,EAAE,EAAE,GAAI,WAAW,CAAA,CAAA,CAAf,CAAgB;IAE7B,IAAI,EAAE,GAAG,EAAE,EAAE;AACX,QAAA,MAAM,IAAI,KAAK,CAAC,oEAAoE,CAAC,CAAC;AACvF,KAAA;AAED,IAAA,IAAI,CAAC,eAAe,CAAC,GAAG,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,EAAE;QAC/C,MAAM,IAAI,KAAK,CAAC,6BAA8B,CAAA,MAAA,CAAA,GAAG,EAAyB,wBAAA,CAAA,CAAA,MAAA,CAAA,EAAE,EAAM,KAAA,CAAA,CAAA,MAAA,CAAA,EAAE,EAAG,GAAA,CAAA,CAAC,CAAC;AAC1F,KAAA;IAED,OAAO,EAAE,GAAG,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;AACnD;;;;"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
var assertNumberRange = function (range) {
|
|
2
|
+
if (range.min > range.max) {
|
|
3
|
+
throw new Error('Invalid number range: min must be lower than or equal to max');
|
|
4
|
+
}
|
|
5
|
+
};
|
|
6
|
+
var isNumberInRange = function (num, _a) {
|
|
7
|
+
var min = _a.min, max = _a.max;
|
|
8
|
+
assertNumberRange({ min: min, max: max });
|
|
9
|
+
return num >= min && num <= max;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export { assertNumberRange, isNumberInRange };
|
|
13
|
+
//# sourceMappingURL=number-range.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"number-range.js","sources":["../../src/math/number-range.ts"],"sourcesContent":["export type NumberRange = {\n min: number,\n max: number,\n};\n\nexport const assertNumberRange = (range: NumberRange) => {\n if (range.min > range.max) {\n throw new Error('Invalid number range: min must be lower than or equal to max');\n }\n};\n\nexport const isNumberInRange = (num: number, { min, max }: NumberRange) => {\n assertNumberRange({ min, max });\n\n return num >= min && num <= max;\n};\n"],"names":[],"mappings":"AAKO,IAAM,iBAAiB,GAAG,UAAC,KAAkB,EAAA;AAClD,IAAA,IAAI,KAAK,CAAC,GAAG,GAAG,KAAK,CAAC,GAAG,EAAE;AACzB,QAAA,MAAM,IAAI,KAAK,CAAC,8DAA8D,CAAC,CAAC;AACjF,KAAA;AACH,EAAE;AAEW,IAAA,eAAe,GAAG,UAAC,GAAW,EAAE,EAAyB,EAAA;QAAvB,GAAG,GAAA,EAAA,CAAA,GAAA,EAAE,GAAG,GAAA,EAAA,CAAA,GAAA,CAAA;IACrD,iBAAiB,CAAC,EAAE,GAAG,EAAA,GAAA,EAAE,GAAG,EAAA,GAAA,EAAE,CAAC,CAAC;AAEhC,IAAA,OAAO,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,CAAC;AAClC;;;;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { assertNumberRange } from './number-range.js';
|
|
2
|
+
|
|
3
|
+
var randomNumber = function (_a) {
|
|
4
|
+
var min = _a.min, max = _a.max;
|
|
5
|
+
assertNumberRange({ min: min, max: max });
|
|
6
|
+
return Math.floor(Math.random() * (max - min) + min);
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export { randomNumber };
|
|
10
|
+
//# sourceMappingURL=random-number.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"random-number.js","sources":["../../src/math/random-number.ts"],"sourcesContent":["import { assertNumberRange } from './number-range';\nimport type { NumberRange } from './number-range';\n\nexport const randomNumber = ({ min, max }: NumberRange) => {\n assertNumberRange({ min, max });\n\n return Math.floor(\n Math.random() * (max - min) + min,\n );\n};\n"],"names":[],"mappings":";;AAGO,IAAM,YAAY,GAAG,UAAC,EAAyB,EAAA;QAAvB,GAAG,GAAA,EAAA,CAAA,GAAA,EAAE,GAAG,GAAA,EAAA,CAAA,GAAA,CAAA;IACrC,iBAAiB,CAAC,EAAE,GAAG,EAAA,GAAA,EAAE,GAAG,EAAA,GAAA,EAAE,CAAC,CAAC;AAEhC,IAAA,OAAO,IAAI,CAAC,KAAK,CACf,IAAI,CAAC,MAAM,EAAE,IAAI,GAAG,GAAG,GAAG,CAAC,GAAG,GAAG,CAClC,CAAC;AACJ;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './merge-deep';
|
package/object/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { __assign } from '../_virtual/_tslib.js';
|
|
2
|
+
|
|
3
|
+
// https://stackoverflow.com/questions/8511281/check-if-a-value-is-an-object-in-javascript/8511350#8511350
|
|
4
|
+
var isObject = function (a) { return typeof a === 'object' && a !== null; };
|
|
5
|
+
var isValueType = function (a) { return (!isObject(a) || Array.isArray(a)); };
|
|
6
|
+
var mergeDeep = function (a, b) {
|
|
7
|
+
if (isValueType(a) || isValueType(b)) {
|
|
8
|
+
return b;
|
|
9
|
+
}
|
|
10
|
+
return Object.keys(b).reduce(function (acc, key) {
|
|
11
|
+
var _a;
|
|
12
|
+
if (!(key in a)) {
|
|
13
|
+
return acc;
|
|
14
|
+
}
|
|
15
|
+
if (b[key] === a[key]) {
|
|
16
|
+
return acc;
|
|
17
|
+
}
|
|
18
|
+
var merged = mergeDeep(a[key], b[key]);
|
|
19
|
+
return __assign(__assign({}, acc), (_a = {}, _a[key] = merged, _a));
|
|
20
|
+
}, a);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export { mergeDeep };
|
|
24
|
+
//# sourceMappingURL=merge-deep.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merge-deep.js","sources":["../../src/object/merge-deep.ts"],"sourcesContent":["import type { DeepPartial, ValueType } from '../types';\n\n// https://stackoverflow.com/questions/8511281/check-if-a-value-is-an-object-in-javascript/8511350#8511350\nconst isObject = (a: any) => typeof a === 'object' && a !== null;\nconst isValueType = (a: any): a is ValueType => (\n !isObject(a) || Array.isArray(a)\n);\n\nexport const mergeDeep = <T>(a: T, b: DeepPartial<T>): T => {\n if (isValueType(a) || isValueType(b)) {\n return b as T;\n }\n\n return (Object.keys(b) as (keyof T)[]).reduce((acc, key) => {\n if (!(key in a)) {\n return acc;\n }\n\n if (b[key] === a[key]) {\n return acc;\n }\n\n const merged = mergeDeep(a[key], (b[key] as DeepPartial<T[keyof T]>));\n\n return { ...acc, [key]: merged };\n }, a);\n};\n"],"names":[],"mappings":";;AAEA;AACA,IAAM,QAAQ,GAAG,UAAC,CAAM,EAAA,EAAK,OAAA,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,CAAA,EAAA,CAAC;AACjE,IAAM,WAAW,GAAG,UAAC,CAAM,IAAqB,QAC9C,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EADc,EAE/C,CAAC;AAEW,IAAA,SAAS,GAAG,UAAI,CAAI,EAAE,CAAiB,EAAA;IAClD,IAAI,WAAW,CAAC,CAAC,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,EAAE;AACpC,QAAA,OAAO,CAAM,CAAC;AACf,KAAA;AAED,IAAA,OAAQ,MAAM,CAAC,IAAI,CAAC,CAAC,CAAiB,CAAC,MAAM,CAAC,UAAC,GAAG,EAAE,GAAG,EAAA;;AACrD,QAAA,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC,EAAE;AACf,YAAA,OAAO,GAAG,CAAC;AACZ,SAAA;QAED,IAAI,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,EAAE;AACrB,YAAA,OAAO,GAAG,CAAC;AACZ,SAAA;AAED,QAAA,IAAM,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,EAAG,CAAC,CAAC,GAAG,CAA6B,CAAC,CAAC;AAEtE,QAAA,OAAA,QAAA,CAAA,QAAA,CAAA,EAAA,EAAY,GAAG,CAAA,GAAA,EAAA,GAAA,EAAA,EAAA,EAAA,CAAG,GAAG,CAAA,GAAG,MAAM,EAAG,EAAA,EAAA,CAAA;KAClC,EAAE,CAAC,CAAC,CAAC;AACR;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sparted/shared-library",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13",
|
|
4
4
|
"repository": "git@github.com:Sparted/shared-library.git",
|
|
5
5
|
"author": "Thomas <duprethomasfr@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
"main": "index.js",
|
|
9
9
|
"module": "index.js",
|
|
10
10
|
"files": [
|
|
11
|
-
"
|
|
11
|
+
"**/*",
|
|
12
|
+
"**/**"
|
|
12
13
|
],
|
|
13
14
|
"scripts": {
|
|
14
15
|
"test": "jest",
|
|
@@ -23,6 +24,7 @@
|
|
|
23
24
|
"jest": "^29.0.3",
|
|
24
25
|
"jest-environment-jsdom": "^29.0.3",
|
|
25
26
|
"jest-extended": "^3.1.0",
|
|
27
|
+
"jest-fetch-mock": "^3.0.3",
|
|
26
28
|
"rollup": "^2.79.1",
|
|
27
29
|
"rollup-plugin-typescript2": "^0.34.0",
|
|
28
30
|
"ts-jest": "^29.0.2",
|
package/parsing/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse a string to a boolean. Throw error if string is neither "true" nor "false"
|
|
3
|
+
*/
|
|
4
|
+
var parseBoolean = function (value) {
|
|
5
|
+
if (value !== 'true' && value !== 'false') {
|
|
6
|
+
throw new Error('Cannot parse value');
|
|
7
|
+
}
|
|
8
|
+
return value === 'true';
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export { parseBoolean };
|
|
12
|
+
//# sourceMappingURL=parse-boolean.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-boolean.js","sources":["../../src/parsing/parse-boolean.ts"],"sourcesContent":["/**\n * Parse a string to a boolean. Throw error if string is neither \"true\" nor \"false\"\n */\n export const parseBoolean = (value: string): boolean => {\n if (value !== 'true' && value !== 'false') {\n throw new Error('Cannot parse value');\n }\n\n return value === 'true';\n};\n"],"names":[],"mappings":"AAAA;;AAEG;AACK,IAAM,YAAY,GAAG,UAAC,KAAa,EAAA;AACzC,IAAA,IAAI,KAAK,KAAK,MAAM,IAAI,KAAK,KAAK,OAAO,EAAE;AACzC,QAAA,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;AACvC,KAAA;IAED,OAAO,KAAK,KAAK,MAAM,CAAC;AAC1B;;;;"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Factory to build enum to parse a string to an enum. Throw error if string is not an enum value
|
|
3
|
+
*/
|
|
4
|
+
var createEnumParser = function (enumType) { return (function (value) {
|
|
5
|
+
var enumValues = Object.values(enumType);
|
|
6
|
+
if (!enumValues.includes(value)) {
|
|
7
|
+
throw new Error('Can\'t parse this value');
|
|
8
|
+
}
|
|
9
|
+
return value;
|
|
10
|
+
}); };
|
|
11
|
+
|
|
12
|
+
export { createEnumParser };
|
|
13
|
+
//# sourceMappingURL=parse-enum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-enum.js","sources":["../../src/parsing/parse-enum.ts"],"sourcesContent":["import type { Primitive } from '../types';\n\n/**\n * Factory to build enum to parse a string to an enum. Throw error if string is not an enum value\n */\n export const createEnumParser = <E extends Record<string, Primitive>>(enumType: E) => (\n (value: string) => {\n const enumValues = Object.values(enumType);\n\n if (!enumValues.includes(value as any)) {\n throw new Error('Can\\'t parse this value');\n }\n\n return value as unknown as E;\n }\n);"],"names":[],"mappings":"AAEA;;AAEG;AACW,IAAA,gBAAgB,GAAG,UAAsC,QAAW,EAAK,EAAA,QACrF,UAAC,KAAa,EAAA;IACZ,IAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AAE3C,IAAA,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,KAAY,CAAC,EAAE;AACtC,QAAA,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;AAC5C,KAAA;AAED,IAAA,OAAO,KAAqB,CAAC;AAC/B,CAAC,EAToF;;;;"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse a string to a number. Throw error if string is NaN
|
|
3
|
+
*/
|
|
4
|
+
var parseNumber = function (value) {
|
|
5
|
+
var number = parseInt(value, 10);
|
|
6
|
+
if (Number.isNaN(number)) {
|
|
7
|
+
throw new Error('Cannot parse value');
|
|
8
|
+
}
|
|
9
|
+
return number;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export { parseNumber };
|
|
13
|
+
//# sourceMappingURL=parse-number.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-number.js","sources":["../../src/parsing/parse-number.ts"],"sourcesContent":["/**\n * Parse a string to a number. Throw error if string is NaN\n */\n export const parseNumber = (value: string): number => {\n const number = parseInt(value, 10);\n\n if (Number.isNaN(number)) {\n throw new Error('Cannot parse value');\n }\n\n return number;\n};"],"names":[],"mappings":"AAAA;;AAEG;AACK,IAAM,WAAW,GAAG,UAAC,KAAa,EAAA;IACxC,IAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AAEnC,IAAA,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE;AACxB,QAAA,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;AACvC,KAAA;AAED,IAAA,OAAO,MAAM,CAAC;AAChB;;;;"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { isFunction } from './is-function.js';
|
|
2
|
+
export { isNull } from './is-null.js';
|
|
3
|
+
export { isObject } from './is-object.js';
|
|
4
|
+
export { isArrayOfPrimitive, isPrimitive } from './is-primitive.js';
|
|
5
|
+
export { isUndefined } from './is-undefined.js';
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isFunction: (value: any) => value is Function;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-function.js","sources":["../../src/predicates/is-function.ts"],"sourcesContent":["export const isFunction = (value: any): value is Function => {\n return typeof value === 'function';\n};\n"],"names":[],"mappings":"AAAO,IAAM,UAAU,GAAG,UAAC,KAAU,EAAA;AACnC,IAAA,OAAO,OAAO,KAAK,KAAK,UAAU,CAAC;AACrC;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isNull: (value: any) => value is null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-null.js","sources":["../../src/predicates/is-null.ts"],"sourcesContent":["export const isNull = (value: any): value is null => {\n return value === null;\n};\n"],"names":[],"mappings":"AAAO,IAAM,MAAM,GAAG,UAAC,KAAU,EAAA;IAC/B,OAAO,KAAK,KAAK,IAAI,CAAC;AACxB;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isObject: (value: any) => value is Object;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-object.js","sources":["../../src/predicates/is-object.ts"],"sourcesContent":["export const isObject = (value: any): value is Object => {\n return typeof value === 'object';\n};\n"],"names":[],"mappings":"AAAO,IAAM,QAAQ,GAAG,UAAC,KAAU,EAAA;AACjC,IAAA,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;AACnC;;;;"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
var PRIMITIVE_TYPES = [
|
|
2
|
+
'string',
|
|
3
|
+
'boolean',
|
|
4
|
+
'number',
|
|
5
|
+
];
|
|
6
|
+
var isPrimitive = function (value) {
|
|
7
|
+
return PRIMITIVE_TYPES.includes(typeof value);
|
|
8
|
+
};
|
|
9
|
+
var isArrayOfPrimitive = function (value) {
|
|
10
|
+
if (!Array.isArray(value)) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
return value.every(function (arrayValue) { return isPrimitive(arrayValue); });
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export { isArrayOfPrimitive, isPrimitive };
|
|
17
|
+
//# sourceMappingURL=is-primitive.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-primitive.js","sources":["../../src/predicates/is-primitive.ts"],"sourcesContent":["import { Primitive } from '../types/general';\n\nconst PRIMITIVE_TYPES = [\n 'string',\n 'boolean',\n 'number',\n];\n\nexport const isPrimitive = (value: any): value is Primitive => {\n return PRIMITIVE_TYPES.includes(typeof value);\n};\n\nexport const isArrayOfPrimitive = (value: any): value is Array<Primitive> => {\n if (!Array.isArray(value)) {\n return false;\n }\n\n return value.every((arrayValue) => isPrimitive(arrayValue));\n};\n"],"names":[],"mappings":"AAEA,IAAM,eAAe,GAAG;IACtB,QAAQ;IACR,SAAS;IACT,QAAQ;CACT,CAAC;AAEK,IAAM,WAAW,GAAG,UAAC,KAAU,EAAA;AACpC,IAAA,OAAO,eAAe,CAAC,QAAQ,CAAC,OAAO,KAAK,CAAC,CAAC;AAChD,EAAE;AAEK,IAAM,kBAAkB,GAAG,UAAC,KAAU,EAAA;AAC3C,IAAA,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;AACzB,QAAA,OAAO,KAAK,CAAC;AACd,KAAA;AAED,IAAA,OAAO,KAAK,CAAC,KAAK,CAAC,UAAC,UAAU,EAAA,EAAK,OAAA,WAAW,CAAC,UAAU,CAAC,CAAvB,EAAuB,CAAC,CAAC;AAC9D;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isUndefined: (value: any) => value is undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-undefined.js","sources":["../../src/predicates/is-undefined.ts"],"sourcesContent":["export const isUndefined = (value: any): value is undefined => {\n return value === undefined;\n};\n"],"names":[],"mappings":"AAAO,IAAM,WAAW,GAAG,UAAC,KAAU,EAAA;IACpC,OAAO,KAAK,KAAK,SAAS,CAAC;AAC7B;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isUuidV4: (arg: any) => arg is string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const delay: (time: number) => Promise<unknown>;
|
package/promise/delay.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delay.js","sources":["../../src/promise/delay.ts"],"sourcesContent":["export const delay = (time: number) => new Promise((resolve) => {\n setTimeout(resolve, time);\n});\n"],"names":[],"mappings":"AAAO,IAAM,KAAK,GAAG,UAAC,IAAY,EAAK,EAAA,OAAA,IAAI,OAAO,CAAC,UAAC,OAAO,EAAA;AACzD,IAAA,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;AAC5B,CAAC,CAAC,CAFqC;;;;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
var executeOrResolveDefault = function (callback, config) {
|
|
2
|
+
var execute = config.execute, defaultValue = config.defaultValue;
|
|
3
|
+
if (execute) {
|
|
4
|
+
return callback();
|
|
5
|
+
}
|
|
6
|
+
return Promise.resolve(defaultValue);
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export { executeOrResolveDefault };
|
|
10
|
+
//# sourceMappingURL=execute-or-resolve-default.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute-or-resolve-default.js","sources":["../../src/promise/execute-or-resolve-default.ts"],"sourcesContent":["export type ExecutionConfig<Default> = {\n execute: boolean,\n defaultValue: Default,\n};\n\nexport const executeOrResolveDefault = <T, Default>(callback: () => Promise<T>, config: ExecutionConfig<Default>): Promise<T | Default> => {\n const { execute, defaultValue } = config;\n\n if (execute) {\n return callback();\n }\n\n return Promise.resolve(defaultValue);\n};\n"],"names":[],"mappings":"AAKa,IAAA,uBAAuB,GAAG,UAAa,QAA0B,EAAE,MAAgC,EAAA;IACtG,IAAA,OAAO,GAAmB,MAAM,CAAA,OAAzB,EAAE,YAAY,GAAK,MAAM,CAAA,YAAX,CAAY;AAEzC,IAAA,IAAI,OAAO,EAAE;QACX,OAAO,QAAQ,EAAE,CAAC;AACnB,KAAA;AAED,IAAA,OAAO,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;AACvC;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const executeWithDelay: <T>(callback: () => T, time: number) => Promise<T>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { __awaiter, __generator } from '../_virtual/_tslib.js';
|
|
2
|
+
import { delay } from './delay.js';
|
|
3
|
+
|
|
4
|
+
var executeWithDelay = function (callback, time) { return __awaiter(void 0, void 0, void 0, function () {
|
|
5
|
+
return __generator(this, function (_a) {
|
|
6
|
+
switch (_a.label) {
|
|
7
|
+
case 0: return [4 /*yield*/, delay(time)];
|
|
8
|
+
case 1:
|
|
9
|
+
_a.sent();
|
|
10
|
+
return [2 /*return*/, callback()];
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
}); };
|
|
14
|
+
|
|
15
|
+
export { executeWithDelay };
|
|
16
|
+
//# sourceMappingURL=execute-with-delay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute-with-delay.js","sources":["../../src/promise/execute-with-delay.ts"],"sourcesContent":["import { delay } from './delay';\n\nexport const executeWithDelay = async <T>(callback: () => T, time: number): Promise<T> => {\n await delay(time);\n return callback();\n};\n"],"names":[],"mappings":";;;AAEa,IAAA,gBAAgB,GAAG,UAAU,QAAiB,EAAE,IAAY,EAAA,EAAA,OAAA,SAAA,CAAA,KAAA,CAAA,EAAA,KAAA,CAAA,EAAA,KAAA,CAAA,EAAA,YAAA;;;AACvE,YAAA,KAAA,CAAA,EAAA,OAAA,CAAA,CAAA,YAAM,KAAK,CAAC,IAAI,CAAC,CAAA,CAAA;;AAAjB,gBAAA,EAAA,CAAA,IAAA,EAAiB,CAAC;gBAClB,OAAO,CAAA,CAAA,aAAA,QAAQ,EAAE,CAAC,CAAA;;;;;;;"}
|
package/promise/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './replace-in-template';
|
package/string/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare type ReplaceConfig = {
|
|
2
|
+
delimiter: string | {
|
|
3
|
+
left: string;
|
|
4
|
+
right: string;
|
|
5
|
+
};
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Replace string inside a template. For now, only works with
|
|
9
|
+
* an object containing promirives or array of primitives. If
|
|
10
|
+
* it contains other objects, they will be ignored.
|
|
11
|
+
*
|
|
12
|
+
* Uses the mustache syntax by default.
|
|
13
|
+
*/
|
|
14
|
+
export declare const replaceInTemplate: (template: string, params: Record<string, any>, config?: ReplaceConfig) => string;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { isPrimitive, isArrayOfPrimitive } from '../predicates/is-primitive.js';
|
|
2
|
+
|
|
3
|
+
var defaultConfig = {
|
|
4
|
+
delimiter: {
|
|
5
|
+
left: '{{',
|
|
6
|
+
right: '}}',
|
|
7
|
+
},
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Replace string inside a template. For now, only works with
|
|
11
|
+
* an object containing promirives or array of primitives. If
|
|
12
|
+
* it contains other objects, they will be ignored.
|
|
13
|
+
*
|
|
14
|
+
* Uses the mustache syntax by default.
|
|
15
|
+
*/
|
|
16
|
+
var replaceInTemplate = function (template, params, config) {
|
|
17
|
+
if (config === void 0) { config = defaultConfig; }
|
|
18
|
+
var delimiter = config.delimiter;
|
|
19
|
+
var leftDelimiter = typeof delimiter === 'string' ? delimiter : delimiter.left;
|
|
20
|
+
var rightDelimiter = typeof delimiter === 'string' ? delimiter : delimiter.right;
|
|
21
|
+
return Object
|
|
22
|
+
.entries(params)
|
|
23
|
+
.reduce(function (acc, _a) {
|
|
24
|
+
var key = _a[0], value = _a[1];
|
|
25
|
+
if (!isPrimitive(value) && !isArrayOfPrimitive(value)) {
|
|
26
|
+
return acc;
|
|
27
|
+
}
|
|
28
|
+
var searchValue = "".concat(leftDelimiter).concat(key).concat(rightDelimiter);
|
|
29
|
+
var replaceBy = Array.isArray(value) ? value.join(', ') : String(value);
|
|
30
|
+
return acc.replace(searchValue, replaceBy);
|
|
31
|
+
}, template);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export { replaceInTemplate };
|
|
35
|
+
//# sourceMappingURL=replace-in-template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replace-in-template.js","sources":["../../src/string/replace-in-template.ts"],"sourcesContent":["import { isArrayOfPrimitive, isPrimitive } from '../predicates';\n\nexport type ReplaceConfig = {\n delimiter: string | {\n left: string,\n right: string,\n },\n};\n\nconst defaultConfig: ReplaceConfig = {\n delimiter: {\n left: '{{',\n right: '}}',\n },\n};\n\n/**\n * Replace string inside a template. For now, only works with\n * an object containing promirives or array of primitives. If\n * it contains other objects, they will be ignored.\n *\n * Uses the mustache syntax by default.\n */\nexport const replaceInTemplate = (\n template: string,\n params: Record<string, any>,\n config: ReplaceConfig = defaultConfig,\n) => {\n const { delimiter } = config;\n const leftDelimiter = typeof delimiter === 'string' ? delimiter : delimiter.left;\n const rightDelimiter = typeof delimiter === 'string' ? delimiter : delimiter.right;\n\n return Object\n .entries(params)\n .reduce((acc, [key, value]) => {\n if (!isPrimitive(value) && !isArrayOfPrimitive(value)) {\n return acc;\n }\n\n const searchValue = `${leftDelimiter}${key}${rightDelimiter}`;\n const replaceBy = Array.isArray(value) ? value.join(', ') : String(value);\n\n return acc.replace(searchValue, replaceBy);\n }, template);\n};\n"],"names":[],"mappings":";;AASA,IAAM,aAAa,GAAkB;AACnC,IAAA,SAAS,EAAE;AACT,QAAA,IAAI,EAAE,IAAI;AACV,QAAA,KAAK,EAAE,IAAI;AACZ,KAAA;CACF,CAAC;AAEF;;;;;;AAMG;IACU,iBAAiB,GAAG,UAC/B,QAAgB,EAChB,MAA2B,EAC3B,MAAqC,EAAA;AAArC,IAAA,IAAA,MAAA,KAAA,KAAA,CAAA,EAAA,EAAA,MAAqC,GAAA,aAAA,CAAA,EAAA;AAE7B,IAAA,IAAA,SAAS,GAAK,MAAM,CAAA,SAAX,CAAY;AAC7B,IAAA,IAAM,aAAa,GAAG,OAAO,SAAS,KAAK,QAAQ,GAAG,SAAS,GAAG,SAAS,CAAC,IAAI,CAAC;AACjF,IAAA,IAAM,cAAc,GAAG,OAAO,SAAS,KAAK,QAAQ,GAAG,SAAS,GAAG,SAAS,CAAC,KAAK,CAAC;AAEnF,IAAA,OAAO,MAAM;SACV,OAAO,CAAC,MAAM,CAAC;AACf,SAAA,MAAM,CAAC,UAAC,GAAG,EAAE,EAAY,EAAA;YAAX,GAAG,GAAA,EAAA,CAAA,CAAA,CAAA,EAAE,KAAK,GAAA,EAAA,CAAA,CAAA,CAAA,CAAA;QACvB,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,EAAE;AACrD,YAAA,OAAO,GAAG,CAAC;AACZ,SAAA;QAED,IAAM,WAAW,GAAG,EAAG,CAAA,MAAA,CAAA,aAAa,SAAG,GAAG,CAAA,CAAA,MAAA,CAAG,cAAc,CAAE,CAAC;QAC9D,IAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;QAE1E,OAAO,GAAG,CAAC,OAAO,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;KAC5C,EAAE,QAAQ,CAAC,CAAC;AACjB;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare type GenericFunction<TS extends any[], R> = (...args: TS) => R;
|
package/types/index.d.ts
ADDED
package/types/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ValueType } from './general';
|
|
2
|
+
export declare type NonMethodKeys<T> = {
|
|
3
|
+
[P in keyof T]: T[P] extends Function ? never : P;
|
|
4
|
+
}[keyof T];
|
|
5
|
+
export declare type Attributes<T> = {
|
|
6
|
+
[K in NonMethodKeys<T>]: T[K];
|
|
7
|
+
};
|
|
8
|
+
export declare type PartialAttributes<T> = {
|
|
9
|
+
[K in NonMethodKeys<T>]?: T[K];
|
|
10
|
+
};
|
|
11
|
+
export declare type MethodKeys<T> = {
|
|
12
|
+
[P in keyof T]: T[P] extends Function ? P : never;
|
|
13
|
+
}[keyof T];
|
|
14
|
+
export declare type Methods<T> = {
|
|
15
|
+
[K in MethodKeys<T>]: T[K];
|
|
16
|
+
};
|
|
17
|
+
export declare type PartialMethods<T> = {
|
|
18
|
+
[K in MethodKeys<T>]?: T[K];
|
|
19
|
+
};
|
|
20
|
+
export declare type ClassType<T> = {
|
|
21
|
+
new (...args: any[]): T;
|
|
22
|
+
};
|
|
23
|
+
export declare type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
24
|
+
export declare type DeepPartial<T> = T extends ValueType ? T : {
|
|
25
|
+
[P in keyof T]?: DeepPartial<T[P]>;
|
|
26
|
+
};
|
|
27
|
+
export declare type Intersection<A, B> = {
|
|
28
|
+
[P in keyof A & keyof B]: A[P] | B[P];
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Helper type. Passes T out again, but boxes it in a way that it cannot
|
|
32
|
+
* "widen" the type by accident if it is a generic that should be inferred
|
|
33
|
+
* from elsewhere.
|
|
34
|
+
*/
|
|
35
|
+
export declare type NoInfer<T> = [T][T extends any ? 0 : never];
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare type SearchSortBy = string;
|
|
2
|
+
export declare type SearchSortOrder = 'asc' | 'desc';
|
|
3
|
+
export declare type SearchSort = {
|
|
4
|
+
[by: SearchSortBy]: SearchSortOrder;
|
|
5
|
+
};
|
|
6
|
+
export declare type SearchQueryProperty = string;
|
|
7
|
+
export declare type SearchQueryValue = string;
|
|
8
|
+
export declare type SearchQuery = {
|
|
9
|
+
[property: SearchQueryProperty]: SearchQueryValue;
|
|
10
|
+
};
|
|
11
|
+
export declare type SearchObject = {
|
|
12
|
+
offset: number;
|
|
13
|
+
limit: number;
|
|
14
|
+
sort?: Record<string, SearchSortOrder>;
|
|
15
|
+
query?: SearchQuery;
|
|
16
|
+
};
|
|
17
|
+
export declare type SearchResponse<T> = {
|
|
18
|
+
items: ReadonlyArray<T>;
|
|
19
|
+
offset: number;
|
|
20
|
+
limit: number;
|
|
21
|
+
total: number;
|
|
22
|
+
next: string | null;
|
|
23
|
+
previous: string | null;
|
|
24
|
+
};
|