@sparted/shared-library 1.0.24 → 1.0.26
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 +6 -1
- package/_virtual/_tslib.js.map +1 -1
- package/array/array-to-map.d.ts +1 -1
- package/array/index.d.ts +1 -0
- package/array/index.js +2 -0
- package/array/index.js.map +1 -1
- package/array/inner-join.d.ts +1 -0
- package/array/inner-join.js +11 -0
- package/array/inner-join.js.map +1 -0
- package/array/left-outter-join.js +2 -3
- package/array/left-outter-join.js.map +1 -1
- package/cdn/types/cdn-factory.type.d.ts +14 -14
- package/cdn/utils/extract-info-from-url.util.d.ts +1 -1
- package/cdn/utils/get-cdn-from-s3-url.util.d.ts +1 -1
- package/cdn/utils/get-cdn-url.util.d.ts +1 -1
- package/fp/run-while.d.ts +2 -2
- package/http/encode-search-object.d.ts +1 -1
- package/http/fetch-with-timeout.d.ts +1 -1
- package/index.js +2 -0
- package/index.js.map +1 -1
- package/linked-list/linked-list-utils.d.ts +4 -4
- package/linked-list/type.d.ts +7 -7
- package/math/interpolate.d.ts +1 -1
- package/math/number-range.d.ts +1 -1
- package/package.json +1 -1
- package/promise/execute-or-resolve-default.d.ts +1 -1
- package/string/replace-in-template.d.ts +1 -1
- package/time/get-time-diff-as-string.d.ts +2 -2
- package/types/function.d.ts +1 -1
- package/types/general.d.ts +4 -4
- package/types/object.d.ts +11 -11
- package/types/search.d.ts +8 -8
package/_virtual/_tslib.js
CHANGED
|
@@ -37,7 +37,12 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
37
37
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
38
38
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
39
39
|
});
|
|
40
|
-
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
43
|
+
var e = new Error(message);
|
|
44
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
45
|
+
};
|
|
41
46
|
|
|
42
47
|
exports.__awaiter = __awaiter;
|
|
43
48
|
exports.__rest = __rest;
|
package/_virtual/_tslib.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_tslib.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"_tslib.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/array/array-to-map.d.ts
CHANGED
package/array/index.d.ts
CHANGED
package/array/index.js
CHANGED
|
@@ -5,10 +5,12 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var arrayToMap = require('./array-to-map.js');
|
|
6
6
|
var getValuesFromKeys = require('./get-values-from-keys.js');
|
|
7
7
|
var leftOutterJoin = require('./left-outter-join.js');
|
|
8
|
+
var innerJoin = require('./inner-join.js');
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
exports.arrayToMap = arrayToMap.arrayToMap;
|
|
12
13
|
exports.valuesFromKeys = getValuesFromKeys.valuesFromKeys;
|
|
13
14
|
exports.leftOutterJoin = leftOutterJoin.leftOutterJoin;
|
|
15
|
+
exports.innerJoin = innerJoin.innerJoin;
|
|
14
16
|
//# sourceMappingURL=index.js.map
|
package/array/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const innerJoin: <T, U>(arr1: T[], arr2: U[], selectKey1: (item: T) => string | number, selectKey2: (item: U) => string | number) => T[];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const innerJoin = (arr1, arr2, selectKey1, selectKey2) => {
|
|
6
|
+
const arr2Set = new Set(arr2.map(selectKey2));
|
|
7
|
+
return arr1.filter((item) => arr2Set.has(selectKey1(item)));
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
exports.innerJoin = innerJoin;
|
|
11
|
+
//# sourceMappingURL=inner-join.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inner-join.js","sources":["../../src/array/inner-join.ts"],"sourcesContent":["export const innerJoin = <T, U>(\n arr1: T[],\n arr2: U[],\n selectKey1: (item: T) => string | number,\n selectKey2: (item: U) => string | number,\n) => {\n const arr2Set = new Set(arr2.map(selectKey2));\n\n return arr1.filter((item) => arr2Set.has(selectKey1(item)));\n};\n"],"names":[],"mappings":";;;;AAAO,MAAM,SAAS,GAAG,CACvB,IAAS,EACT,IAAS,EACT,UAAwC,EACxC,UAAwC,KACtC;AACF,IAAA,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC;AAE9C,IAAA,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,KAAK,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAC9D;;;;"}
|
|
@@ -3,9 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const leftOutterJoin = (arr1, arr2, selectKey1, selectKey2) => {
|
|
6
|
-
const arr2Set = arr2.
|
|
7
|
-
|
|
8
|
-
return leftOutterJoinedArr;
|
|
6
|
+
const arr2Set = new Set(arr2.map(selectKey2));
|
|
7
|
+
return arr1.filter((item) => !arr2Set.has(selectKey1(item)));
|
|
9
8
|
};
|
|
10
9
|
|
|
11
10
|
exports.leftOutterJoin = leftOutterJoin;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"left-outter-join.js","sources":["../../src/array/left-outter-join.ts"],"sourcesContent":["export const leftOutterJoin = <T, U>(\n arr1: T[],\n arr2: U[],\n selectKey1: (item: T) => string | number,\n selectKey2: (item: U) => string | number,\n) => {\n const arr2Set = arr2.
|
|
1
|
+
{"version":3,"file":"left-outter-join.js","sources":["../../src/array/left-outter-join.ts"],"sourcesContent":["export const leftOutterJoin = <T, U>(\n arr1: T[],\n arr2: U[],\n selectKey1: (item: T) => string | number,\n selectKey2: (item: U) => string | number,\n) => {\n const arr2Set = new Set(arr2.map(selectKey2));\n\n return arr1.filter((item) => !arr2Set.has(selectKey1(item)));\n};\n"],"names":[],"mappings":";;;;AAAO,MAAM,cAAc,GAAG,CAC5B,IAAS,EACT,IAAS,EACT,UAAwC,EACxC,UAAwC,KACtC;AACF,IAAA,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC;IAE9C,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAC/D;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export type BaseUrlMapperFunc = (instanceId: string) => string;
|
|
2
|
+
export type Transformation = {
|
|
3
3
|
fit?: 'crop' | 'contain';
|
|
4
4
|
width?: number;
|
|
5
5
|
height?: number;
|
|
@@ -11,26 +11,26 @@ export declare type Transformation = {
|
|
|
11
11
|
compress?: boolean;
|
|
12
12
|
output?: 'jpeg' | 'png' | 'webp' | 'image';
|
|
13
13
|
};
|
|
14
|
-
export
|
|
14
|
+
export type CdnParams = {
|
|
15
15
|
asThumbnail?: boolean;
|
|
16
16
|
transformation?: Transformation;
|
|
17
17
|
};
|
|
18
|
-
export
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
export
|
|
22
|
-
export
|
|
23
|
-
export
|
|
24
|
-
export
|
|
25
|
-
export
|
|
26
|
-
export
|
|
27
|
-
export
|
|
18
|
+
export type TransformationQueries = (params: Transformation) => string;
|
|
19
|
+
type TwicpicsOutputTransformation = ['output', Transformation['output']];
|
|
20
|
+
type TwicpicsFitTransformation = ['cover' | 'crop' | 'contain', string] | ['quality', number];
|
|
21
|
+
export type TwicpicsTransformation = TwicpicsOutputTransformation | TwicpicsFitTransformation;
|
|
22
|
+
export type TwicpicsTransformationChain = TwicpicsTransformation[];
|
|
23
|
+
export type GetCdnUrl = (instanceId: string, path: `/${string}`, params?: CdnParams) => string;
|
|
24
|
+
export type GetCdnFromS3Url = (url: string, params?: CdnParams) => string;
|
|
25
|
+
export type InstanceMapper = (instanceId: string) => string;
|
|
26
|
+
export type CdnType = 'twicpics' | 'imgix';
|
|
27
|
+
export type CdnConfig<T extends CdnType> = {
|
|
28
28
|
type: T;
|
|
29
29
|
domain: `https://${string}`;
|
|
30
30
|
instanceMapper: InstanceMapper;
|
|
31
31
|
cacheVersion?: T extends 'twicpics' ? number : undefined;
|
|
32
32
|
};
|
|
33
|
-
export
|
|
33
|
+
export type Cdn = {
|
|
34
34
|
getCdnUrl: GetCdnUrl;
|
|
35
35
|
getCdnFromS3Url: GetCdnFromS3Url;
|
|
36
36
|
};
|
package/fp/run-while.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type RunWhileConfig<T> = {
|
|
2
2
|
/**
|
|
3
3
|
* Return a boolean to keep running the callback or not.
|
|
4
4
|
*/
|
|
@@ -17,7 +17,7 @@ export declare type RunWhileConfig<T> = {
|
|
|
17
17
|
*/
|
|
18
18
|
initialValue: T;
|
|
19
19
|
};
|
|
20
|
-
export
|
|
20
|
+
export type RunWhileFn = <T>(config: RunWhileConfig<T>) => {
|
|
21
21
|
/**
|
|
22
22
|
* The callback last result.
|
|
23
23
|
*/
|
package/index.js
CHANGED
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var arrayToMap = require('./array/array-to-map.js');
|
|
6
6
|
var getValuesFromKeys = require('./array/get-values-from-keys.js');
|
|
7
7
|
var leftOutterJoin = require('./array/left-outter-join.js');
|
|
8
|
+
var innerJoin = require('./array/inner-join.js');
|
|
8
9
|
var cdn_factory = require('./cdn/cdn.factory.js');
|
|
9
10
|
var constants = require('./time/constants.js');
|
|
10
11
|
var convert = require('./time/convert.js');
|
|
@@ -41,6 +42,7 @@ var replaceInTemplate = require('./string/replace-in-template.js');
|
|
|
41
42
|
exports.arrayToMap = arrayToMap.arrayToMap;
|
|
42
43
|
exports.valuesFromKeys = getValuesFromKeys.valuesFromKeys;
|
|
43
44
|
exports.leftOutterJoin = leftOutterJoin.leftOutterJoin;
|
|
45
|
+
exports.innerJoin = innerJoin.innerJoin;
|
|
44
46
|
exports.createCdn = cdn_factory.createCdn;
|
|
45
47
|
exports.MS_DAY = constants.MS_DAY;
|
|
46
48
|
exports.MS_HOUR = constants.MS_HOUR;
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { LinkedListFormat, LinkedListItem, SimpleLinkedList } from './type';
|
|
2
|
-
export
|
|
2
|
+
export type WalkConfig<T extends LinkedListItem, Result> = {
|
|
3
3
|
startId: string | null;
|
|
4
4
|
items: Record<string, T>;
|
|
5
5
|
initValue: Result;
|
|
6
6
|
};
|
|
7
|
-
|
|
7
|
+
type WalkCallbackResult<R> = {
|
|
8
8
|
result: R;
|
|
9
9
|
control?: {
|
|
10
10
|
stop?: boolean;
|
|
11
11
|
};
|
|
12
12
|
};
|
|
13
|
-
export
|
|
13
|
+
export type WalkCallback<Item, Result> = (accumulator: Result, current: Item) => WalkCallbackResult<Result>;
|
|
14
14
|
export declare const walkListItemRecord: <T extends LinkedListItem, Result>(callback: WalkCallback<T, Result>, config: WalkConfig<T, Result>) => Result;
|
|
15
15
|
export declare const findPreviousId: <T extends LinkedListItem>(id: string | null, list: SimpleLinkedList<T>) => string | null;
|
|
16
16
|
export declare const assertItemCompatibility: <T extends LinkedListItem>(item: T, format: LinkedListFormat | null) => void;
|
|
17
17
|
export declare const assertPresence: (id: string | null | undefined, items: Record<string, unknown>) => void;
|
|
18
|
-
|
|
18
|
+
type PositionAssertionConfig = {
|
|
19
19
|
previousId: string | null;
|
|
20
20
|
list: SimpleLinkedList<LinkedListItem>;
|
|
21
21
|
};
|
package/linked-list/type.d.ts
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type LinkedListItem = {
|
|
2
2
|
id: string;
|
|
3
3
|
nextId: string | null;
|
|
4
4
|
previousId?: string | null;
|
|
5
5
|
};
|
|
6
|
-
export
|
|
6
|
+
export type SimpleLinkedList<T extends LinkedListItem> = {
|
|
7
7
|
headId: string | null;
|
|
8
8
|
items: {
|
|
9
9
|
[id: string]: T;
|
|
10
10
|
};
|
|
11
11
|
};
|
|
12
|
-
export
|
|
13
|
-
export
|
|
14
|
-
export
|
|
15
|
-
export
|
|
12
|
+
export type ReduceCallback<Item, Result> = (accumulator: Result, current: Item) => Result;
|
|
13
|
+
export type ItemPredicate<Item> = (item: Item) => boolean;
|
|
14
|
+
export type LinkedListFormat = 'double' | 'single';
|
|
15
|
+
export type ManipulationConfig<T extends LinkedListItem> = {
|
|
16
16
|
format: LinkedListFormat | null;
|
|
17
17
|
list: SimpleLinkedList<T>;
|
|
18
18
|
factory: (list: SimpleLinkedList<T>) => LinkedList<T>;
|
|
19
19
|
};
|
|
20
|
-
export
|
|
20
|
+
export type LinkedList<T extends LinkedListItem> = {
|
|
21
21
|
readonly head: T | null;
|
|
22
22
|
readonly items: {
|
|
23
23
|
[id: string]: T;
|
package/math/interpolate.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type RangeArray = [number, number];
|
|
2
2
|
export declare const interpolate: (num: number, inputRange: RangeArray, outputRange: RangeArray) => number;
|
package/math/number-range.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type MonthLocaleLabels = [
|
|
2
2
|
string,
|
|
3
3
|
string,
|
|
4
4
|
string,
|
|
@@ -12,7 +12,7 @@ export declare type MonthLocaleLabels = [
|
|
|
12
12
|
string,
|
|
13
13
|
string
|
|
14
14
|
];
|
|
15
|
-
export
|
|
15
|
+
export type DiffTemplate = {
|
|
16
16
|
/**
|
|
17
17
|
* e.g.: ("%time% %timelabel% blabla")
|
|
18
18
|
*/
|
package/types/function.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type GenericFunction<TS extends any[], R> = (...args: TS) => R;
|
package/types/general.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
1
|
+
export type Primitive = string | number | boolean;
|
|
2
|
+
export type Nullable<T> = T | null;
|
|
3
|
+
export type ValueType = Primitive | null | void | Array<any> | ReadonlyArray<any>;
|
|
4
|
+
export type ValueOf<T> = T[keyof T];
|
package/types/object.d.ts
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
import { ValueType } from './general';
|
|
2
|
-
export
|
|
2
|
+
export type NonMethodKeys<T> = {
|
|
3
3
|
[P in keyof T]: T[P] extends Function ? never : P;
|
|
4
4
|
}[keyof T];
|
|
5
|
-
export
|
|
5
|
+
export type Attributes<T> = {
|
|
6
6
|
[K in NonMethodKeys<T>]: T[K];
|
|
7
7
|
};
|
|
8
|
-
export
|
|
8
|
+
export type PartialAttributes<T> = {
|
|
9
9
|
[K in NonMethodKeys<T>]?: T[K];
|
|
10
10
|
};
|
|
11
|
-
export
|
|
11
|
+
export type MethodKeys<T> = {
|
|
12
12
|
[P in keyof T]: T[P] extends Function ? P : never;
|
|
13
13
|
}[keyof T];
|
|
14
|
-
export
|
|
14
|
+
export type Methods<T> = {
|
|
15
15
|
[K in MethodKeys<T>]: T[K];
|
|
16
16
|
};
|
|
17
|
-
export
|
|
17
|
+
export type PartialMethods<T> = {
|
|
18
18
|
[K in MethodKeys<T>]?: T[K];
|
|
19
19
|
};
|
|
20
|
-
export
|
|
20
|
+
export type ClassType<T, Params extends Array<any> = Array<any>> = {
|
|
21
21
|
new (...args: Params): T;
|
|
22
22
|
};
|
|
23
|
-
export
|
|
24
|
-
export
|
|
23
|
+
export type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
24
|
+
export type DeepPartial<T> = T extends ValueType ? T : {
|
|
25
25
|
[P in keyof T]?: DeepPartial<T[P]>;
|
|
26
26
|
};
|
|
27
|
-
export
|
|
27
|
+
export type Intersection<A, B> = {
|
|
28
28
|
[P in keyof A & keyof B]: A[P] | B[P];
|
|
29
29
|
};
|
|
30
30
|
/**
|
|
@@ -32,4 +32,4 @@ export declare type Intersection<A, B> = {
|
|
|
32
32
|
* "widen" the type by accident if it is a generic that should be inferred
|
|
33
33
|
* from elsewhere.
|
|
34
34
|
*/
|
|
35
|
-
export
|
|
35
|
+
export type NoInfer<T> = [T][T extends any ? 0 : never];
|
package/types/search.d.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
1
|
+
export type SearchSortBy = string;
|
|
2
|
+
export type SearchSortOrder = 'asc' | 'desc';
|
|
3
|
+
export type SearchSort = {
|
|
4
4
|
[by: SearchSortBy]: SearchSortOrder;
|
|
5
5
|
};
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
6
|
+
export type SearchQueryProperty = string;
|
|
7
|
+
export type SearchQueryValue = string;
|
|
8
|
+
export type SearchQuery = {
|
|
9
9
|
[property: SearchQueryProperty]: SearchQueryValue;
|
|
10
10
|
};
|
|
11
|
-
export
|
|
11
|
+
export type SearchObject = {
|
|
12
12
|
offset: number;
|
|
13
13
|
limit: number;
|
|
14
14
|
sort?: Record<string, SearchSortOrder>;
|
|
15
15
|
query?: SearchQuery;
|
|
16
16
|
};
|
|
17
|
-
export
|
|
17
|
+
export type SearchResponse<T> = {
|
|
18
18
|
items: ReadonlyArray<T>;
|
|
19
19
|
offset: number;
|
|
20
20
|
limit: number;
|