@dereekb/util 8.12.0 → 8.12.1
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 +4 -0
- package/package.json +1 -1
- package/src/lib/getter/getter.d.ts +20 -0
- package/src/lib/getter/getter.js +29 -1
- package/src/lib/getter/getter.js.map +1 -1
- package/src/lib/model/model.conversion.d.ts +2 -2
- package/src/lib/object/object.d.ts +3 -0
- package/src/lib/object/object.js.map +1 -1
- package/test/CHANGELOG.md +4 -0
- package/test/package.json +2 -2
package/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
|
+
## [8.12.1](https://github.com/dereekb/dbx-components/compare/v8.12.0-dev...v8.12.1) (2022-07-08)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
5
9
|
# [8.12.0](https://github.com/dereekb/dbx-components/compare/v8.11.2-dev...v8.12.0) (2022-07-07)
|
|
6
10
|
|
|
7
11
|
|
package/package.json
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CopyObjectFunction } from '../object';
|
|
1
2
|
import { PromiseOrValue } from '../promise/promise';
|
|
2
3
|
import { MapFunction } from '../value/map';
|
|
3
4
|
import { Maybe } from '../value/maybe.type';
|
|
@@ -59,6 +60,25 @@ export declare function getValueFromGetter<T extends string | number | object |
|
|
|
59
60
|
* @returns
|
|
60
61
|
*/
|
|
61
62
|
export declare function asGetter<T>(input: GetterOrValue<T>): Getter<T>;
|
|
63
|
+
/**
|
|
64
|
+
* A factory that returns a copy of a value.
|
|
65
|
+
*/
|
|
66
|
+
export declare type ObjectCopyFactory<T> = Factory<T>;
|
|
67
|
+
/**
|
|
68
|
+
* Creates a getter from the input value that returns a copy of that value.
|
|
69
|
+
*
|
|
70
|
+
* @param value
|
|
71
|
+
*/
|
|
72
|
+
export declare function objectCopyFactory<T extends object>(value: T, copyFunction?: CopyObjectFunction<T>): ObjectCopyFactory<T>;
|
|
73
|
+
/**
|
|
74
|
+
* Returns a getter that will copy any input object values to a new object.
|
|
75
|
+
*
|
|
76
|
+
* Any input Getters are considered ObjectCopyFactory values and passed through directly.
|
|
77
|
+
*
|
|
78
|
+
* @param input
|
|
79
|
+
* @returns
|
|
80
|
+
*/
|
|
81
|
+
export declare function asObjectCopyFactory<T>(input: T | ObjectCopyFactory<T>, copyFunction?: CopyObjectFunction<T>): ObjectCopyFactory<T>;
|
|
62
82
|
/**
|
|
63
83
|
* Wraps the input and returns a Getter for that value.
|
|
64
84
|
*
|
package/src/lib/getter/getter.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.makeWithFactoryInput = exports.makeWithFactory = exports.makeGetter = exports.asGetter = exports.getValueFromGetter = exports.isGetter = void 0;
|
|
3
|
+
exports.makeWithFactoryInput = exports.makeWithFactory = exports.makeGetter = exports.asObjectCopyFactory = exports.objectCopyFactory = exports.asGetter = exports.getValueFromGetter = exports.isGetter = void 0;
|
|
4
|
+
const object_1 = require("../object");
|
|
4
5
|
/**
|
|
5
6
|
* Returns true if the input object looks like a Getter (is a function).
|
|
6
7
|
*
|
|
@@ -35,6 +36,33 @@ function asGetter(input) {
|
|
|
35
36
|
}
|
|
36
37
|
}
|
|
37
38
|
exports.asGetter = asGetter;
|
|
39
|
+
/**
|
|
40
|
+
* Creates a getter from the input value that returns a copy of that value.
|
|
41
|
+
*
|
|
42
|
+
* @param value
|
|
43
|
+
*/
|
|
44
|
+
function objectCopyFactory(value, copyFunction = object_1.copyObject) {
|
|
45
|
+
return () => copyFunction(value);
|
|
46
|
+
}
|
|
47
|
+
exports.objectCopyFactory = objectCopyFactory;
|
|
48
|
+
/**
|
|
49
|
+
* Returns a getter that will copy any input object values to a new object.
|
|
50
|
+
*
|
|
51
|
+
* Any input Getters are considered ObjectCopyFactory values and passed through directly.
|
|
52
|
+
*
|
|
53
|
+
* @param input
|
|
54
|
+
* @returns
|
|
55
|
+
*/
|
|
56
|
+
function asObjectCopyFactory(input, copyFunction) {
|
|
57
|
+
if (typeof input === 'object') {
|
|
58
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
59
|
+
return objectCopyFactory(input, copyFunction);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
return asGetter(input);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.asObjectCopyFactory = asObjectCopyFactory;
|
|
38
66
|
/**
|
|
39
67
|
* Wraps the input and returns a Getter for that value.
|
|
40
68
|
*
|
|
@@ -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":";;;AAAA,sCAA2D;AA+C3D;;;;;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;AAOD;;;;GAIG;AACH,SAAgB,iBAAiB,CAAmB,KAAQ,EAAE,eAAsC,mBAAU;IAC5G,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;AACnC,CAAC;AAFD,8CAEC;AAED;;;;;;;GAOG;AACH,SAAgB,mBAAmB,CAAI,KAA+B,EAAE,YAAoC;IAC1G,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC7B,8DAA8D;QAC9D,OAAO,iBAAiB,CAAM,KAAK,EAAE,YAAY,CAAC,CAAC;KACpD;SAAM;QACL,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAC;KACxB;AACH,CAAC;AAPD,kDAOC;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"}
|
|
@@ -111,8 +111,8 @@ export declare type ToModelFieldConversionsInput<T extends object, O extends obj
|
|
|
111
111
|
* @returns
|
|
112
112
|
*/
|
|
113
113
|
export declare function toModelFieldConversions<T extends object, O extends object>(input: ToModelFieldConversionsInput<T, O>): Required<{ [K in keyof T]: ModelFieldMapFunctions<T[K], ReplaceType<T, O, any>[K]>; }>;
|
|
114
|
-
export declare type
|
|
114
|
+
export declare type ModelMapFunctionsRef<T extends object, O extends object> = {
|
|
115
115
|
readonly mapFunctions: ModelMapFunctions<T, O>;
|
|
116
116
|
};
|
|
117
|
-
export declare type ToModelMapFunctionsInput<T extends object, O extends object> = ToModelFieldConversionsInput<T, O> |
|
|
117
|
+
export declare type ToModelMapFunctionsInput<T extends object, O extends object> = ToModelFieldConversionsInput<T, O> | ModelMapFunctionsRef<T, O>;
|
|
118
118
|
export declare function toModelMapFunctions<T extends object, O extends object>(input: ToModelMapFunctionsInput<T, O>): ModelMapFunctions<T, O>;
|
|
@@ -9,6 +9,9 @@ export declare function applyToMultipleFields<T extends object, X = unknown>(val
|
|
|
9
9
|
export declare function mapToObject<T, K extends PropertyKey>(map: Map<K, T>): {
|
|
10
10
|
[key: PropertyKey]: T;
|
|
11
11
|
};
|
|
12
|
+
/**
|
|
13
|
+
* Returns a copy of the input object.
|
|
14
|
+
*/
|
|
12
15
|
export declare type CopyObjectFunction<T> = (input: T) => T;
|
|
13
16
|
/**
|
|
14
17
|
* Creates a shallow copy of an object using the spread operator.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/object/object.ts"],"names":[],"mappings":";;;AAIA,SAAgB,eAAe,CAAC,GAAW;IACzC,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC;AACvC,CAAC;AAFD,0CAEC;AAID,SAAgB,YAAY,CAAI,GAAM,EAAE,GAAW;IACjD,OAAO,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AACxD,CAAC;AAFD,oCAEC;AAED,SAAgB,qBAAqB,CAAgC,KAAQ,EAAE,MAAwB;IACrG,MAAM,MAAM,GAAG,EAA2B,CAAC;IAE3C,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;QACvB,MAAM,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC;IACxB,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC;AARD,sDAQC;AAED,SAAgB,WAAW,CAA2B,GAAc;IAClE,MAAM,MAAM,GAAG,EAA+B,CAAC;IAE/C,GAAG,CAAC,OAAO,CAAC,CAAC,CAAI,EAAE,GAAM,EAAE,EAAE;QAC3B,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC;AARD,kCAQC;
|
|
1
|
+
{"version":3,"file":"object.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/object/object.ts"],"names":[],"mappings":";;;AAIA,SAAgB,eAAe,CAAC,GAAW;IACzC,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC;AACvC,CAAC;AAFD,0CAEC;AAID,SAAgB,YAAY,CAAI,GAAM,EAAE,GAAW;IACjD,OAAO,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AACxD,CAAC;AAFD,oCAEC;AAED,SAAgB,qBAAqB,CAAgC,KAAQ,EAAE,MAAwB;IACrG,MAAM,MAAM,GAAG,EAA2B,CAAC;IAE3C,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;QACvB,MAAM,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC;IACxB,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC;AARD,sDAQC;AAED,SAAgB,WAAW,CAA2B,GAAc;IAClE,MAAM,MAAM,GAAG,EAA+B,CAAC;IAE/C,GAAG,CAAC,OAAO,CAAC,CAAC,CAAI,EAAE,GAAM,EAAE,EAAE;QAC3B,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC;AARD,kCAQC;AAOD;;;;;GAKG;AACH,SAAgB,UAAU,CAAmB,KAAQ;IACnD,yBAAY,KAAK,EAAG;AACtB,CAAC;AAFD,gCAEC"}
|
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
|
+
## [8.12.1](https://github.com/dereekb/dbx-components/compare/v8.12.0-dev...v8.12.1) (2022-07-08)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
5
9
|
# [8.12.0](https://github.com/dereekb/dbx-components/compare/v8.11.2-dev...v8.12.0) (2022-07-07)
|
|
6
10
|
|
|
7
11
|
|
package/test/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/util/test",
|
|
3
|
-
"version": "8.12.
|
|
3
|
+
"version": "8.12.1",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"typings": "./src/index.d.ts",
|
|
7
7
|
"dependencies": {},
|
|
8
8
|
"peerDependencies": {
|
|
9
|
-
"@dereekb/util": "8.12.
|
|
9
|
+
"@dereekb/util": "8.12.1",
|
|
10
10
|
"make-error": "^1.3.0",
|
|
11
11
|
"ts-essentials": "^9.1.2",
|
|
12
12
|
"extra-set": "^2.2.11",
|