@openstax/ts-utils 1.1.30 → 1.1.31

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.
@@ -1,29 +1,4 @@
1
- import { UnionToIntersection } from './types';
2
- export declare const getKeyValue: <K extends string>(key: K) => <O extends { [key in K]?: any; }>(obj: O) => O[K];
3
- export declare const getKeyValueOr: <K extends string, V, Od extends { [key in K]?: any; } = { [key_1 in K]?: any; }>(key: K, defaultValue: V) => <O extends Od extends undefined ? { [key_2 in K]?: any; } : Od>(obj: O) => V | NonNullable<O[K]>;
4
- export declare const putKeyValue: <K extends string>(key: K) => <O extends { [key in K]?: any; }>(obj: O, value: O[K]) => O;
5
- export declare const coerceArray: <T>(thing: T | T[] | undefined) => T[];
6
- declare type FlowFn<A, R> = (...args: [A]) => R;
7
- declare type AnyFlowFn = FlowFn<any, any>;
8
- declare type FlowFnResult<F, A> = F extends FlowFn<A, infer R> ? R : never;
9
- declare type FlowResult<C, A> = C extends [infer F1, ...infer Cr] ? F1 extends AnyFlowFn ? Cr extends never[] ? FlowFnResult<F1, A> : FlowResult<Cr, FlowFnResult<F1, A>> : never : never;
10
- declare type FlowChainArg<C> = C extends [infer F1, ...infer _] ? F1 extends FlowFn<infer A, any> ? A : never : never;
11
- export declare const flow: <C extends AnyFlowFn[]>(...chain: C) => (param: FlowChainArg<C>) => FlowResult<C, FlowChainArg<C>>;
12
- export declare const fnIf: <T1, T2>(condition: boolean, trueValue: T1, falseValue: T2) => T1 | T2;
13
- export declare const mapFind: <I, R>(array: I[], mapper: (item: I) => R, predicate?: (result: R) => boolean) => R | undefined;
14
- declare type HashValue = string | number | boolean | null | HashCompoundValue;
15
- declare type HashCompoundValue = Array<HashValue> | {
16
- [key: string]: HashValue;
17
- };
18
- export declare const hashValue: (value: HashValue) => string;
19
- export declare const once: <F extends (...args: any[]) => any>(fn: F) => F;
20
- export declare const partitionSequence: <T, P>(getPartition: (thing: T, previous?: P | undefined) => {
21
- matches?: boolean | undefined;
22
- value: P;
23
- }, sequence: T[]) => [P, T[]][];
24
- export declare const memoize: <F extends (...args: any[]) => any>(fn: F) => F;
25
- export declare const roundToPrecision: (num: number, places: number) => number;
26
- export declare const getCommonProperties: <T1 extends {}, T2 extends {}>(thing1: T1, thing2: T2) => (keyof T1 & keyof T2)[];
27
- export declare const merge: <T extends {}[]>(...[thing1, ...tail]: T) => UnionToIntersection<T[number]>;
28
- export declare const tuple: <A extends any[]>(...args: A) => A;
29
- export {};
1
+ export * from './misc/partitionSequence';
2
+ export * from './misc/helpers';
3
+ export * from './misc/merge';
4
+ export * from './misc/hashValue';
package/dist/esm/index.js CHANGED
@@ -1,210 +1,4 @@
1
- import { createHash } from 'crypto';
2
- import deepEqual from 'deep-equal';
3
- import { isPlainObject } from './guards';
4
- /*
5
- * there was a reason i made these instead of using lodash/fp but i forget what it was. i think maybe
6
- * these do more validation that the second function gets a compatible object.
7
- *
8
- * const getAuthor = getKeyValue('author');
9
- * const author = getAuthor(book);
10
- *
11
- * const getAuthorOrNope = getKeyValueOr('author', 'nope');
12
- * const authorOrNope = getAuthorOrNope(book);
13
- *
14
- * const putAuthor = putKeyValue('author');
15
- * const newBook = putAuthor(book, 'tom');
16
- * */
17
- export const getKeyValue = (key) => (obj) => obj[key];
18
- export const getKeyValueOr = (key, defaultValue) => (obj) => obj[key] || defaultValue;
19
- export const putKeyValue = (key) => (obj, value) => ({ ...obj, [key]: value });
20
- export const coerceArray = (thing) => thing instanceof Array ? thing : thing !== undefined ? [thing] : [];
21
- /*
22
- * this is like lodash/flow but it uses a recursive type instead of hard-coding parameters
23
- */
24
- export const flow = (...chain) => (param) => {
25
- let result = param;
26
- for (const fn of chain) {
27
- result = fn(result);
28
- }
29
- return result;
30
- };
31
- /*
32
- * a shameful helper to avoid needing to test code coverage of branches
33
- */
34
- export const fnIf = (condition, trueValue, falseValue) => condition ? trueValue : falseValue;
35
- /*
36
- * maps the array and returns the first result that matches the predicate
37
- * avoids processing extra elements that would happen with .map().find() or .reduce
38
- *
39
- * eg the third element of the array is never processed:
40
- * const result = mapFind([1,2,3], x => 'hello'.charAt(x), x => x === 'l');
41
- */
42
- export const mapFind = (array, mapper, predicate = (r) => !!r) => {
43
- for (const item of array) {
44
- const mapped = mapper(item);
45
- if (predicate(mapped)) {
46
- return mapped;
47
- }
48
- }
49
- };
50
- /*
51
- * creates a string hash of lots of different kinds of things.
52
- *
53
- * eg:
54
- * hashValue({someKey: 'someValue'})
55
- * */
56
- export const hashValue = (value) => {
57
- // hack for sorting keys https://stackoverflow.com/a/53593328/14809536
58
- const allKeys = new Set();
59
- JSON.stringify(value, (k, v) => (allKeys.add(k), v));
60
- const strValue = JSON.stringify(value, Array.from(allKeys).sort());
61
- return createHash('sha1').update(strValue).digest('hex');
62
- };
63
- /*
64
- * returns a function that will only ever call the given function once, returning the first result for every subsequent call
65
- *
66
- * eg:
67
- * const heavyFunction = () => 'hello';
68
- * const butOnlyOnce = once(() => 'hello');
69
- *
70
- * heavyFunction() // returns `hello`;
71
- * butOnlyOnce() // returns `hello`;
72
- */
73
- export const once = (fn) => {
74
- const initialValue = {};
75
- let result = initialValue;
76
- return ((...args) => result === initialValue ? (result = fn(...args)) : result);
77
- };
78
- /*
79
- * partitions a sequence based on a partition function returning {value: any; matches?: boolean}
80
- * - if the function returns `matches` explicitly then adjacent matching elements will
81
- * be grouped and the predicate value in the result will be from the last item in the group
82
- * - if the function returns only a value then matching will be evaluated based on the deep
83
- * equality of the value with its neighbors
84
- *
85
- * this is different from lodash/partition and lodash/groupBy because:
86
- * - it preserves the order of the items, items will only be grouped if they are already adjacent
87
- * - there can be any number of groups
88
- * - it tells you the partition value
89
- * - the partition value can be reduced, if you care (so you can like, partition on sequential values)
90
- *
91
- * simple predicate:
92
- * returns: [[0, [1,2]], [1, [3,4,5]]]
93
- * partitionSequence((n: number) => ({value: Math.floor(n / 3)}), [1,2,3,4,5])
94
- *
95
- * mutating partition:
96
- * returns: [
97
- * [{min: 1,max: 3}, [1,2,3]],
98
- * [{min: 5,max: 6}, [5,6]],
99
- * [{min: 8,max: 8}, [8]],
100
- * ]
101
- * partitionSequence(
102
- * (n: number, p?: {min: number; max: number}) =>
103
- * p && p.max + 1 === n
104
- * ? {value: {...p, max: n}, matches: true}
105
- * : {value: {min: n, max: n}, matches: false}
106
- * , [1,2,3,5,6,8]
107
- * )
108
- */
109
- export const partitionSequence = (getPartition, sequence) => {
110
- const appendItem = (result, item) => {
111
- const current = result[result.length - 1];
112
- const itemPartition = getPartition(item, current === null || current === void 0 ? void 0 : current[0]);
113
- if (current && ((itemPartition.matches === undefined && deepEqual(current[0], itemPartition.value))
114
- || itemPartition.matches)) {
115
- current[0] = itemPartition.value;
116
- current[1].push(item);
117
- }
118
- else {
119
- result.push([itemPartition.value, [item]]);
120
- }
121
- return result;
122
- };
123
- return sequence.reduce(appendItem, []);
124
- };
125
- /*
126
- * memoizes a function with any number of arguments
127
- */
128
- export const memoize = (fn) => {
129
- const cache = {};
130
- const resolveCache = (cacheLayer, [first, ...rest]) => {
131
- if (!first) {
132
- return cacheLayer;
133
- }
134
- const layers = first instanceof Object
135
- ? (cacheLayer.weakLayers = (cacheLayer.weakLayers || (typeof WeakMap === 'undefined' ? undefined : new WeakMap())))
136
- : (cacheLayer.strongLayers = (cacheLayer.strongLayers || new Map()));
137
- // argument is an object and WeakMap is not supported
138
- if (!layers) {
139
- return {};
140
- }
141
- const layer = layers.get(first) || {};
142
- if (!layers.has(first)) {
143
- layers.set(first, layer);
144
- }
145
- return resolveCache(layer, rest);
146
- };
147
- return ((...args) => {
148
- const thisCache = resolveCache(cache, args);
149
- return thisCache.result = (thisCache.result || fn(...args));
150
- });
151
- };
152
- /*
153
- * rounds number to given number of places
154
- *
155
- * eg:
156
- * roundToPrecision(1234.123, 2); // returns 1200
157
- * roundToPrecision(1234.123, -2); // returns 1234.12
158
- * roundToPrecision(1234.125, -2); // returns 1234.13
159
- */
160
- export const roundToPrecision = (num, places) => {
161
- const multiplier = Math.pow(10, -1 * places);
162
- // https://stackoverflow.com/a/11832950/14809536
163
- return Math.round((num + Number.EPSILON) * multiplier) / multiplier;
164
- };
165
- export const getCommonProperties = (thing1, thing2) => Object.keys(thing1).filter((key) => Object.keys(thing2).includes(key));
166
- /*
167
- * recursive merge properties of inputs. values are merged if they are
168
- * plain objects or arrays, otherwise if the same property exists in both
169
- * objects the value from the second argument will win.
170
- *
171
- * unlike lodash merge, this will not change object references for values that
172
- * exist only in one parameter.
173
- *
174
- * eg:
175
- * merge({thing: 'one'}, {thing: 'two', otherKey: 'one'}, {coolKey: 'coolValue'});
176
- */
177
- export const merge = (...[thing1, ...tail]) => {
178
- const mergedTail = tail.length > 0
179
- ? merge(...tail)
180
- : null;
181
- if (!mergedTail) {
182
- return thing1;
183
- }
184
- return {
185
- ...thing1,
186
- ...mergedTail,
187
- ...getCommonProperties(thing1, mergedTail).reduce((result, property) => ({
188
- ...result,
189
- ...(isPlainObject(thing1[property]) && isPlainObject(mergedTail[property])
190
- ? { [property]: merge(thing1[property], mergedTail[property]) }
191
- : (Array.isArray(thing1[property]) && Array.isArray(mergedTail[property]))
192
- ? { [property]: [...thing1[property], ...mergedTail[property]] }
193
- : {}),
194
- }), {}),
195
- };
196
- };
197
- /*
198
- * a silly utility to help typescript realize an array is a tuple
199
- *
200
- * eg:
201
- * const a = [5, 'string'] // type is `Array<string | number>`
202
- * const t = tuple(5, 'string') type is `[5, 'string']`
203
- *
204
- * both have the same javascript value, but one is forced to be a tuple, which
205
- * is nice if its structure is important. examples are like the React.useState
206
- * pattern where there are two return values in a tuple, or if you're feeding
207
- * Object.fromEntries
208
- *
209
- */
210
- export const tuple = (...args) => args;
1
+ export * from './misc/partitionSequence';
2
+ export * from './misc/helpers';
3
+ export * from './misc/merge';
4
+ export * from './misc/hashValue';
@@ -0,0 +1,6 @@
1
+ declare type HashValue = string | number | boolean | null | HashCompoundValue;
2
+ declare type HashCompoundValue = Array<HashValue> | {
3
+ [key: string]: HashValue;
4
+ };
5
+ export declare const hashValue: (value: HashValue) => string;
6
+ export {};
@@ -0,0 +1,14 @@
1
+ import { createHash } from 'crypto';
2
+ /*
3
+ * creates a string hash of lots of different kinds of things.
4
+ *
5
+ * eg:
6
+ * hashValue({someKey: 'someValue'})
7
+ * */
8
+ export const hashValue = (value) => {
9
+ // hack for sorting keys https://stackoverflow.com/a/53593328/14809536
10
+ const allKeys = new Set();
11
+ JSON.stringify(value, (k, v) => (allKeys.add(k), v));
12
+ const strValue = JSON.stringify(value, Array.from(allKeys).sort());
13
+ return createHash('sha1').update(strValue).digest('hex');
14
+ };
@@ -0,0 +1,17 @@
1
+ export declare const getKeyValue: <K extends string>(key: K) => <O extends { [key in K]?: any; }>(obj: O) => O[K];
2
+ export declare const getKeyValueOr: <K extends string, V, Od extends { [key in K]?: any; } = { [key_1 in K]?: any; }>(key: K, defaultValue: V) => <O extends Od extends undefined ? { [key_2 in K]?: any; } : Od>(obj: O) => V | NonNullable<O[K]>;
3
+ export declare const putKeyValue: <K extends string>(key: K) => <O extends { [key in K]?: any; }>(obj: O, value: O[K]) => O;
4
+ export declare const coerceArray: <T>(thing: T | T[] | undefined) => T[];
5
+ declare type FlowFn<A, R> = (...args: [A]) => R;
6
+ declare type AnyFlowFn = FlowFn<any, any>;
7
+ declare type FlowFnResult<F, A> = F extends FlowFn<A, infer R> ? R : never;
8
+ declare type FlowResult<C, A> = C extends [infer F1, ...infer Cr] ? F1 extends AnyFlowFn ? Cr extends never[] ? FlowFnResult<F1, A> : FlowResult<Cr, FlowFnResult<F1, A>> : never : never;
9
+ declare type FlowChainArg<C> = C extends [infer F1, ...infer _] ? F1 extends FlowFn<infer A, any> ? A : never : never;
10
+ export declare const flow: <C extends AnyFlowFn[]>(...chain: C) => (param: FlowChainArg<C>) => FlowResult<C, FlowChainArg<C>>;
11
+ export declare const fnIf: <T1, T2>(condition: boolean, trueValue: T1, falseValue: T2) => T1 | T2;
12
+ export declare const mapFind: <I, R>(array: I[], mapper: (item: I) => R, predicate?: (result: R) => boolean) => R | undefined;
13
+ export declare const once: <F extends (...args: any[]) => any>(fn: F) => F;
14
+ export declare const memoize: <F extends (...args: any[]) => any>(fn: F) => F;
15
+ export declare const roundToPrecision: (num: number, places: number) => number;
16
+ export declare const tuple: <A extends any[]>(...args: A) => A;
17
+ export {};
@@ -0,0 +1,115 @@
1
+ /*
2
+ * there was a reason i made these instead of using lodash/fp but i forget what it was. i think maybe
3
+ * these do more validation that the second function gets a compatible object.
4
+ *
5
+ * const getAuthor = getKeyValue('author');
6
+ * const author = getAuthor(book);
7
+ *
8
+ * const getAuthorOrNope = getKeyValueOr('author', 'nope');
9
+ * const authorOrNope = getAuthorOrNope(book);
10
+ *
11
+ * const putAuthor = putKeyValue('author');
12
+ * const newBook = putAuthor(book, 'tom');
13
+ * */
14
+ export const getKeyValue = (key) => (obj) => obj[key];
15
+ export const getKeyValueOr = (key, defaultValue) => (obj) => obj[key] || defaultValue;
16
+ export const putKeyValue = (key) => (obj, value) => ({ ...obj, [key]: value });
17
+ export const coerceArray = (thing) => thing instanceof Array ? thing : thing !== undefined ? [thing] : [];
18
+ /*
19
+ * this is like lodash/flow but it uses a recursive type instead of hard-coding parameters
20
+ */
21
+ export const flow = (...chain) => (param) => {
22
+ let result = param;
23
+ for (const fn of chain) {
24
+ result = fn(result);
25
+ }
26
+ return result;
27
+ };
28
+ /*
29
+ * a shameful helper to avoid needing to test code coverage of branches
30
+ */
31
+ export const fnIf = (condition, trueValue, falseValue) => condition ? trueValue : falseValue;
32
+ /*
33
+ * maps the array and returns the first result that matches the predicate
34
+ * avoids processing extra elements that would happen with .map().find() or .reduce
35
+ *
36
+ * eg the third element of the array is never processed:
37
+ * const result = mapFind([1,2,3], x => 'hello'.charAt(x), x => x === 'l');
38
+ */
39
+ export const mapFind = (array, mapper, predicate = (r) => !!r) => {
40
+ for (const item of array) {
41
+ const mapped = mapper(item);
42
+ if (predicate(mapped)) {
43
+ return mapped;
44
+ }
45
+ }
46
+ };
47
+ /*
48
+ * returns a function that will only ever call the given function once, returning the first result for every subsequent call
49
+ *
50
+ * eg:
51
+ * const heavyFunction = () => 'hello';
52
+ * const butOnlyOnce = once(() => 'hello');
53
+ *
54
+ * heavyFunction() // returns `hello`;
55
+ * butOnlyOnce() // returns `hello`;
56
+ */
57
+ export const once = (fn) => {
58
+ const initialValue = {};
59
+ let result = initialValue;
60
+ return ((...args) => result === initialValue ? (result = fn(...args)) : result);
61
+ };
62
+ /*
63
+ * memoizes a function with any number of arguments
64
+ */
65
+ export const memoize = (fn) => {
66
+ const cache = {};
67
+ const resolveCache = (cacheLayer, [first, ...rest]) => {
68
+ if (!first) {
69
+ return cacheLayer;
70
+ }
71
+ const layers = first instanceof Object
72
+ ? (cacheLayer.weakLayers = (cacheLayer.weakLayers || (typeof WeakMap === 'undefined' ? undefined : new WeakMap())))
73
+ : (cacheLayer.strongLayers = (cacheLayer.strongLayers || new Map()));
74
+ // argument is an object and WeakMap is not supported
75
+ if (!layers) {
76
+ return {};
77
+ }
78
+ const layer = layers.get(first) || {};
79
+ if (!layers.has(first)) {
80
+ layers.set(first, layer);
81
+ }
82
+ return resolveCache(layer, rest);
83
+ };
84
+ return ((...args) => {
85
+ const thisCache = resolveCache(cache, args);
86
+ return thisCache.result = (thisCache.result || fn(...args));
87
+ });
88
+ };
89
+ /*
90
+ * rounds number to given number of places
91
+ *
92
+ * eg:
93
+ * roundToPrecision(1234.123, 2); // returns 1200
94
+ * roundToPrecision(1234.123, -2); // returns 1234.12
95
+ * roundToPrecision(1234.125, -2); // returns 1234.13
96
+ */
97
+ export const roundToPrecision = (num, places) => {
98
+ const multiplier = Math.pow(10, -1 * places);
99
+ // https://stackoverflow.com/a/11832950/14809536
100
+ return Math.round((num + Number.EPSILON) * multiplier) / multiplier;
101
+ };
102
+ /*
103
+ * a silly utility to help typescript realize an array is a tuple
104
+ *
105
+ * eg:
106
+ * const a = [5, 'string'] // type is `Array<string | number>`
107
+ * const t = tuple(5, 'string') type is `[5, 'string']`
108
+ *
109
+ * both have the same javascript value, but one is forced to be a tuple, which
110
+ * is nice if its structure is important. examples are like the React.useState
111
+ * pattern where there are two return values in a tuple, or if you're feeding
112
+ * Object.fromEntries
113
+ *
114
+ */
115
+ export const tuple = (...args) => args;
@@ -0,0 +1,3 @@
1
+ import type { UnionToIntersection } from '../types';
2
+ export declare const getCommonProperties: <T1 extends {}, T2 extends {}>(thing1: T1, thing2: T2) => (keyof T1 & keyof T2)[];
3
+ export declare const merge: <T extends {}[]>(...[thing1, ...tail]: T) => UnionToIntersection<T[number]>;
@@ -0,0 +1,33 @@
1
+ import { isPlainObject } from '../guards';
2
+ export const getCommonProperties = (thing1, thing2) => Object.keys(thing1).filter((key) => Object.keys(thing2).includes(key));
3
+ /*
4
+ * recursive merge properties of inputs. values are merged if they are
5
+ * plain objects or arrays, otherwise if the same property exists in both
6
+ * objects the value from the second argument will win.
7
+ *
8
+ * unlike lodash merge, this will not change object references for values that
9
+ * exist only in one parameter.
10
+ *
11
+ * eg:
12
+ * merge({thing: 'one'}, {thing: 'two', otherKey: 'one'}, {coolKey: 'coolValue'});
13
+ */
14
+ export const merge = (...[thing1, ...tail]) => {
15
+ const mergedTail = tail.length > 0
16
+ ? merge(...tail)
17
+ : null;
18
+ if (!mergedTail) {
19
+ return thing1;
20
+ }
21
+ return {
22
+ ...thing1,
23
+ ...mergedTail,
24
+ ...getCommonProperties(thing1, mergedTail).reduce((result, property) => ({
25
+ ...result,
26
+ ...(isPlainObject(thing1[property]) && isPlainObject(mergedTail[property])
27
+ ? { [property]: merge(thing1[property], mergedTail[property]) }
28
+ : (Array.isArray(thing1[property]) && Array.isArray(mergedTail[property]))
29
+ ? { [property]: [...thing1[property], ...mergedTail[property]] }
30
+ : {}),
31
+ }), {}),
32
+ };
33
+ };
@@ -0,0 +1,4 @@
1
+ export declare const partitionSequence: <T, P>(getPartition: (thing: T, previous?: P | undefined) => {
2
+ matches?: boolean | undefined;
3
+ value: P;
4
+ }, sequence: T[]) => [P, T[]][];
@@ -0,0 +1,48 @@
1
+ import deepEqual from 'deep-equal';
2
+ /*
3
+ * partitions a sequence based on a partition function returning {value: any; matches?: boolean}
4
+ * - if the function returns `matches` explicitly then adjacent matching elements will
5
+ * be grouped and the predicate value in the result will be from the last item in the group
6
+ * - if the function returns only a value then matching will be evaluated based on the deep
7
+ * equality of the value with its neighbors
8
+ *
9
+ * this is different from lodash/partition and lodash/groupBy because:
10
+ * - it preserves the order of the items, items will only be grouped if they are already adjacent
11
+ * - there can be any number of groups
12
+ * - it tells you the partition value
13
+ * - the partition value can be reduced, if you care (so you can like, partition on sequential values)
14
+ *
15
+ * simple predicate:
16
+ * returns: [[0, [1,2]], [1, [3,4,5]]]
17
+ * partitionSequence((n: number) => ({value: Math.floor(n / 3)}), [1,2,3,4,5])
18
+ *
19
+ * mutating partition:
20
+ * returns: [
21
+ * [{min: 1,max: 3}, [1,2,3]],
22
+ * [{min: 5,max: 6}, [5,6]],
23
+ * [{min: 8,max: 8}, [8]],
24
+ * ]
25
+ * partitionSequence(
26
+ * (n: number, p?: {min: number; max: number}) =>
27
+ * p && p.max + 1 === n
28
+ * ? {value: {...p, max: n}, matches: true}
29
+ * : {value: {min: n, max: n}, matches: false}
30
+ * , [1,2,3,5,6,8]
31
+ * )
32
+ */
33
+ export const partitionSequence = (getPartition, sequence) => {
34
+ const appendItem = (result, item) => {
35
+ const current = result[result.length - 1];
36
+ const itemPartition = getPartition(item, current === null || current === void 0 ? void 0 : current[0]);
37
+ if (current && ((itemPartition.matches === undefined && deepEqual(current[0], itemPartition.value))
38
+ || itemPartition.matches)) {
39
+ current[0] = itemPartition.value;
40
+ current[1].push(item);
41
+ }
42
+ else {
43
+ result.push([itemPartition.value, [item]]);
44
+ }
45
+ return result;
46
+ };
47
+ return sequence.reduce(appendItem, []);
48
+ };
@@ -1,7 +1,7 @@
1
1
  import { compactDecrypt, compactVerify, importSPKI } from 'jose';
2
- import { once } from '../..';
3
2
  import { resolveConfigValue } from '../../config/resolveConfigValue';
4
3
  import { ifDefined } from '../../guards';
4
+ import { once } from '../../misc/helpers';
5
5
  import { getAuthTokenOrCookie } from '.';
6
6
  export const decryptionAuthProvider = (initializer) => (configProvider) => {
7
7
  const config = configProvider[ifDefined(initializer.configSpace, 'decryption')];