@sparted/shared-library 1.0.25 → 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.
@@ -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;
@@ -1 +1 @@
1
- {"version":3,"file":"_tslib.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"_tslib.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,4 +1,4 @@
1
- export declare type ArrayToMapOptions<InitialValue, ModifiedValue = InitialValue> = {
1
+ export type ArrayToMapOptions<InitialValue, ModifiedValue = InitialValue> = {
2
2
  /**
3
3
  * Function to return the key used in the map.
4
4
  */
package/array/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './array-to-map';
2
2
  export * from './get-values-from-keys';
3
3
  export * from './left-outter-join';
4
+ export * from './inner-join';
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
@@ -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,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;;;;"}
@@ -1,5 +1,5 @@
1
- export declare type BaseUrlMapperFunc = (instanceId: string) => string;
2
- export declare type Transformation = {
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 declare type CdnParams = {
14
+ export type CdnParams = {
15
15
  asThumbnail?: boolean;
16
16
  transformation?: Transformation;
17
17
  };
18
- export declare type TransformationQueries = (params: Transformation) => string;
19
- declare type TwicpicsOutputTransformation = ['output', Transformation['output']];
20
- declare type TwicpicsFitTransformation = ['cover' | 'crop' | 'contain', string] | ['quality', number];
21
- export declare type TwicpicsTransformation = TwicpicsOutputTransformation | TwicpicsFitTransformation;
22
- export declare type TwicpicsTransformationChain = TwicpicsTransformation[];
23
- export declare type GetCdnUrl = (instanceId: string, path: `/${string}`, params?: CdnParams) => string;
24
- export declare type GetCdnFromS3Url = (url: string, params?: CdnParams) => string;
25
- export declare type InstanceMapper = (instanceId: string) => string;
26
- export declare type CdnType = 'twicpics' | 'imgix';
27
- export declare type CdnConfig<T extends CdnType> = {
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 declare type Cdn = {
33
+ export type Cdn = {
34
34
  getCdnUrl: GetCdnUrl;
35
35
  getCdnFromS3Url: GetCdnFromS3Url;
36
36
  };
@@ -1,4 +1,4 @@
1
- declare type ExtractInfoFromUrl = (url: string) => {
1
+ type ExtractInfoFromUrl = (url: string) => {
2
2
  instanceId: string;
3
3
  path: `/${string}`;
4
4
  } | undefined;
@@ -1,5 +1,5 @@
1
1
  import type { GetCdnFromS3Url, GetCdnUrl } from '../types';
2
- declare type FactoryConfig = {
2
+ type FactoryConfig = {
3
3
  getCdnUrl: GetCdnUrl;
4
4
  };
5
5
  export declare function getCdnFromS3UrlFactory(config: FactoryConfig): GetCdnFromS3Url;
@@ -1,5 +1,5 @@
1
1
  import type { GetCdnUrl, InstanceMapper, TransformationQueries } from '../types';
2
- declare type FactoryConfig = {
2
+ type FactoryConfig = {
3
3
  domain: `https://${string}`;
4
4
  instanceMapper: InstanceMapper;
5
5
  transformationQueries: TransformationQueries;
package/fp/run-while.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare type RunWhileConfig<T> = {
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 declare type RunWhileFn = <T>(config: RunWhileConfig<T>) => {
20
+ export type RunWhileFn = <T>(config: RunWhileConfig<T>) => {
21
21
  /**
22
22
  * The callback last result.
23
23
  */
@@ -1,5 +1,5 @@
1
1
  import { SearchObject } from '../types';
2
- export declare type EncodingConfig = {
2
+ export type EncodingConfig = {
3
3
  keyValueDelimiter: string;
4
4
  pairDelimiter: string;
5
5
  };
@@ -1,4 +1,4 @@
1
- export declare type RequestInitWithTimeout = RequestInit & {
1
+ export type RequestInitWithTimeout = RequestInit & {
2
2
  timeout?: number;
3
3
  };
4
4
  /**
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 declare type WalkConfig<T extends LinkedListItem, Result> = {
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
- declare type WalkCallbackResult<R> = {
7
+ type WalkCallbackResult<R> = {
8
8
  result: R;
9
9
  control?: {
10
10
  stop?: boolean;
11
11
  };
12
12
  };
13
- export declare type WalkCallback<Item, Result> = (accumulator: Result, current: Item) => WalkCallbackResult<Result>;
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
- declare type PositionAssertionConfig = {
18
+ type PositionAssertionConfig = {
19
19
  previousId: string | null;
20
20
  list: SimpleLinkedList<LinkedListItem>;
21
21
  };
@@ -1,23 +1,23 @@
1
- export declare type LinkedListItem = {
1
+ export type LinkedListItem = {
2
2
  id: string;
3
3
  nextId: string | null;
4
4
  previousId?: string | null;
5
5
  };
6
- export declare type SimpleLinkedList<T extends LinkedListItem> = {
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 declare type ReduceCallback<Item, Result> = (accumulator: Result, current: Item) => Result;
13
- export declare type ItemPredicate<Item> = (item: Item) => boolean;
14
- export declare type LinkedListFormat = 'double' | 'single';
15
- export declare type ManipulationConfig<T extends LinkedListItem> = {
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 declare type LinkedList<T extends LinkedListItem> = {
20
+ export type LinkedList<T extends LinkedListItem> = {
21
21
  readonly head: T | null;
22
22
  readonly items: {
23
23
  [id: string]: T;
@@ -1,2 +1,2 @@
1
- export declare type RangeArray = [number, number];
1
+ export type RangeArray = [number, number];
2
2
  export declare const interpolate: (num: number, inputRange: RangeArray, outputRange: RangeArray) => number;
@@ -1,4 +1,4 @@
1
- export declare type NumberRange = {
1
+ export type NumberRange = {
2
2
  min: number;
3
3
  max: number;
4
4
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sparted/shared-library",
3
- "version": "1.0.25",
3
+ "version": "1.0.26",
4
4
  "repository": "git@github.com:Sparted/shared-library.git",
5
5
  "author": {
6
6
  "name": "Sparted",
@@ -1,4 +1,4 @@
1
- export declare type ExecutionConfig<Default> = {
1
+ export type ExecutionConfig<Default> = {
2
2
  execute: boolean;
3
3
  defaultValue: Default;
4
4
  };
@@ -1,4 +1,4 @@
1
- export declare type ReplaceConfig = {
1
+ export type ReplaceConfig = {
2
2
  delimiter: string | {
3
3
  left: string;
4
4
  right: string;
@@ -1,4 +1,4 @@
1
- export declare type MonthLocaleLabels = [
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 declare type DiffTemplate = {
15
+ export type DiffTemplate = {
16
16
  /**
17
17
  * e.g.: ("%time% %timelabel% blabla")
18
18
  */
@@ -1 +1 @@
1
- export declare type GenericFunction<TS extends any[], R> = (...args: TS) => R;
1
+ export type GenericFunction<TS extends any[], R> = (...args: TS) => R;
@@ -1,4 +1,4 @@
1
- export declare type Primitive = string | number | boolean;
2
- export declare type Nullable<T> = T | null;
3
- export declare type ValueType = Primitive | null | void | Array<any> | ReadonlyArray<any>;
4
- export declare type ValueOf<T> = T[keyof T];
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 declare type NonMethodKeys<T> = {
2
+ export type NonMethodKeys<T> = {
3
3
  [P in keyof T]: T[P] extends Function ? never : P;
4
4
  }[keyof T];
5
- export declare type Attributes<T> = {
5
+ export type Attributes<T> = {
6
6
  [K in NonMethodKeys<T>]: T[K];
7
7
  };
8
- export declare type PartialAttributes<T> = {
8
+ export type PartialAttributes<T> = {
9
9
  [K in NonMethodKeys<T>]?: T[K];
10
10
  };
11
- export declare type MethodKeys<T> = {
11
+ export type MethodKeys<T> = {
12
12
  [P in keyof T]: T[P] extends Function ? P : never;
13
13
  }[keyof T];
14
- export declare type Methods<T> = {
14
+ export type Methods<T> = {
15
15
  [K in MethodKeys<T>]: T[K];
16
16
  };
17
- export declare type PartialMethods<T> = {
17
+ export type PartialMethods<T> = {
18
18
  [K in MethodKeys<T>]?: T[K];
19
19
  };
20
- export declare type ClassType<T, Params extends Array<any> = Array<any>> = {
20
+ export type ClassType<T, Params extends Array<any> = Array<any>> = {
21
21
  new (...args: Params): T;
22
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 : {
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 declare type Intersection<A, B> = {
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 declare type NoInfer<T> = [T][T extends any ? 0 : never];
35
+ export type NoInfer<T> = [T][T extends any ? 0 : never];
package/types/search.d.ts CHANGED
@@ -1,20 +1,20 @@
1
- export declare type SearchSortBy = string;
2
- export declare type SearchSortOrder = 'asc' | 'desc';
3
- export declare type SearchSort = {
1
+ export type SearchSortBy = string;
2
+ export type SearchSortOrder = 'asc' | 'desc';
3
+ export type SearchSort = {
4
4
  [by: SearchSortBy]: SearchSortOrder;
5
5
  };
6
- export declare type SearchQueryProperty = string;
7
- export declare type SearchQueryValue = string;
8
- export declare type SearchQuery = {
6
+ export type SearchQueryProperty = string;
7
+ export type SearchQueryValue = string;
8
+ export type SearchQuery = {
9
9
  [property: SearchQueryProperty]: SearchQueryValue;
10
10
  };
11
- export declare type SearchObject = {
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 declare type SearchResponse<T> = {
17
+ export type SearchResponse<T> = {
18
18
  items: ReadonlyArray<T>;
19
19
  offset: number;
20
20
  limit: number;