@dereekb/util 7.8.1 → 7.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/package.json +1 -1
- package/src/lib/array/array.factory.d.ts +23 -0
- package/src/lib/array/array.factory.js +25 -0
- package/src/lib/array/array.factory.js.map +1 -0
- package/src/lib/array/array.make.d.ts +19 -5
- package/src/lib/array/array.make.js +16 -10
- package/src/lib/array/array.make.js.map +1 -1
- package/src/lib/array/index.d.ts +1 -0
- package/src/lib/array/index.js +1 -0
- package/src/lib/array/index.js.map +1 -1
- package/src/lib/getter/getter.d.ts +10 -1
- package/src/lib/getter/getter.js +13 -1
- package/src/lib/getter/getter.js.map +1 -1
- package/src/lib/grouping.d.ts +29 -0
- package/src/lib/grouping.js +32 -1
- package/src/lib/grouping.js.map +1 -1
- package/src/lib/number/random.d.ts +9 -4
- package/src/lib/number/random.js +11 -5
- package/src/lib/number/random.js.map +1 -1
- package/src/lib/promise/promise.loop.d.ts +11 -1
- package/src/lib/promise/promise.loop.js +16 -1
- package/src/lib/promise/promise.loop.js.map +1 -1
- package/test/CHANGELOG.md +4 -0
- package/test/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
# [7.9.0](https://github.com/dereekb/dbx-components/compare/v7.8.1-dev...v7.9.0) (2022-06-11)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* added arrayFactory() ([5a7ef13](https://github.com/dereekb/dbx-components/commit/5a7ef13116ebbacd8b7a9502e3298fd30708f944))
|
|
11
|
+
* added makeWithFactory() ([4a6f4a0](https://github.com/dereekb/dbx-components/commit/4a6f4a01a04e7800653bc942fe56b27ec457813e))
|
|
12
|
+
* added performBatchLoop() ([7c6c947](https://github.com/dereekb/dbx-components/commit/7c6c9475eacfd3cc7f153ef949fef1187925a8cb))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
5
16
|
## [7.8.1](https://github.com/dereekb/dbx-components/compare/v7.8.0-dev...v7.8.1) (2022-06-10)
|
|
6
17
|
|
|
7
18
|
|
package/package.json
CHANGED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Factory, FactoryWithIndex, FactoryWithRequiredInput } from '../getter/getter';
|
|
2
|
+
/**
|
|
3
|
+
* Factory that generates multiple values given a number of items to make.
|
|
4
|
+
*/
|
|
5
|
+
export declare type ArrayFactory<T> = FactoryWithRequiredInput<T[], number>;
|
|
6
|
+
/**
|
|
7
|
+
* Factory that generates a value for each input value.
|
|
8
|
+
*/
|
|
9
|
+
export declare type ArrayInputFactory<I, O> = FactoryWithRequiredInput<O[], I[]>;
|
|
10
|
+
/**
|
|
11
|
+
* Creates a new ArrayFactory.
|
|
12
|
+
*
|
|
13
|
+
* @param factory
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
export declare function arrayFactory<T>(factory: Factory<T> | FactoryWithIndex<T>): ArrayFactory<T>;
|
|
17
|
+
/**
|
|
18
|
+
* Creates a ArrayInputFactory.
|
|
19
|
+
*
|
|
20
|
+
* @param factory
|
|
21
|
+
* @returns
|
|
22
|
+
*/
|
|
23
|
+
export declare function arrayInputFactory<O, I>(factory: FactoryWithRequiredInput<O, I>): ArrayInputFactory<I, O>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.arrayInputFactory = exports.arrayFactory = void 0;
|
|
4
|
+
const getter_1 = require("../getter/getter");
|
|
5
|
+
/**
|
|
6
|
+
* Creates a new ArrayFactory.
|
|
7
|
+
*
|
|
8
|
+
* @param factory
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
function arrayFactory(factory) {
|
|
12
|
+
return (count) => (0, getter_1.makeWithFactory)(factory, count);
|
|
13
|
+
}
|
|
14
|
+
exports.arrayFactory = arrayFactory;
|
|
15
|
+
/**
|
|
16
|
+
* Creates a ArrayInputFactory.
|
|
17
|
+
*
|
|
18
|
+
* @param factory
|
|
19
|
+
* @returns
|
|
20
|
+
*/
|
|
21
|
+
function arrayInputFactory(factory) {
|
|
22
|
+
return (input) => (0, getter_1.makeWithFactoryInput)(factory, input);
|
|
23
|
+
}
|
|
24
|
+
exports.arrayInputFactory = arrayInputFactory;
|
|
25
|
+
//# sourceMappingURL=array.factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array.factory.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/array/array.factory.ts"],"names":[],"mappings":";;;AAAA,6CAA8H;AAY9H;;;;;GAKG;AACH,SAAgB,YAAY,CAAI,OAAyC;IACvE,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,IAAA,wBAAe,EAAC,OAAO,EAAE,KAAK,CAAC,CAAC;AACpD,CAAC;AAFD,oCAEC;AAED;;;;;GAKG;AACH,SAAgB,iBAAiB,CAAO,OAAuC;IAC7E,OAAO,CAAC,KAAU,EAAE,EAAE,CAAC,IAAA,6BAAoB,EAAO,OAAO,EAAE,KAAK,CAAC,CAAC;AACpE,CAAC;AAFD,8CAEC"}
|
|
@@ -1,22 +1,36 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FactoryWithInput } from '../getter';
|
|
2
|
+
import { RandomNumberFactoryInput, RandomNumberFactory } from '../number/random';
|
|
2
3
|
export interface MakeArray<T> {
|
|
3
4
|
count: number;
|
|
4
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Makes an item
|
|
7
|
+
*/
|
|
8
|
+
make: FactoryWithInput<T, number>;
|
|
5
9
|
}
|
|
6
10
|
/**
|
|
7
11
|
* Makes an array of values of a certain length using a generator function.
|
|
8
12
|
*
|
|
9
13
|
* @param param0
|
|
10
14
|
* @returns
|
|
15
|
+
*
|
|
16
|
+
* @deprecated use makeWithFactory instead.
|
|
11
17
|
*/
|
|
12
18
|
export declare function makeArray<T>({ count, make }: MakeArray<T>): T[];
|
|
13
|
-
export interface
|
|
14
|
-
random:
|
|
19
|
+
export interface RandomArrayFactoryConfig<T> extends Omit<MakeArray<T>, 'count'> {
|
|
20
|
+
random: RandomNumberFactory | RandomNumberFactoryInput;
|
|
15
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Creates an array of a random size and values.
|
|
24
|
+
*/
|
|
25
|
+
export declare type RandomArrayFactory<T> = FactoryWithInput<T[], number>;
|
|
16
26
|
/**
|
|
17
27
|
* Makes a function that generates arrays of a random length of a specific type.
|
|
18
28
|
*
|
|
19
29
|
* @param config
|
|
20
30
|
* @returns
|
|
21
31
|
*/
|
|
22
|
-
export declare function
|
|
32
|
+
export declare function randomArrayFactory<T>(config: RandomArrayFactoryConfig<T>): RandomArrayFactory<T>;
|
|
33
|
+
/**
|
|
34
|
+
* @deprecated Use randomArrayFactory instead.
|
|
35
|
+
*/
|
|
36
|
+
export declare const makeRandomArrayFn: typeof randomArrayFactory;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.makeRandomArrayFn = exports.makeArray = void 0;
|
|
3
|
+
exports.makeRandomArrayFn = exports.randomArrayFactory = exports.makeArray = void 0;
|
|
4
|
+
const getter_1 = require("../getter");
|
|
4
5
|
const random_1 = require("../number/random");
|
|
6
|
+
const array_factory_1 = require("./array.factory");
|
|
5
7
|
/**
|
|
6
8
|
* Makes an array of values of a certain length using a generator function.
|
|
7
9
|
*
|
|
8
10
|
* @param param0
|
|
9
11
|
* @returns
|
|
12
|
+
*
|
|
13
|
+
* @deprecated use makeWithFactory instead.
|
|
10
14
|
*/
|
|
11
15
|
function makeArray({ count, make }) {
|
|
12
|
-
|
|
13
|
-
for (let i = 0; i < count; i += 1) {
|
|
14
|
-
array.push(make(i));
|
|
15
|
-
}
|
|
16
|
-
return array;
|
|
16
|
+
return (0, getter_1.makeWithFactory)(make, count);
|
|
17
17
|
}
|
|
18
18
|
exports.makeArray = makeArray;
|
|
19
19
|
/**
|
|
@@ -22,9 +22,15 @@ exports.makeArray = makeArray;
|
|
|
22
22
|
* @param config
|
|
23
23
|
* @returns
|
|
24
24
|
*/
|
|
25
|
-
function
|
|
26
|
-
const randomFn = typeof config.random === 'function' ? config.random : (0, random_1.
|
|
27
|
-
|
|
25
|
+
function randomArrayFactory(config) {
|
|
26
|
+
const randomFn = typeof config.random === 'function' ? config.random : (0, random_1.randomNumberFactory)(config.random);
|
|
27
|
+
const nextRandomCount = () => Math.abs(randomFn());
|
|
28
|
+
const factory = (0, array_factory_1.arrayFactory)(config.make);
|
|
29
|
+
return (count = nextRandomCount()) => factory(count);
|
|
28
30
|
}
|
|
29
|
-
exports.
|
|
31
|
+
exports.randomArrayFactory = randomArrayFactory;
|
|
32
|
+
/**
|
|
33
|
+
* @deprecated Use randomArrayFactory instead.
|
|
34
|
+
*/
|
|
35
|
+
exports.makeRandomArrayFn = randomArrayFactory;
|
|
30
36
|
//# sourceMappingURL=array.make.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array.make.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/array/array.make.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"array.make.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/array/array.make.ts"],"names":[],"mappings":";;;AAAA,sCAAuE;AACvE,6CAAsG;AACtG,mDAA+C;AAW/C;;;;;;;GAOG;AACH,SAAgB,SAAS,CAAI,EAAE,KAAK,EAAE,IAAI,EAAgB;IACxD,OAAO,IAAA,wBAAe,EAAC,IAAkB,EAAE,KAAK,CAAC,CAAC;AACpD,CAAC;AAFD,8BAEC;AAYD;;;;;GAKG;AACH,SAAgB,kBAAkB,CAAI,MAAmC;IACvE,MAAM,QAAQ,GAAG,OAAO,MAAM,CAAC,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,IAAA,4BAAmB,EAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC1G,MAAM,eAAe,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;IACnD,MAAM,OAAO,GAAG,IAAA,4BAAY,EAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC1C,OAAO,CAAC,KAAK,GAAG,eAAe,EAAE,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AACvD,CAAC;AALD,gDAKC;AAED;;GAEG;AACU,QAAA,iBAAiB,GAAG,kBAAkB,CAAC"}
|
package/src/lib/array/index.d.ts
CHANGED
package/src/lib/array/index.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
tslib_1.__exportStar(require("./array.boolean"), exports);
|
|
5
5
|
tslib_1.__exportStar(require("./array.filter"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./array.factory"), exports);
|
|
6
7
|
tslib_1.__exportStar(require("./array.index"), exports);
|
|
7
8
|
tslib_1.__exportStar(require("./array.limit"), exports);
|
|
8
9
|
tslib_1.__exportStar(require("./array.make"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/array/index.ts"],"names":[],"mappings":";;;AAAA,0DAAgC;AAChC,yDAA+B;AAC/B,wDAA8B;AAC9B,wDAA8B;AAC9B,uDAA6B;AAC7B,sDAA4B;AAC5B,yDAA+B;AAC/B,sDAA4B;AAC5B,yDAA+B;AAC/B,kDAAwB;AACxB,yDAA+B;AAC/B,wDAA8B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/array/index.ts"],"names":[],"mappings":";;;AAAA,0DAAgC;AAChC,yDAA+B;AAC/B,0DAAgC;AAChC,wDAA8B;AAC9B,wDAA8B;AAC9B,uDAA6B;AAC7B,sDAA4B;AAC5B,yDAA+B;AAC/B,sDAA4B;AAC5B,yDAA+B;AAC/B,kDAAwB;AACxB,yDAA+B;AAC/B,wDAA8B"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { PromiseOrValue } from '../promise/promise';
|
|
2
|
+
import { MapFunction } from '../value/map';
|
|
3
|
+
import { Maybe } from '../value/maybe.type';
|
|
2
4
|
/**
|
|
3
5
|
* Function that returns a value.
|
|
4
6
|
*/
|
|
@@ -14,7 +16,7 @@ export declare type FactoryWithInput<O, I> = (args?: I) => O;
|
|
|
14
16
|
/**
|
|
15
17
|
* Function that returns a value with a single argument.
|
|
16
18
|
*/
|
|
17
|
-
export declare type FactoryWithRequiredInput<T, A> =
|
|
19
|
+
export declare type FactoryWithRequiredInput<T, A> = MapFunction<A, T>;
|
|
18
20
|
/**
|
|
19
21
|
* Either a Getter, or an instance of the item.
|
|
20
22
|
*/
|
|
@@ -64,3 +66,10 @@ export declare function asGetter<T>(input: GetterOrValue<T>): Getter<T>;
|
|
|
64
66
|
* @returns
|
|
65
67
|
*/
|
|
66
68
|
export declare function makeGetter<T>(input: T): Getter<T>;
|
|
69
|
+
/**
|
|
70
|
+
* A factory that can take in an index input optionally.
|
|
71
|
+
*/
|
|
72
|
+
export declare type FactoryWithIndex<T> = FactoryWithInput<T, number> | FactoryWithRequiredInput<T, number>;
|
|
73
|
+
export declare function makeWithFactory<T>(factory: Factory<T> | FactoryWithIndex<T>, count: number): T[];
|
|
74
|
+
export declare function makeWithFactoryInput<T, A>(factory: FactoryWithInput<T, A>, input: Maybe<A>[]): T[];
|
|
75
|
+
export declare function makeWithFactoryInput<T, A>(factory: FactoryWithRequiredInput<T, A>, input: A[]): T[];
|
package/src/lib/getter/getter.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.makeGetter = exports.asGetter = exports.getValueFromGetter = exports.isGetter = void 0;
|
|
3
|
+
exports.makeWithFactoryInput = exports.makeWithFactory = exports.makeGetter = exports.asGetter = exports.getValueFromGetter = exports.isGetter = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Returns true if the input object looks like a Getter (is a function).
|
|
6
6
|
*
|
|
@@ -45,4 +45,16 @@ function makeGetter(input) {
|
|
|
45
45
|
return () => input;
|
|
46
46
|
}
|
|
47
47
|
exports.makeGetter = makeGetter;
|
|
48
|
+
function makeWithFactory(factory, count) {
|
|
49
|
+
const results = [];
|
|
50
|
+
for (let i = 0; i < count; i += 1) {
|
|
51
|
+
results.push(factory(i));
|
|
52
|
+
}
|
|
53
|
+
return results;
|
|
54
|
+
}
|
|
55
|
+
exports.makeWithFactory = makeWithFactory;
|
|
56
|
+
function makeWithFactoryInput(factory, input) {
|
|
57
|
+
return input.map((x) => factory(x));
|
|
58
|
+
}
|
|
59
|
+
exports.makeWithFactoryInput = makeWithFactoryInput;
|
|
48
60
|
//# sourceMappingURL=getter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getter.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/getter/getter.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"getter.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/getter/getter.ts"],"names":[],"mappings":";;;AA8CA;;;;;GAKG;AACH,SAAgB,QAAQ,CAAc,KAAc;IAClD,OAAO,OAAO,KAAK,KAAK,UAAU,CAAC;AACrC,CAAC;AAFD,4BAEC;AAaD,SAAgB,kBAAkB,CAAsB,KAAc,EAAE,IAAQ;IAC9E,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE;QAC/B,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC;KACpB;SAAM;QACL,OAAO,KAAU,CAAC;KACnB;AACH,CAAC;AAND,gDAMC;AAED;;;;;GAKG;AACH,SAAgB,QAAQ,CAAI,KAAuB;IACjD,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE;QAC/B,OAAO,KAAkB,CAAC;KAC3B;SAAM;QACL,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC;KAC1B;AACH,CAAC;AAND,4BAMC;AAED;;;;;GAKG;AACH,SAAgB,UAAU,CAAI,KAAQ;IACpC,OAAO,GAAG,EAAE,CAAC,KAAK,CAAC;AACrB,CAAC;AAFD,gCAEC;AAOD,SAAgB,eAAe,CAAI,OAAyC,EAAE,KAAa;IACzF,MAAM,OAAO,GAAQ,EAAE,CAAC;IAExB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,IAAI,CAAC,EAAE;QACjC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;KAC1B;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AARD,0CAQC;AAID,SAAgB,oBAAoB,CAAO,OAAuC,EAAE,KAAU;IAC5F,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;AACtC,CAAC;AAFD,oDAEC"}
|
package/src/lib/grouping.d.ts
CHANGED
|
@@ -42,6 +42,35 @@ export interface RestoreOrderParams<T, K extends number | string = number | stri
|
|
|
42
42
|
* @returns
|
|
43
43
|
*/
|
|
44
44
|
export declare function batch<T>(array: T[], batchSize: number): T[][];
|
|
45
|
+
export interface BatchCount {
|
|
46
|
+
/**
|
|
47
|
+
* Total number of items to make.
|
|
48
|
+
*/
|
|
49
|
+
totalItems: number;
|
|
50
|
+
/**
|
|
51
|
+
* Size of each batch/expected max number of items to create per make call.
|
|
52
|
+
*/
|
|
53
|
+
itemsPerBatch: number;
|
|
54
|
+
}
|
|
55
|
+
export interface BatchCalc extends BatchCount {
|
|
56
|
+
batchCount: number;
|
|
57
|
+
/**
|
|
58
|
+
* Total number of full batches.
|
|
59
|
+
*/
|
|
60
|
+
fullBatchCount: number;
|
|
61
|
+
/**
|
|
62
|
+
* The number of items not in a full batch.
|
|
63
|
+
*/
|
|
64
|
+
remainder: number;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Calculates a BatchCount given the input.
|
|
68
|
+
*
|
|
69
|
+
* @param input
|
|
70
|
+
* @returns
|
|
71
|
+
*/
|
|
72
|
+
export declare function batchCalc(input: BatchCount): BatchCalc;
|
|
73
|
+
export declare function itemCountForBatchIndex(index: number, calc: BatchCalc): number;
|
|
45
74
|
/**
|
|
46
75
|
* Convenience function for calling restoreOrder with two arrays of values, instead of an array of keys and array of values.
|
|
47
76
|
*
|
package/src/lib/grouping.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.makeValuesGroupMap = exports.groupValues = exports.separateValues = exports.makeKeyPairs = exports.pairGroupValues = exports.arrayContentsDiffer = exports.restoreOrder = exports.restoreOrderWithValues = exports.batch = void 0;
|
|
3
|
+
exports.makeValuesGroupMap = exports.groupValues = exports.separateValues = exports.makeKeyPairs = exports.pairGroupValues = exports.arrayContentsDiffer = exports.restoreOrder = exports.restoreOrderWithValues = exports.itemCountForBatchIndex = exports.batchCalc = exports.batch = void 0;
|
|
4
4
|
const object_1 = require("./object");
|
|
5
5
|
// MARK: Functions
|
|
6
6
|
/**
|
|
@@ -19,6 +19,37 @@ function batch(array, batchSize) {
|
|
|
19
19
|
return batch;
|
|
20
20
|
}
|
|
21
21
|
exports.batch = batch;
|
|
22
|
+
/**
|
|
23
|
+
* Calculates a BatchCount given the input.
|
|
24
|
+
*
|
|
25
|
+
* @param input
|
|
26
|
+
* @returns
|
|
27
|
+
*/
|
|
28
|
+
function batchCalc(input) {
|
|
29
|
+
const { totalItems: total, itemsPerBatch: batchSize } = input;
|
|
30
|
+
const batchCount = Math.ceil(total / batchSize);
|
|
31
|
+
const remainder = total % batchSize;
|
|
32
|
+
const fullBatchCount = remainder ? batchCount - 1 : batchCount;
|
|
33
|
+
return {
|
|
34
|
+
totalItems: input.totalItems,
|
|
35
|
+
itemsPerBatch: input.itemsPerBatch,
|
|
36
|
+
batchCount,
|
|
37
|
+
fullBatchCount,
|
|
38
|
+
remainder
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
exports.batchCalc = batchCalc;
|
|
42
|
+
function itemCountForBatchIndex(index, calc) {
|
|
43
|
+
let itemCount;
|
|
44
|
+
if (index < calc.fullBatchCount) {
|
|
45
|
+
itemCount = calc.itemsPerBatch;
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
itemCount = calc.remainder;
|
|
49
|
+
}
|
|
50
|
+
return itemCount;
|
|
51
|
+
}
|
|
52
|
+
exports.itemCountForBatchIndex = itemCountForBatchIndex;
|
|
22
53
|
/**
|
|
23
54
|
* Convenience function for calling restoreOrder with two arrays of values, instead of an array of keys and array of values.
|
|
24
55
|
*
|
package/src/lib/grouping.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grouping.js","sourceRoot":"","sources":["../../../../../packages/util/src/lib/grouping.ts"],"names":[],"mappings":";;;AACA,qCAAuC;AA4CvC,kBAAkB;AAClB;;;;;;GAMG;AACH,SAAgB,KAAK,CAAI,KAAU,EAAE,SAAiB;IACpD,KAAK,GAAG,EAAE,CAAC,MAAM,CAAC,KAAW,CAAC,CAAC,CAAC,iCAAiC;IACjE,MAAM,KAAK,GAAG,EAAE,CAAC;IAEjB,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;QACvB,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC;KACxC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AATD,sBASC;AAED;;;;;;;GAOG;AACH,SAAgB,sBAAsB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IAC1C,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,QAAQ,EAAE,MAAM,CAAC,EAAE,IAAI,EAAE;QACzB,QAAQ,EAAE,MAAM,CAAC,GAAG,IAAI,EAAE;KAC3B,CAAC;AACJ,CAAC;AATD,wCASC;AAUD,SAAgB,WAAW,CAA2C,MAAW,EAAE,UAAiC;IAClH,MAAM,GAAG,GAAG,kBAAkB,CAAO,MAAM,EAAE,UAAU,CAAC,CAAC;IACzD,OAAO,IAAA,oBAAW,EAAC,GAA4B,CAAC,CAAC;AACnD,CAAC;AAHD,kCAGC;AAED;;;;;;GAMG;AACH,SAAgB,kBAAkB,CAA2C,MAAW,EAAE,UAAiC;IACzH,MAAM,GAAG,GAAG,IAAI,GAAG,EAAiB,CAAC;IAErC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;QACnB,MAAM,GAAG,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;QAC1B,MAAM,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAE3B,IAAI,KAAK,IAAI,IAAI,EAAE;YACjB,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACf;aAAM;YACL,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;SACnB;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,GAAG,CAAC;AACb,CAAC;AAfD,gDAeC"}
|
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
1
|
+
import { Factory } from './../getter/getter';
|
|
2
|
+
export declare type RandomNumberFactory = Factory<number>;
|
|
3
|
+
export interface RandomNumberFactoryConfig {
|
|
3
4
|
min?: number;
|
|
4
5
|
max: number;
|
|
5
6
|
}
|
|
6
|
-
export declare type
|
|
7
|
+
export declare type RandomNumberFactoryInput = number | RandomNumberFactoryConfig;
|
|
7
8
|
/**
|
|
8
9
|
* Used to generate a RandomNumberFunction that returns a number between the input and the maximum.
|
|
9
10
|
*
|
|
10
11
|
* @param maxOrArgs
|
|
11
12
|
* @returns
|
|
12
13
|
*/
|
|
13
|
-
export declare function
|
|
14
|
+
export declare function randomNumberFactory(maxOrArgs: RandomNumberFactoryInput): RandomNumberFactory;
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated use randomNumberFactory() instead.
|
|
17
|
+
*/
|
|
18
|
+
export declare const makeRandomFunction: typeof randomNumberFactory;
|
package/src/lib/number/random.js
CHANGED
|
@@ -1,22 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.makeRandomFunction = void 0;
|
|
3
|
+
exports.makeRandomFunction = exports.randomNumberFactory = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Used to generate a RandomNumberFunction that returns a number between the input and the maximum.
|
|
6
6
|
*
|
|
7
7
|
* @param maxOrArgs
|
|
8
8
|
* @returns
|
|
9
9
|
*/
|
|
10
|
-
function
|
|
10
|
+
function randomNumberFactory(maxOrArgs) {
|
|
11
11
|
const config = typeof maxOrArgs === 'number' ? { min: 0, max: maxOrArgs } : maxOrArgs;
|
|
12
12
|
const { min, max } = config;
|
|
13
|
+
let fn;
|
|
13
14
|
if (min != null) {
|
|
14
15
|
const range = max - min;
|
|
15
|
-
|
|
16
|
+
fn = () => Math.random() * range + min;
|
|
16
17
|
}
|
|
17
18
|
else {
|
|
18
|
-
|
|
19
|
+
fn = () => Math.random() * max;
|
|
19
20
|
}
|
|
21
|
+
return fn;
|
|
20
22
|
}
|
|
21
|
-
exports.
|
|
23
|
+
exports.randomNumberFactory = randomNumberFactory;
|
|
24
|
+
/**
|
|
25
|
+
* @deprecated use randomNumberFactory() instead.
|
|
26
|
+
*/
|
|
27
|
+
exports.makeRandomFunction = randomNumberFactory;
|
|
22
28
|
//# sourceMappingURL=random.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"random.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/number/random.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"random.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/number/random.ts"],"names":[],"mappings":";;;AAWA;;;;;GAKG;AACH,SAAgB,mBAAmB,CAAC,SAAmC;IACrE,MAAM,MAAM,GAA8B,OAAO,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;IACjH,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,MAAM,CAAC;IAC5B,IAAI,EAAuB,CAAC;IAE5B,IAAI,GAAG,IAAI,IAAI,EAAE;QACf,MAAM,KAAK,GAAG,GAAG,GAAG,GAAG,CAAC;QACxB,EAAE,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,KAAK,GAAG,GAAG,CAAC;KACxC;SAAM;QACL,EAAE,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC;KAChC;IAED,OAAO,EAAE,CAAC;AACZ,CAAC;AAbD,kDAaC;AAED;;GAEG;AACU,QAAA,kBAAkB,GAAG,mBAAmB,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BatchCount } from '../grouping';
|
|
1
2
|
import { Maybe } from '../value/maybe.type';
|
|
2
3
|
export interface PerformTaskLoopConfig<O> {
|
|
3
4
|
next: (i: number, prev: Maybe<O>) => Promise<O>;
|
|
@@ -21,8 +22,17 @@ export interface PerformTaskCountLoopWithInitConfig<O> extends Omit<PerformTaskL
|
|
|
21
22
|
export declare function performTaskCountLoop<O>(config: PerformTaskCountLoopWithInitConfig<O>): Promise<O>;
|
|
22
23
|
export declare function performTaskCountLoop<O>(config: PerformTaskCountLoopConfig<O>): Promise<Maybe<O>>;
|
|
23
24
|
export declare function performTaskCountLoop(config: PerformTaskCountLoopConfig<void>): Promise<void>;
|
|
25
|
+
export declare type PerformMakeLoopFunction<O> = (i: number, made: O[]) => Promise<O>;
|
|
24
26
|
export interface PerformMakeLoopConfig<O> {
|
|
25
|
-
make:
|
|
27
|
+
make: PerformMakeLoopFunction<O>;
|
|
26
28
|
count: number;
|
|
27
29
|
}
|
|
28
30
|
export declare function performMakeLoop<O>(config: PerformMakeLoopConfig<O>): Promise<O[]>;
|
|
31
|
+
export declare type PerformBatchLoopFunction<O> = (itemsToMake: number, i: number, made: O[][]) => Promise<O[]>;
|
|
32
|
+
export interface PerformBatchLoopConfig<O> extends BatchCount {
|
|
33
|
+
/**
|
|
34
|
+
* Makes a certain number of items.
|
|
35
|
+
*/
|
|
36
|
+
make: PerformBatchLoopFunction<O>;
|
|
37
|
+
}
|
|
38
|
+
export declare function performBatchLoop<O>(config: PerformBatchLoopConfig<O>): Promise<O[][]>;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.performMakeLoop = exports.performTaskCountLoop = exports.performTaskLoop = void 0;
|
|
3
|
+
exports.performBatchLoop = exports.performMakeLoop = exports.performTaskCountLoop = exports.performTaskLoop = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
+
const grouping_1 = require("../grouping");
|
|
5
6
|
function performTaskLoop(config) {
|
|
6
7
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
7
8
|
let result;
|
|
@@ -41,4 +42,18 @@ function performMakeLoop(config) {
|
|
|
41
42
|
});
|
|
42
43
|
}
|
|
43
44
|
exports.performMakeLoop = performMakeLoop;
|
|
45
|
+
function performBatchLoop(config) {
|
|
46
|
+
const { make } = config;
|
|
47
|
+
const calc = (0, grouping_1.batchCalc)(config);
|
|
48
|
+
const { batchCount } = calc;
|
|
49
|
+
return performMakeLoop({
|
|
50
|
+
count: batchCount,
|
|
51
|
+
make: (i, made) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
const itemsToMake = (0, grouping_1.itemCountForBatchIndex)(i, calc);
|
|
53
|
+
const batch = yield make(itemsToMake, i, made);
|
|
54
|
+
return batch;
|
|
55
|
+
})
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
exports.performBatchLoop = performBatchLoop;
|
|
44
59
|
//# sourceMappingURL=promise.loop.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"promise.loop.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/promise/promise.loop.ts"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"promise.loop.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/promise/promise.loop.ts"],"names":[],"mappings":";;;;AAAA,0CAAmF;AAmBnF,SAAsB,eAAe,CAAI,MAAmE;;QAC1G,IAAI,MAAS,CAAC;QACd,MAAM,SAAS,GAAI,MAA2C,CAAC,SAAS,CAAC;QACzE,MAAM,SAAS,GAAG,SAAS,IAAI,IAAI,IAAI,MAAM,CAAC,aAAa,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC;QAE3E,IAAI,SAAS,EAAE;YACb,IAAI,CAAC,GAAG,CAAC,CAAC;YACV,IAAI,SAAS,GAAa,SAAS,CAAC;YACpC,IAAI,KAAc,CAAC;YAEnB,GAAG;gBACD,SAAS,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;gBAC5C,CAAC,IAAI,CAAC,CAAC;gBACP,KAAK,GAAG,MAAM,CAAC,aAAa,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;aAC5C,QAAQ,KAAK,EAAE;YAEhB,MAAM,GAAG,SAAS,CAAC;SACpB;aAAM;YACL,MAAM,GAAG,SAAS,CAAC;SACpB;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CAAA;AAtBD,0CAsBC;AAcD,SAAgB,oBAAoB,CAAI,MAA6E;IACnH,OAAO,eAAe,CAAI,gCACrB,MAAM,KACT,aAAa,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,MAAM,CAAC,KAAK,GACd,CAAC,CAAC;AACjC,CAAC;AALD,oDAKC;AAUD,SAAgB,eAAe,CAAI,MAAgC;IACjE,OAAO,oBAAoB,CAAM;QAC/B,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,SAAS,EAAE,EAAS;QACpB,IAAI,EAAE,CAAO,CAAC,EAAE,WAAgB,EAAE,EAAE;YAClC,MAAM,MAAM,GAAM,MAAM,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC;YACpD,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACzB,OAAO,WAAW,CAAC;QACrB,CAAC,CAAA;KACF,CAAC,CAAC;AACL,CAAC;AAVD,0CAUC;AAYD,SAAgB,gBAAgB,CAAI,MAAiC;IACnE,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC;IACxB,MAAM,IAAI,GAAG,IAAA,oBAAS,EAAC,MAAM,CAAC,CAAC;IAC/B,MAAM,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC;IAE5B,OAAO,eAAe,CAAC;QACrB,KAAK,EAAE,UAAU;QACjB,IAAI,EAAE,CAAO,CAAC,EAAE,IAAW,EAAE,EAAE;YAC7B,MAAM,WAAW,GAAG,IAAA,iCAAsB,EAAC,CAAC,EAAE,IAAI,CAAC,CAAC;YACpD,MAAM,KAAK,GAAQ,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;YACpD,OAAO,KAAK,CAAC;QACf,CAAC,CAAA;KACF,CAAC,CAAC;AACL,CAAC;AAbD,4CAaC"}
|
package/test/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
# [7.9.0](https://github.com/dereekb/dbx-components/compare/v7.8.1-dev...v7.9.0) (2022-06-11)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
5
9
|
## [7.8.1](https://github.com/dereekb/dbx-components/compare/v7.8.0-dev...v7.8.1) (2022-06-10)
|
|
6
10
|
|
|
7
11
|
|
package/test/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/util/test",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.9.0",
|
|
4
4
|
"main": "./src/index.js",
|
|
5
5
|
"typings": "./src/index.d.ts",
|
|
6
6
|
"dependencies": {},
|
|
7
7
|
"peerDependencies": {
|
|
8
|
-
"@dereekb/util": "7.
|
|
8
|
+
"@dereekb/util": "7.9.0",
|
|
9
9
|
"make-error": "^1.3.0",
|
|
10
10
|
"ts-essentials": "^9.1.2",
|
|
11
11
|
"extra-set": "^2.2.11",
|