@dereekb/util 7.2.0 → 7.3.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 +13 -0
- package/package.json +1 -1
- package/src/lib/array/array.boolean.d.ts +1 -1
- package/src/lib/array/array.d.ts +1 -1
- package/src/lib/array/array.index.d.ts +1 -1
- package/src/lib/array/array.limit.d.ts +1 -1
- package/src/lib/array/array.map.d.ts +1 -1
- package/src/lib/array/array.string.js +1 -1
- package/src/lib/array/array.string.js.map +1 -1
- package/src/lib/array/array.unique.d.ts +1 -1
- package/src/lib/array/array.value.d.ts +14 -2
- package/src/lib/array/array.value.js +24 -6
- package/src/lib/array/array.value.js.map +1 -1
- package/src/lib/auth/auth.role.claims.d.ts +1 -1
- package/src/lib/auth/auth.role.claims.js +13 -10
- package/src/lib/auth/auth.role.claims.js.map +1 -1
- package/src/lib/auth/auth.role.d.ts +1 -1
- package/src/lib/date/date.d.ts +1 -1
- package/src/lib/date/date.time.d.ts +1 -1
- package/src/lib/error/error.d.ts +1 -1
- package/src/lib/error/error.server.d.ts +1 -1
- package/src/lib/filter/filter.d.ts +3 -0
- package/src/lib/filter/filter.js.map +1 -1
- package/src/lib/grouping.d.ts +1 -1
- package/src/lib/iterable/iterable.d.ts +8 -1
- package/src/lib/iterable/iterable.js +14 -1
- package/src/lib/iterable/iterable.js.map +1 -1
- package/src/lib/key.d.ts +1 -1
- package/src/lib/misc/host.d.ts +1 -1
- package/src/lib/model/model.conversion.d.ts +1 -1
- package/src/lib/model/model.conversion.js +7 -6
- package/src/lib/model/model.conversion.js.map +1 -1
- package/src/lib/model/model.copy.d.ts +1 -1
- package/src/lib/model/model.d.ts +1 -1
- package/src/lib/model/model.modify.d.ts +1 -1
- package/src/lib/object/index.d.ts +3 -0
- package/src/lib/object/index.js +3 -0
- package/src/lib/object/index.js.map +1 -1
- package/src/lib/object/object.d.ts +4 -112
- package/src/lib/object/object.empty.d.ts +7 -0
- package/src/lib/object/object.empty.js +27 -0
- package/src/lib/object/object.empty.js.map +1 -0
- package/src/lib/object/object.filter.pojo.d.ts +154 -0
- package/src/lib/object/object.filter.pojo.js +235 -0
- package/src/lib/object/object.filter.pojo.js.map +1 -0
- package/src/lib/object/object.filter.tuple.d.ts +64 -0
- package/src/lib/object/object.filter.tuple.js +120 -0
- package/src/lib/object/object.filter.tuple.js.map +1 -0
- package/src/lib/object/object.js +6 -224
- package/src/lib/object/object.js.map +1 -1
- package/src/lib/object/object.map.d.ts +23 -1
- package/src/lib/object/object.map.js +26 -4
- package/src/lib/object/object.map.js.map +1 -1
- package/src/lib/page/page.d.ts +1 -1
- package/src/lib/promise/promise.d.ts +1 -1
- package/src/lib/promise/promise.loop.d.ts +1 -1
- package/src/lib/relation/relation.d.ts +8 -7
- package/src/lib/relation/relation.js +2 -1
- package/src/lib/relation/relation.js.map +1 -1
- package/src/lib/service/typed.service.js +2 -2
- package/src/lib/service/typed.service.js.map +1 -1
- package/src/lib/set/set.allowed.d.ts +1 -1
- package/src/lib/set/set.d.ts +1 -1
- package/src/lib/set/set.hashset.d.ts +1 -1
- package/src/lib/set/set.maybe.d.ts +1 -1
- package/src/lib/storage/storage.memory.d.ts +1 -1
- package/src/lib/storage/storage.object.d.ts +1 -1
- package/src/lib/storage/storage.object.js +4 -3
- package/src/lib/storage/storage.object.js.map +1 -1
- package/src/lib/string.d.ts +1 -1
- package/src/lib/tree/tree.expand.d.ts +1 -1
- package/src/lib/value/index.d.ts +1 -0
- package/src/lib/value/index.js +1 -0
- package/src/lib/value/index.js.map +1 -1
- package/src/lib/value/map.d.ts +1 -1
- package/src/lib/value/maybe.d.ts +16 -41
- package/src/lib/value/maybe.js +57 -4
- package/src/lib/value/maybe.js.map +1 -1
- package/src/lib/value/maybe.type.d.ts +19 -0
- package/src/lib/value/maybe.type.js +3 -0
- package/src/lib/value/maybe.type.js.map +1 -0
- package/src/lib/value/modifier.d.ts +1 -1
- package/test/CHANGELOG.md +4 -0
- package/test/package.json +2 -2
package/src/lib/value/maybe.d.ts
CHANGED
|
@@ -1,62 +1,40 @@
|
|
|
1
|
-
import {
|
|
2
|
-
/**
|
|
3
|
-
* A null/undefined value.
|
|
4
|
-
*/
|
|
5
|
-
export declare type MaybeNot = null | undefined;
|
|
6
|
-
/**
|
|
7
|
-
* A non-null/undefined value.
|
|
8
|
-
*/
|
|
9
|
-
export declare type MaybeSo<T = unknown> = T extends MaybeNot ? never : T;
|
|
10
|
-
/**
|
|
11
|
-
* A value that might exist, or be null/undefined instead.
|
|
12
|
-
*/
|
|
13
|
-
export declare type Maybe<T> = T | MaybeNot;
|
|
14
|
-
/**
|
|
15
|
-
* Turns all key values in an object into a Maybe value.
|
|
16
|
-
*/
|
|
17
|
-
export declare type MaybeMap<T extends object> = NonNever<{
|
|
18
|
-
[K in keyof T]: T[K] extends MaybeNot ? never : Maybe<T[K]>;
|
|
19
|
-
}>;
|
|
1
|
+
import { Maybe, MaybeNot, MaybeSo } from './maybe.type';
|
|
20
2
|
/**
|
|
21
3
|
* Returns true if the value is not null or undefined.
|
|
22
4
|
*
|
|
23
5
|
* @param value
|
|
24
6
|
* @returns
|
|
25
7
|
*/
|
|
26
|
-
export declare function hasNonNullValue<T>(value: Maybe<T>): value is T
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
8
|
+
export declare function hasNonNullValue<T = unknown>(value: Maybe<T>): value is MaybeSo<T>;
|
|
9
|
+
/**
|
|
10
|
+
* Whether or not the input has any value.
|
|
11
|
+
*
|
|
12
|
+
* Will return false for:
|
|
13
|
+
* - empty iterables
|
|
14
|
+
* - empty strings
|
|
15
|
+
* - null/undefined values.
|
|
16
|
+
*
|
|
17
|
+
* NaN has undefined behavior.
|
|
18
|
+
*/
|
|
19
|
+
export declare function hasValueOrNotEmpty<T = unknown>(value: Maybe<T>): value is MaybeSo<T>;
|
|
33
20
|
/**
|
|
34
21
|
* Whether or not the input has any value.
|
|
35
22
|
*
|
|
36
23
|
* Will return false for:
|
|
37
|
-
* - empty
|
|
24
|
+
* - empty iterables
|
|
38
25
|
* - empty strings
|
|
26
|
+
* - empty objects (no keys)
|
|
39
27
|
* - null/undefined values.
|
|
40
28
|
*
|
|
41
29
|
* NaN has undefined behavior.
|
|
42
30
|
*/
|
|
43
|
-
export declare function
|
|
44
|
-
export declare function hasValueOrNotEmpty(value: true): true;
|
|
45
|
-
export declare function hasValueOrNotEmpty(value: false): true;
|
|
46
|
-
export declare function hasValueOrNotEmpty(value: number): true;
|
|
47
|
-
export declare function hasValueOrNotEmpty(value: ''): false;
|
|
48
|
-
export declare function hasValueOrNotEmpty(value: null): false;
|
|
49
|
-
export declare function hasValueOrNotEmpty(value: undefined): false;
|
|
31
|
+
export declare function hasValueOrNotEmptyObject<T = unknown>(value: Maybe<T>): value is MaybeSo<T>;
|
|
50
32
|
/**
|
|
51
33
|
* Returns true if the input value is a non-empty string or is true.
|
|
52
34
|
*
|
|
53
35
|
* @param value
|
|
54
36
|
* @returns
|
|
55
37
|
*/
|
|
56
|
-
export declare function isStringOrTrue(value: ''): false;
|
|
57
|
-
export declare function isStringOrTrue(value: false): false;
|
|
58
|
-
export declare function isStringOrTrue(value: null): false;
|
|
59
|
-
export declare function isStringOrTrue(value: undefined): false;
|
|
60
38
|
export declare function isStringOrTrue(value: Maybe<string | boolean>): boolean;
|
|
61
39
|
/**
|
|
62
40
|
* Returns true if the input is not MaybeNot and not an empty string.
|
|
@@ -64,9 +42,6 @@ export declare function isStringOrTrue(value: Maybe<string | boolean>): boolean;
|
|
|
64
42
|
* @param value
|
|
65
43
|
* @returns
|
|
66
44
|
*/
|
|
67
|
-
export declare function isNotNullOrEmptyString<T>(value: ''): false;
|
|
68
|
-
export declare function isNotNullOrEmptyString<T>(value: null): false;
|
|
69
|
-
export declare function isNotNullOrEmptyString<T>(value: undefined): false;
|
|
70
45
|
export declare function isNotNullOrEmptyString<T>(value: Maybe<MaybeNot | '' | T>): value is MaybeSo<T>;
|
|
71
46
|
/**
|
|
72
47
|
* True if the input is MaybeNot.
|
package/src/lib/value/maybe.js
CHANGED
|
@@ -1,23 +1,76 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isSameNonNullValue = exports.isDefinedAndNotFalse = exports.isMaybeNotOrTrue = exports.isMaybeSo = exports.isMaybeNot = exports.isNotNullOrEmptyString = exports.isStringOrTrue = exports.hasValueOrNotEmpty = exports.hasNonNullValue = void 0;
|
|
3
|
+
exports.isSameNonNullValue = exports.isDefinedAndNotFalse = exports.isMaybeNotOrTrue = exports.isMaybeSo = exports.isMaybeNot = exports.isNotNullOrEmptyString = exports.isStringOrTrue = exports.hasValueOrNotEmptyObject = exports.hasValueOrNotEmpty = exports.hasNonNullValue = void 0;
|
|
4
|
+
const iterable_1 = require("../iterable/iterable");
|
|
5
|
+
const object_1 = require("../object/object");
|
|
6
|
+
/**
|
|
7
|
+
* Returns true if the value is not null or undefined.
|
|
8
|
+
*
|
|
9
|
+
* @param value
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
4
12
|
function hasNonNullValue(value) {
|
|
5
13
|
return value != null;
|
|
6
14
|
}
|
|
7
15
|
exports.hasNonNullValue = hasNonNullValue;
|
|
16
|
+
/**
|
|
17
|
+
* Whether or not the input has any value.
|
|
18
|
+
*
|
|
19
|
+
* Will return false for:
|
|
20
|
+
* - empty iterables
|
|
21
|
+
* - empty strings
|
|
22
|
+
* - null/undefined values.
|
|
23
|
+
*
|
|
24
|
+
* NaN has undefined behavior.
|
|
25
|
+
*/
|
|
8
26
|
function hasValueOrNotEmpty(value) {
|
|
9
|
-
if (
|
|
10
|
-
return value
|
|
27
|
+
if ((0, iterable_1.isIterable)(value, true)) {
|
|
28
|
+
return !(0, iterable_1.isEmptyIterable)(value);
|
|
11
29
|
}
|
|
12
30
|
else {
|
|
13
|
-
return value
|
|
31
|
+
return isNotNullOrEmptyString(value);
|
|
14
32
|
}
|
|
15
33
|
}
|
|
16
34
|
exports.hasValueOrNotEmpty = hasValueOrNotEmpty;
|
|
35
|
+
/**
|
|
36
|
+
* Whether or not the input has any value.
|
|
37
|
+
*
|
|
38
|
+
* Will return false for:
|
|
39
|
+
* - empty iterables
|
|
40
|
+
* - empty strings
|
|
41
|
+
* - empty objects (no keys)
|
|
42
|
+
* - null/undefined values.
|
|
43
|
+
*
|
|
44
|
+
* NaN has undefined behavior.
|
|
45
|
+
*/
|
|
46
|
+
function hasValueOrNotEmptyObject(value) {
|
|
47
|
+
if ((0, iterable_1.isIterable)(value, true)) {
|
|
48
|
+
return !(0, iterable_1.isEmptyIterable)(value);
|
|
49
|
+
}
|
|
50
|
+
else if (isNotNullOrEmptyString(value)) {
|
|
51
|
+
return typeof value === 'object' ? !(0, object_1.objectHasNoKeys)(value) : true;
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.hasValueOrNotEmptyObject = hasValueOrNotEmptyObject;
|
|
58
|
+
/**
|
|
59
|
+
* Returns true if the input value is a non-empty string or is true.
|
|
60
|
+
*
|
|
61
|
+
* @param value
|
|
62
|
+
* @returns
|
|
63
|
+
*/
|
|
17
64
|
function isStringOrTrue(value) {
|
|
18
65
|
return Boolean(value || value !== '');
|
|
19
66
|
}
|
|
20
67
|
exports.isStringOrTrue = isStringOrTrue;
|
|
68
|
+
/**
|
|
69
|
+
* Returns true if the input is not MaybeNot and not an empty string.
|
|
70
|
+
*
|
|
71
|
+
* @param value
|
|
72
|
+
* @returns
|
|
73
|
+
*/
|
|
21
74
|
function isNotNullOrEmptyString(value) {
|
|
22
75
|
return value != null && value !== '';
|
|
23
76
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"maybe.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/value/maybe.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"maybe.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AAC;AAFD,gCAEC;AAED;;;;;GAKG;AACH,SAAgB,SAAS,CAAI,KAAe;IAC1C,OAAO,KAAK,IAAI,IAAI,CAAC;AACvB,CAAC;AAFD,8BAEC;AAED;;;;;GAKG;AACH,SAAgB,gBAAgB,CAAC,KAAc;IAC7C,OAAO,KAAK,IAAI,IAAI,IAAI,KAAK,KAAK,IAAI,CAAC;AACzC,CAAC;AAFD,4CAEC;AAED;;;;;GAKG;AACH,SAAgB,oBAAoB,CAAC,KAAc;IACjD,OAAO,KAAK,IAAI,IAAI,IAAI,KAAK,KAAK,KAAK,CAAC;AAC1C,CAAC;AAFD,oDAEC;AAED;;;;;;GAMG;AACH,SAAgB,kBAAkB,CAAI,CAAW,EAAE,CAAW;IAC5D,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC;AAC9B,CAAC;AAFD,gDAEC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { NonNever } from 'ts-essentials';
|
|
2
|
+
/**
|
|
3
|
+
* A null/undefined value.
|
|
4
|
+
*/
|
|
5
|
+
export declare type MaybeNot = null | undefined;
|
|
6
|
+
/**
|
|
7
|
+
* A non-null/undefined value.
|
|
8
|
+
*/
|
|
9
|
+
export declare type MaybeSo<T = unknown> = T extends MaybeNot ? never : T;
|
|
10
|
+
/**
|
|
11
|
+
* A value that might exist, or be null/undefined instead.
|
|
12
|
+
*/
|
|
13
|
+
export declare type Maybe<T> = T | MaybeNot;
|
|
14
|
+
/**
|
|
15
|
+
* Turns all key values in an object into a Maybe value.
|
|
16
|
+
*/
|
|
17
|
+
export declare type MaybeMap<T extends object> = NonNever<{
|
|
18
|
+
[K in keyof T]: T[K] extends MaybeNot ? never : Maybe<T[K]>;
|
|
19
|
+
}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"maybe.type.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/value/maybe.type.ts"],"names":[],"mappings":""}
|
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.3.0](https://github.com/dereekb/dbx-components/compare/v7.2.0-dev...v7.3.0) (2022-06-08)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
5
9
|
# [7.2.0](https://github.com/dereekb/dbx-components/compare/v7.1.0-dev...v7.2.0) (2022-06-06)
|
|
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.3.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.3.0",
|
|
9
9
|
"make-error": "^1.3.0",
|
|
10
10
|
"ts-essentials": "^9.1.2",
|
|
11
11
|
"extra-set": "^2.2.11",
|