type-plus 4.4.1 → 4.5.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/README.md +1 -0
- package/cjs/ComposableTypes.d.ts +0 -6
- package/cjs/JSONTypes.js +0 -1
- package/cjs/JSONTypes.js.map +1 -1
- package/cjs/UnionKeys.d.ts +0 -4
- package/cjs/array/CommonPropKeys.d.ts +0 -7
- package/cjs/array/CreateTuple.d.ts +0 -3
- package/cjs/array/Filter.d.ts +1 -1
- package/cjs/array/FindFirst.d.ts +0 -3
- package/cjs/array/IntersectOfProps.d.ts +0 -7
- package/cjs/array/Last.d.ts +0 -3
- package/cjs/array/Tail.d.ts +0 -3
- package/cjs/array/UnionOfProps.d.ts +0 -7
- package/cjs/array/UnionOfValues.d.ts +0 -7
- package/cjs/assertion/assertType.d.ts +0 -4
- package/cjs/assertion/assertType.js +0 -8
- package/cjs/assertion/assertType.js.map +1 -1
- package/cjs/functional/ChainFn.d.ts +0 -3
- package/cjs/functional/compose.d.ts +0 -3
- package/cjs/functional/compose.js +0 -3
- package/cjs/functional/compose.js.map +1 -1
- package/cjs/index.js +0 -2
- package/cjs/index.js.map +1 -1
- package/cjs/math/Add.d.ts +0 -6
- package/cjs/math/Digit.d.ts +0 -3
- package/cjs/math/IsPositive.d.ts +0 -5
- package/cjs/math/IsWhole.d.ts +0 -5
- package/cjs/math/Subtract.d.ts +0 -3
- package/cjs/nodejs/isNodeError.d.ts +0 -5
- package/cjs/nodejs/isNodeError.js +0 -5
- package/cjs/nodejs/isNodeError.js.map +1 -1
- package/cjs/nominal-types/Brand.d.ts +0 -10
- package/cjs/nominal-types/Brand.js +0 -3
- package/cjs/nominal-types/Brand.js.map +1 -1
- package/cjs/nominal-types/Flavor.d.ts +0 -12
- package/cjs/nominal-types/Flavor.js +0 -3
- package/cjs/nominal-types/Flavor.js.map +1 -1
- package/cjs/object/ExcludePropType.d.ts +0 -3
- package/cjs/object/IsDisjoint.d.ts +0 -4
- package/cjs/object/KeyTypes.d.ts +0 -5
- package/cjs/object/KeyofOptional.d.ts +0 -3
- package/cjs/object/KnownKeys.js +0 -3
- package/cjs/object/KnownKeys.js.map +1 -1
- package/cjs/object/Partial.d.ts +0 -9
- package/cjs/object/RecursiveIntersect.d.ts +0 -11
- package/cjs/object/Required.js +0 -1
- package/cjs/object/Required.js.map +1 -1
- package/cjs/object/facade.d.ts +0 -3
- package/cjs/object/facade.js +0 -3
- package/cjs/object/facade.js.map +1 -1
- package/cjs/object/index.d.ts +1 -0
- package/cjs/object/index.js +1 -0
- package/cjs/object/index.js.map +1 -1
- package/cjs/object/mapProperties.d.ts +0 -8
- package/cjs/object/mapProperties.js +0 -8
- package/cjs/object/mapProperties.js.map +1 -1
- package/cjs/object/omit.d.ts +0 -3
- package/cjs/object/pick.d.ts +0 -7
- package/cjs/object/record.d.ts +3 -0
- package/cjs/object/record.js +9 -0
- package/cjs/object/record.js.map +1 -0
- package/cjs/object/reduceKey.d.ts +0 -3
- package/cjs/object/reduceKey.js +0 -3
- package/cjs/object/reduceKey.js.map +1 -1
- package/cjs/object/split.d.ts +0 -4
- package/cjs/predicates/CanAssign.d.ts +0 -3
- package/cjs/predicates/Equal.d.ts +0 -6
- package/cjs/predicates/isType.js +0 -6
- package/cjs/predicates/isType.js.map +1 -1
- package/cjs/promise/PromiseValue.d.ts +0 -3
- package/cjs/promise/PromiseValueMerge.d.ts +0 -3
- package/cjs/promise/isPromise.js +0 -1
- package/cjs/promise/isPromise.js.map +1 -1
- package/cjs/testing/stub.d.ts +4 -2
- package/cjs/testing/stub.js.map +1 -1
- package/cjs/utils/Widen.d.ts +0 -4
- package/esm/JSONTypes.js +0 -1
- package/esm/JSONTypes.js.map +1 -1
- package/esm/assertion/assertType.js +0 -8
- package/esm/assertion/assertType.js.map +1 -1
- package/esm/functional/compose.js +0 -3
- package/esm/functional/compose.js.map +1 -1
- package/esm/index.js +0 -2
- package/esm/index.js.map +1 -1
- package/esm/nodejs/isNodeError.js +0 -5
- package/esm/nodejs/isNodeError.js.map +1 -1
- package/esm/nominal-types/Brand.js +0 -3
- package/esm/nominal-types/Brand.js.map +1 -1
- package/esm/nominal-types/Flavor.js +0 -3
- package/esm/nominal-types/Flavor.js.map +1 -1
- package/esm/object/KnownKeys.js +0 -3
- package/esm/object/KnownKeys.js.map +1 -1
- package/esm/object/Required.js +0 -1
- package/esm/object/Required.js.map +1 -1
- package/esm/object/facade.js +0 -3
- package/esm/object/facade.js.map +1 -1
- package/esm/object/index.js +1 -0
- package/esm/object/index.js.map +1 -1
- package/esm/object/mapProperties.js +0 -8
- package/esm/object/mapProperties.js.map +1 -1
- package/esm/object/record.js +5 -0
- package/esm/object/record.js.map +1 -0
- package/esm/object/reduceKey.js +0 -3
- package/esm/object/reduceKey.js.map +1 -1
- package/esm/predicates/isType.js +0 -6
- package/esm/predicates/isType.js.map +1 -1
- package/esm/promise/isPromise.js +0 -1
- package/esm/promise/isPromise.js.map +1 -1
- package/esm/testing/stub.js.map +1 -1
- package/package.json +1 -1
- package/ts/array/Filter.spec.ts +54 -21
- package/ts/array/Filter.ts +17 -12
- package/ts/object/index.ts +1 -0
- package/ts/object/record.spec.ts +54 -0
- package/ts/object/record.ts +10 -0
- package/ts/testing/stub.ts +4 -2
package/README.md
CHANGED
|
@@ -429,6 +429,7 @@ So you may encounter some weird behavior if your logic is complex.
|
|
|
429
429
|
- `isSystemError(code, err)`: type guard `err` with Nodejs error code.
|
|
430
430
|
- `omit(obj, ...props)`: omit properties from `obj`.
|
|
431
431
|
- `pick(obj, ...props)`: pick properties from `obj`.
|
|
432
|
+
- `record<K, V>(value?)`: create a `Record<K, V>` without extra object prototype.
|
|
432
433
|
- `required(...)`: merge options and removing `Partial<T>`. From [`unpartial`](https://github.com/unional/unpartial)
|
|
433
434
|
- `requiredDeep(...)`: merge options deeply and removing `Partial<T>`. From [`unpartial`](https://github.com/unional/unpartial)
|
|
434
435
|
- `split(target, ...splitters)`: split one object into multiple objects.
|
package/cjs/ComposableTypes.d.ts
CHANGED
|
@@ -1,8 +1,2 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Types that can contain custom properties.
|
|
3
|
-
*/
|
|
4
1
|
export declare type ComposableTypes = object | Function;
|
|
5
|
-
/**
|
|
6
|
-
* Types that cannot contain custom properties.
|
|
7
|
-
*/
|
|
8
2
|
export declare type NonComposableTypes = boolean | number | string | symbol | bigint | undefined | null;
|
package/cjs/JSONTypes.js
CHANGED
package/cjs/JSONTypes.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JSONTypes.js","sourceRoot":"","sources":["../ts/JSONTypes.ts"],"names":[],"mappings":";;;;;;;;;;;;AASa,QAAA,SAAS,GAAG,EAAE,GAAG,KAAA,EAAE,CAAA;AAEhC,SAAS,GAAG,CAAsB,GAAc;IAAE,eAAgC;SAAhC,UAAgC,EAAhC,qBAAgC,EAAhC,IAAgC;QAAhC,8BAAgC;;IAChF,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,GAAQ,CAAA;IACvC,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI;QAAE,OAAO,SAAS,CAAA;IAC7D,IAAM,CAAC,GAAG,KAAK,CAAC,KAAK,EAAG,CAAA;
|
|
1
|
+
{"version":3,"file":"JSONTypes.js","sourceRoot":"","sources":["../ts/JSONTypes.ts"],"names":[],"mappings":";;;;;;;;;;;;AASa,QAAA,SAAS,GAAG,EAAE,GAAG,KAAA,EAAE,CAAA;AAEhC,SAAS,GAAG,CAAsB,GAAc;IAAE,eAAgC;SAAhC,UAAgC,EAAhC,qBAAgC,EAAhC,IAAgC;QAAhC,8BAAgC;;IAChF,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,GAAQ,CAAA;IACvC,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI;QAAE,OAAO,SAAS,CAAA;IAC7D,IAAM,CAAC,GAAG,KAAK,CAAC,KAAK,EAAG,CAAA;IAExB,OAAO,GAAG,8BAAC,GAAG,CAAC,CAAC,CAAC,GAAK,KAAK,SAAM,CAAA;AACnC,CAAC"}
|
package/cjs/UnionKeys.d.ts
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
1
|
import { Tail } from './Tail';
|
|
2
|
-
/**
|
|
3
|
-
* Gets the common property keys of the elements in `A`.
|
|
4
|
-
*/
|
|
5
2
|
export declare type CommonPropKeys<A extends Record<string, unknown>[]> = A['length'] extends 0 ? never : (A['length'] extends 1 ? keyof A[0] : (A['length'] extends 2 ? keyof A[0] & keyof A[1] : keyof A[0] & keyof A[1] & CommonPropKeys<Tail<Tail<A>>>));
|
|
6
|
-
/**
|
|
7
|
-
* Gets the common property keys of the elements in `A`.
|
|
8
|
-
* This will be deprecated in 4.0. Please use CommonPropKeys instead.
|
|
9
|
-
*/
|
|
10
3
|
export declare type CommonKeys<A extends Record<string, any>[]> = CommonPropKeys<A>;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import type { IsPositive } from '../math';
|
|
2
|
-
/**
|
|
3
|
-
* Creates `Tuple<T>` with `L` number of elements.
|
|
4
|
-
*/
|
|
5
2
|
export declare type CreateTuple<L extends number, T = any> = IsPositive<L> extends true ? CreateTuple.Device<[], L, T> : never;
|
|
6
3
|
export declare namespace CreateTuple {
|
|
7
4
|
type Device<R extends any[], L extends number, T> = R['length'] extends L ? R : Device<[T, ...R], L, T>;
|
package/cjs/array/Filter.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare type Filter<A extends Array<any>, Criteria> = number extends A['length'] ? (A[0] extends Criteria ? A : never[]) : (A['length'] extends 0 ? never : (A extends [infer Head, ...infer Tail] ? (Tail['length'] extends 0 ? (Head extends Criteria ? [Head] : never[]) : (Head extends Criteria ? [Head, ...Filter<Tail, Criteria>] : Filter<Tail, Criteria>)) : never));
|
|
1
|
+
export declare type Filter<A extends Array<any>, Criteria> = number extends A['length'] ? (A[0] extends Criteria ? A : (Criteria extends A[0] ? Array<Criteria> : never[])) : (A['length'] extends 0 ? never : (A extends [infer Head, ...infer Tail] ? (Tail['length'] extends 0 ? (Head extends Criteria ? [Head] : never[]) : (Head extends Criteria ? [Head, ...Filter<Tail, Criteria>] : Filter<Tail, Criteria>)) : never));
|
package/cjs/array/FindFirst.d.ts
CHANGED
|
@@ -1,5 +1,2 @@
|
|
|
1
1
|
export declare type FindFirst<A extends Array<any>, Criteria> = (number extends A['length'] ? A[0] extends Criteria ? A[0] : never : (A['length'] extends 0 ? never : (A extends [any, ...infer Tail] ? A[0] extends Criteria ? A[0] : FindFirst<Tail, Criteria> : never)));
|
|
2
|
-
/**
|
|
3
|
-
* @deprecated use FindFirst
|
|
4
|
-
*/
|
|
5
2
|
export declare type First<A extends any[], Criteria> = FindFirst<A, Criteria>;
|
|
@@ -1,11 +1,4 @@
|
|
|
1
1
|
import { KeyTypes } from '../object';
|
|
2
2
|
import { Tail } from './Tail';
|
|
3
|
-
/**
|
|
4
|
-
* Gets the intersect of properties of the elements in `A`
|
|
5
|
-
*/
|
|
6
3
|
export declare type IntersectOfProps<A extends Record<any, unknown>[], P extends KeyTypes> = A['length'] extends 0 ? never : (A['length'] extends 1 ? A[0][P] : A[0][P] & IntersectOfProps<Tail<A>, P>);
|
|
7
|
-
/**
|
|
8
|
-
* Gets the intersect of properties of the elements in `A`
|
|
9
|
-
* This will be deprecated in 4.0. Please use IntersectOfProps instead.
|
|
10
|
-
*/
|
|
11
4
|
export declare type MapToProp<A extends Record<any, any>[], P extends KeyTypes> = IntersectOfProps<A, P>;
|
package/cjs/array/Last.d.ts
CHANGED
package/cjs/array/Tail.d.ts
CHANGED
|
@@ -1,5 +1,2 @@
|
|
|
1
1
|
import { UnionOfValues } from './UnionOfValues';
|
|
2
|
-
/**
|
|
3
|
-
* Gets the types of a tuple except the first entry.
|
|
4
|
-
*/
|
|
5
2
|
export declare type Tail<T extends any[]> = T['length'] extends 0 ? never : (T extends [any, ...infer Tail] ? (Tail extends UnionOfValues<T>[] ? Tail : never) : T);
|
|
@@ -1,11 +1,4 @@
|
|
|
1
1
|
import { KeyTypes } from '../object';
|
|
2
2
|
import { Tail } from './Tail';
|
|
3
|
-
/**
|
|
4
|
-
* Gets the union of properties of the elements in `A`
|
|
5
|
-
*/
|
|
6
3
|
export declare type UnionOfProps<A extends Record<any, any>[], P extends KeyTypes> = A['length'] extends 0 ? never : (A['length'] extends 1 ? A[0][P] : A[0][P] | UnionOfProps<Tail<A>, P>);
|
|
7
|
-
/**
|
|
8
|
-
* Gets the union of properties in the element of `A`
|
|
9
|
-
* This will be deprecated in 4.0. Please use UnionOfProps instead.
|
|
10
|
-
*/
|
|
11
4
|
export declare type PropUnion<A extends Record<any, any>[], P extends KeyTypes> = UnionOfProps<A, P>;
|
|
@@ -1,9 +1,2 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Gets the union of value types in `A`
|
|
3
|
-
*/
|
|
4
1
|
export declare type UnionOfValues<A extends Array<any>> = A extends Array<infer E> ? E : never;
|
|
5
|
-
/**
|
|
6
|
-
* Gets the union of value types in `A`
|
|
7
|
-
* This will be deprecated in 4.0. Please use UnionOfValues instead.
|
|
8
|
-
*/
|
|
9
2
|
export declare type ArrayValue<A extends any[]> = UnionOfValues<A>;
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import { AnyConstructor } from '../class';
|
|
2
2
|
import { AnyFunction } from '../function';
|
|
3
|
-
/**
|
|
4
|
-
* assert the subject satisfies the specified type T
|
|
5
|
-
* @type T the type to check against.
|
|
6
|
-
*/
|
|
7
3
|
export declare function assertType<T>(subject: T): asserts subject is T;
|
|
8
4
|
export declare function assertType<T>(subject: unknown, validator: (s: T) => boolean): asserts subject is T;
|
|
9
5
|
export declare function assertType<T extends new (...args: any) => any>(subject: unknown, constructor: T): asserts subject is InstanceType<T>;
|
|
@@ -48,7 +48,6 @@ assertType.isTrue = function (subject) {
|
|
|
48
48
|
throw TypeError("subject is not true");
|
|
49
49
|
};
|
|
50
50
|
assertType.noTrue = function (subject) {
|
|
51
|
-
// @ts-ignore
|
|
52
51
|
if (subject === true)
|
|
53
52
|
throw TypeError("subject is true");
|
|
54
53
|
};
|
|
@@ -57,7 +56,6 @@ assertType.isFalse = function (subject) {
|
|
|
57
56
|
throw TypeError("subject is not false");
|
|
58
57
|
};
|
|
59
58
|
assertType.noFalse = function (subject) {
|
|
60
|
-
// @ts-ignore
|
|
61
59
|
if (subject === false)
|
|
62
60
|
throw TypeError("subject is false");
|
|
63
61
|
};
|
|
@@ -91,12 +89,6 @@ assertType.noError = function (subject) {
|
|
|
91
89
|
};
|
|
92
90
|
assertType.isNever = function (subject) {
|
|
93
91
|
};
|
|
94
|
-
/**
|
|
95
|
-
* creates a custom assertion function with standard TypeError.
|
|
96
|
-
* Currently this requires explicity type annotation,
|
|
97
|
-
* thus making it hard to use:
|
|
98
|
-
* https://github.com/microsoft/TypeScript/issues/41047
|
|
99
|
-
*/
|
|
100
92
|
assertType.custom = function (validator) {
|
|
101
93
|
return function (subject) {
|
|
102
94
|
if (!validator(subject))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assertType.js","sourceRoot":"","sources":["../../ts/assertion/assertType.ts"],"names":[],"mappings":";;;AAAA,mCAAiC;AACjC,kCAAwD;AAUxD,SAAgB,UAAU,CAAC,OAAgB,EAAE,SAA+B;IAC1E,IAAI,SAAS,EAAE;QACb,IAAI,CAAC,IAAA,qBAAa,EAAC,SAAS,CAAC,IAAI,CAAC,CAAC,OAAO,YAAY,SAAS,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;YACtF,MAAM,IAAI,SAAS,CAAC,mCAA4B,IAAA,iBAAO,EAAC,SAAS,CAAC,CAAE,CAAC,CAAA;KACxE;IACD,OAAM;AACR,CAAC;AAND,gCAMC;AAED,UAAU,CAAC,WAAW,GAAG,UAAU,OAAkB;IACnD,IAAI,OAAO,OAAO,KAAK,WAAW;QAAE,MAAM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;QAAE,MAAM,SAAS,CAAC,yBAAyB,CAAC,CAAA;AAC/E,CAAC,CAAA;AACD,UAAU,CAAC,UAAU,GAAG,UAAa,OAAgC;IACnE,IAAI,OAAO,OAAO,KAAK,UAAU;QAAE,MAAM,SAAS,CAAC,qBAAqB,CAAC,CAAA;AAC3E,CAAC,CAAA;AAED,UAAU,CAAC,aAAa,GAAG,UAAU,OAAuB;IAC1D,IAAI,CAAC,IAAA,qBAAa,EAAC,OAAO,CAAC;QAAE,MAAM,SAAS,CAAC,8BAA8B,CAAC,CAAA;AAC9E,CAAC,CAAA;AAED,UAAU,CAAC,OAAO,GAAG,UAAU,OAAc;IAC3C,IAAI,CAAC,CAAC,OAAO,YAAY,KAAK,CAAC;QAAE,MAAM,SAAS,CAAC,yBAAyB,CAAC,CAAA;AAC7E,CAAC,CAAA;AACD,UAAU,CAAC,OAAO,GAAG,UAAa,OAA0B;IAC1D,IAAI,OAAO,YAAY,KAAK;QAAE,MAAM,SAAS,CAAC,qBAAqB,CAAC,CAAA;AACtE,CAAC,CAAA;AAED,UAAU,CAAC,OAAO,GAAG,UAAU,OAAc;AAC7C,CAAC,CAAA;AAQD,UAAU,CAAC,MAAM,GAAG,UAClB,SAA4B;IAE5B,OAAO,UAAU,OAAO;QACtB,IAAI,CAAC,SAAS,CAAC,OAAc,CAAC;YAAE,MAAM,IAAI,SAAS,CAAC,mCAA4B,IAAA,iBAAO,EAAC,SAAS,CAAC,CAAE,CAAC,CAAA;QACrG,OAAM;IACR,CAAC,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compose.js","sourceRoot":"","sources":["../../ts/functional/compose.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"compose.js","sourceRoot":"","sources":["../../ts/functional/compose.ts"],"names":[],"mappings":";;;AAMA,SAAgB,OAAO;IAA2B,aAAU;SAAV,UAAU,EAAV,qBAAU,EAAV,IAAU;QAAV,wBAAU;;IAC1D,OAAO;QAAC,cAAc;aAAd,UAAc,EAAd,qBAAc,EAAd,IAAc;YAAd,yBAAc;;QAAK,OAAA,GAAG,CAAC,MAAM,CAAC,UAAC,IAAI,EAAE,EAAE,IAAK,OAAA,CAAC,EAAE,eAAI,IAAI,EAAE,EAAb,CAAa,EAAE,IAAI,CAAC,CAAC,CAAC,CAAQ;IAAvD,CAAuD,CAAA;AACpF,CAAC;AAFD,0BAEC"}
|
package/cjs/index.js
CHANGED
|
@@ -15,7 +15,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.requiredDeep = exports.required = void 0;
|
|
18
|
-
// import * as types from './types'
|
|
19
18
|
var unpartial_1 = require("unpartial");
|
|
20
19
|
Object.defineProperty(exports, "required", { enumerable: true, get: function () { return unpartial_1.required; } });
|
|
21
20
|
Object.defineProperty(exports, "requiredDeep", { enumerable: true, get: function () { return unpartial_1.requiredDeep; } });
|
|
@@ -33,5 +32,4 @@ __exportStar(require("./predicates"), exports);
|
|
|
33
32
|
__exportStar(require("./promise"), exports);
|
|
34
33
|
__exportStar(require("./testing"), exports);
|
|
35
34
|
__exportStar(require("./utils"), exports);
|
|
36
|
-
// export { types, types as T }
|
|
37
35
|
//# sourceMappingURL=index.js.map
|
package/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACA,uCAAkD;AAAzC,qGAAA,QAAQ,OAAA;AAAE,yGAAA,YAAY,OAAA;AAC/B,0CAAuB;AACvB,8CAA2B;AAC3B,0CAAuB;AAEvB,6CAA0B;AAC1B,+CAA4B;AAC5B,8CAA2B;AAC3B,yCAAsB;AACtB,2CAAwB;AACxB,kDAA+B;AAC/B,2CAAwB;AACxB,+CAA4B;AAE5B,4CAAyB;AACzB,4CAAyB;AAIzB,0CAAuB"}
|
package/cjs/math/Add.d.ts
CHANGED
|
@@ -4,9 +4,6 @@ import type { Digit, DigitArray } from './Digit';
|
|
|
4
4
|
import type { IsPositive } from './IsPositive';
|
|
5
5
|
import type { IsWhole } from './IsWhole';
|
|
6
6
|
import type { Max } from './Max';
|
|
7
|
-
/**
|
|
8
|
-
* Add two number literals.
|
|
9
|
-
*/
|
|
10
7
|
export declare type Add<A extends number, B extends number, Fail = never> = And<And<IsPositive<A>, IsWhole<A>>, And<IsPositive<B>, IsWhole<B>>> extends false ? Fail : DigitArray.FromNumber<A> extends infer DA ? DA extends number[] ? DigitArray.FromNumber<B> extends infer DB ? DB extends number[] ? Max<DA['length'], DB['length']> extends infer M ? M extends number ? PadLeft<DA, M, 0> extends infer PDA ? PDA extends number[] ? PadLeft<DB, M, 0> extends infer PDB ? PDB extends number[] ? DigitArray.ToNumber<Add.DigitArray<PDA, PDB>> : Fail : Fail : Fail : Fail : Fail : Fail : Fail : Fail : Fail : Fail;
|
|
11
8
|
export declare namespace Add {
|
|
12
9
|
type DigitArray<A extends number[], B extends number[]> = (A extends [any, ...infer ATail] ? (ATail extends number[] ? (B extends [any, ...infer BTail] ? (BTail extends number[] ? [Digit<A[0], B[0]>, ...DigitArray<ATail, BTail>] : []) : [A[0], ...DigitArray<[], ATail>]) : []) : (B extends [any, ...infer BTail] ? (BTail extends number[] ? [B[0], ...DigitArray<[], BTail>] : []) : []));
|
|
@@ -15,7 +12,4 @@ export declare namespace Add {
|
|
|
15
12
|
...Digit.ToTuple[B]
|
|
16
13
|
]['length'];
|
|
17
14
|
}
|
|
18
|
-
/**
|
|
19
|
-
* Increment `A` by 1.
|
|
20
|
-
*/
|
|
21
15
|
export declare type Increment<A extends number, Fail = never> = Add<A, 1, Fail>;
|
package/cjs/math/Digit.d.ts
CHANGED
|
@@ -27,9 +27,6 @@ export declare namespace Digit {
|
|
|
27
27
|
18: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
|
|
28
28
|
19: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
|
|
29
29
|
};
|
|
30
|
-
/**
|
|
31
|
-
* A > B for [1-9]
|
|
32
|
-
*/
|
|
33
30
|
type GreaterThan<A extends number, B extends number> = B extends GreaterThanMap[A] ? true : false;
|
|
34
31
|
type GreaterThanMap = {
|
|
35
32
|
[k in number]: number;
|
package/cjs/math/IsPositive.d.ts
CHANGED
|
@@ -1,6 +1 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Check if type of positive number literal
|
|
3
|
-
* `number` type is false as it can be negative.
|
|
4
|
-
* @see https://itnext.io/implementing-arithmetic-within-typescripts-type-system-a1ef140a6f6f
|
|
5
|
-
*/
|
|
6
1
|
export declare type IsPositive<N extends number, Then = true, Else = false> = number extends N ? Else : `${N}` extends `-${number}` ? Else : Then;
|
package/cjs/math/IsWhole.d.ts
CHANGED
|
@@ -1,6 +1 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Check if type is whole number literal.
|
|
3
|
-
* `number` type is false as it can be fractional.
|
|
4
|
-
* @see https://itnext.io/implementing-arithmetic-within-typescripts-type-system-a1ef140a6f6f
|
|
5
|
-
*/
|
|
6
1
|
export declare type IsWhole<N extends number, Then = true, Else = false> = number extends N ? Else : `${N}` extends `${number}.${number}` ? Else : Then;
|
package/cjs/math/Subtract.d.ts
CHANGED
|
@@ -9,7 +9,4 @@ export declare namespace Subtract {
|
|
|
9
9
|
type DigitArray<R extends number[], A extends number[], B extends number[]> = A['length'] extends 0 ? R : DigitArray<[...R, Digit<A[0], B[0]>], Tail<A>, Tail<B>>;
|
|
10
10
|
type Digit<A extends number, B extends number> = Digit.ToTuple[A] extends [...(infer U), ...Digit.ToTuple[B]] ? U['length'] : never;
|
|
11
11
|
}
|
|
12
|
-
/**
|
|
13
|
-
* A - 1
|
|
14
|
-
*/
|
|
15
12
|
export declare type Decrement<A extends number, Fail = never> = Subtract<A, 1, Fail>;
|
|
@@ -22,9 +22,4 @@ export declare type SystemErrors = {
|
|
|
22
22
|
'ETIMEDOUT': Error;
|
|
23
23
|
};
|
|
24
24
|
export declare type SystemErrorCodes = keyof SystemErrors;
|
|
25
|
-
/**
|
|
26
|
-
* Type guard NodeJS SystemErrors.
|
|
27
|
-
* The list is not complete. Will add as needed.
|
|
28
|
-
* Feel free to contribute.
|
|
29
|
-
*/
|
|
30
25
|
export declare function isSystemError<C extends SystemErrorCodes>(code: C, err: unknown): err is SystemErrors[C];
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isSystemError = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Type guard NodeJS SystemErrors.
|
|
6
|
-
* The list is not complete. Will add as needed.
|
|
7
|
-
* Feel free to contribute.
|
|
8
|
-
*/
|
|
9
4
|
function isSystemError(code, err) {
|
|
10
5
|
return !!err && err.code === code;
|
|
11
6
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isNodeError.js","sourceRoot":"","sources":["../../ts/nodejs/isNodeError.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"isNodeError.js","sourceRoot":"","sources":["../../ts/nodejs/isNodeError.ts"],"names":[],"mappings":";;;AAwBA,SAAgB,aAAa,CAA6B,IAAO,EAAE,GAAY;IAC7E,OAAO,CAAC,CAAC,GAAG,IAAK,GAAW,CAAC,IAAI,KAAK,IAAI,CAAA;AAC5C,CAAC;AAFD,sCAEC"}
|
|
@@ -1,20 +1,10 @@
|
|
|
1
1
|
import { Widen } from '../utils';
|
|
2
2
|
import { typeSym, valueSym } from './types';
|
|
3
|
-
/**
|
|
4
|
-
* Create a "branded" version of a type.
|
|
5
|
-
* TypeScript won't allow implicit conversion to this type
|
|
6
|
-
*/
|
|
7
3
|
export declare type Brand<B extends string, T> = T extends undefined | null | number | bigint | boolean ? {
|
|
8
4
|
[typeSym]: B;
|
|
9
5
|
[valueSym]: T;
|
|
10
6
|
} : T & {
|
|
11
7
|
[typeSym]: B;
|
|
12
8
|
};
|
|
13
|
-
/**
|
|
14
|
-
* Creates a brand creator with the specified type.
|
|
15
|
-
*/
|
|
16
9
|
export declare function brand<B extends string>(type: B): <T>(subject: T) => Brand<B, Widen<T>>;
|
|
17
|
-
/**
|
|
18
|
-
* Creates a branded value of specified type.
|
|
19
|
-
*/
|
|
20
10
|
export declare function brand<B extends string, T>(type: B, subject: T): Brand<B, Widen<T>>;
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// By Drew Colthorp, <https://spin.atomicobject.com/2018/01/15/typescript-flexible-nominal-typing/#comment-604580>
|
|
3
|
-
// <https://gist.github.com/dcolthorp/aa21cf87d847ae9942106435bf47565d>
|
|
4
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
3
|
exports.brand = void 0;
|
|
6
4
|
var types_1 = require("./types");
|
|
@@ -8,7 +6,6 @@ function brand(type, subject) {
|
|
|
8
6
|
if (subject === undefined)
|
|
9
7
|
return function (subject) { return brand(type, subject); };
|
|
10
8
|
if (typeof subject === 'object' && subject !== null) {
|
|
11
|
-
// if subject is not an object, the branding will exist only in type-level.
|
|
12
9
|
subject[types_1.typeSym] = type;
|
|
13
10
|
}
|
|
14
11
|
return subject;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Brand.js","sourceRoot":"","sources":["../../ts/nominal-types/Brand.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Brand.js","sourceRoot":"","sources":["../../ts/nominal-types/Brand.ts"],"names":[],"mappings":";;;AAIA,iCAA2C;AAmB3C,SAAgB,KAAK,CAAC,IAAY,EAAE,OAAiB;IACnD,IAAI,OAAO,KAAK,SAAS;QAAE,OAAO,UAAa,OAAU,IAAI,OAAO,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA,CAAC,CAAC,CAAA;IAE1F,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI,EAAE;QAElD,OAAiC,CAAC,eAAO,CAAC,GAAG,IAAI,CAAA;KACnD;IACD,OAAO,OAAO,CAAA;AAChB,CAAC;AARD,sBAQC"}
|
|
@@ -1,19 +1,7 @@
|
|
|
1
1
|
import { Widen } from '../utils';
|
|
2
2
|
import { typeSym } from './types';
|
|
3
|
-
/**
|
|
4
|
-
* Create a "flavored" version of a type.
|
|
5
|
-
* TypeScript will disallow mixing flavors,
|
|
6
|
-
* but will allow unflavored values of that type to be passed in where a flavored version is expected.
|
|
7
|
-
* This is a less restrictive form of branding.
|
|
8
|
-
*/
|
|
9
3
|
export declare type Flavor<F extends string, T> = T & {
|
|
10
4
|
[typeSym]?: F;
|
|
11
5
|
};
|
|
12
|
-
/**
|
|
13
|
-
* Creates a brand creator with the specified type.
|
|
14
|
-
*/
|
|
15
6
|
export declare function flavor<F extends string>(type: F): <T>(subject: T) => Flavor<F, Widen<T>>;
|
|
16
|
-
/**
|
|
17
|
-
* Creates a branded value of specified type.
|
|
18
|
-
*/
|
|
19
7
|
export declare function flavor<F extends string, T>(type: F, subject: T): Flavor<F, Widen<T>>;
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// By Drew Colthorp, <https://spin.atomicobject.com/2018/01/15/typescript-flexible-nominal-typing/#comment-604580>
|
|
3
|
-
// <https://gist.github.com/dcolthorp/aa21cf87d847ae9942106435bf47565d>
|
|
4
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
3
|
exports.flavor = void 0;
|
|
6
4
|
var types_1 = require("./types");
|
|
@@ -8,7 +6,6 @@ function flavor(type, subject) {
|
|
|
8
6
|
if (subject === undefined)
|
|
9
7
|
return function (subject) { return flavor(type, subject); };
|
|
10
8
|
if (typeof subject === 'object' && subject !== null) {
|
|
11
|
-
// if subject is not an object, the branding will exist only in type-level.
|
|
12
9
|
subject[types_1.typeSym] = type;
|
|
13
10
|
}
|
|
14
11
|
return subject;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Flavor.js","sourceRoot":"","sources":["../../ts/nominal-types/Flavor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Flavor.js","sourceRoot":"","sources":["../../ts/nominal-types/Flavor.ts"],"names":[],"mappings":";;;AAIA,iCAAiC;AAoBjC,SAAgB,MAAM,CAAC,IAAY,EAAE,OAAiB;IACpD,IAAI,OAAO,KAAK,SAAS;QAAE,OAAO,UAAa,OAAU,IAAI,OAAO,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA,CAAC,CAAC,CAAA;IAC3F,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI,EAAE;QAElD,OAAiC,CAAC,eAAO,CAAC,GAAG,IAAI,CAAA;KACnD;IACD,OAAO,OAAO,CAAA;AAChB,CAAC;AAPD,wBAOC"}
|
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
import { And, Not } from '../predicates';
|
|
2
2
|
import { AnyRecord } from './AnyRecord';
|
|
3
3
|
import { HasKey } from './hasKey';
|
|
4
|
-
/**
|
|
5
|
-
* Are the two records disjoint from each other.
|
|
6
|
-
* Disjoint means no common property.
|
|
7
|
-
*/
|
|
8
4
|
export declare type IsDisjoint<A extends AnyRecord, B extends AnyRecord> = And<Not<HasKey<A, keyof B>>, Not<HasKey<B, keyof A>>>;
|
package/cjs/object/KeyTypes.d.ts
CHANGED
package/cjs/object/KnownKeys.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// Original by Klaus Meinhardt @ajafff
|
|
3
|
-
// known from Gerrit Birkeland @Gerrit0
|
|
4
|
-
// https://github.com/Microsoft/TypeScript/issues/25987#issuecomment-408339599
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
//# sourceMappingURL=KnownKeys.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KnownKeys.js","sourceRoot":"","sources":["../../ts/object/KnownKeys.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"KnownKeys.js","sourceRoot":"","sources":["../../ts/object/KnownKeys.ts"],"names":[],"mappings":""}
|
package/cjs/object/Partial.d.ts
CHANGED
|
@@ -1,15 +1,6 @@
|
|
|
1
1
|
import { UnionKeys } from '../UnionKeys';
|
|
2
2
|
import { Omit } from './omit';
|
|
3
3
|
import { Pick } from './pick';
|
|
4
|
-
/**
|
|
5
|
-
* Apply `Partial<>` on the selected properties.
|
|
6
|
-
*/
|
|
7
4
|
export declare type PartialPick<T, U extends UnionKeys<T>> = T extends T ? Omit<T, U> & Partial<Pick<T, U>> : never;
|
|
8
|
-
/**
|
|
9
|
-
* @deprecated replaced by `PartialOmit`
|
|
10
|
-
*/
|
|
11
5
|
export declare type PartialExcept<T, U extends UnionKeys<T>> = T extends T ? Pick<T, U> & Partial<Omit<T, U>> : never;
|
|
12
|
-
/**
|
|
13
|
-
* Apply `Partial<>` on all not selected properties.
|
|
14
|
-
*/
|
|
15
6
|
export declare type PartialOmit<T, U extends UnionKeys<T>> = T extends T ? Pick<T, U> & Partial<Omit<T, U>> : never;
|
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
import { AnyRecord } from './AnyRecord';
|
|
2
|
-
/**
|
|
3
|
-
* Intersect type recursively.
|
|
4
|
-
* The recursion terminates at level 7 due to design limit of TypeScript.
|
|
5
|
-
*
|
|
6
|
-
* Normal use case is intersecting betwee two object types.
|
|
7
|
-
* While it works for value types and top level array,
|
|
8
|
-
* top level array does not recursive into the elements.
|
|
9
|
-
* NOTE: in latest TypeScript,
|
|
10
|
-
* `undefined` is not an accepted value.
|
|
11
|
-
* The resulting type would be `never`
|
|
12
|
-
*/
|
|
13
2
|
export declare type RecursiveIntersect<T, U> = (T & (T extends Array<infer Y> ? Array<Y & U> & U : T extends AnyRecord ? {
|
|
14
3
|
[P in keyof T]: T[P] extends Array<infer R> ? Array<RecursiveIntersect<R, U>> & U : T[P] extends AnyRecord ? RecursiveIntersect<T[P], U> : T[P] & U;
|
|
15
4
|
} & U : U));
|
package/cjs/object/Required.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// Thanks [jack-williams](https://github.com/jack-williams) for the [solution](https://github.com/Microsoft/TypeScript/issues/29269#issuecomment-451602962)
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
3
|
//# sourceMappingURL=Required.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Required.js","sourceRoot":"","sources":["../../ts/object/Required.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Required.js","sourceRoot":"","sources":["../../ts/object/Required.ts"],"names":[],"mappings":""}
|
package/cjs/object/facade.d.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import { AnyRecord } from './AnyRecord';
|
|
2
|
-
/**
|
|
3
|
-
* creates a facade of the subject.
|
|
4
|
-
*/
|
|
5
2
|
export declare function facade<T extends AnyRecord, P1 extends keyof T>(subject: T, prop1: P1): Pick<T, P1>;
|
|
6
3
|
export declare function facade<T extends AnyRecord, P1 extends keyof T, P2 extends keyof T>(subject: T, prop1: P1, prop2: P2): Pick<T, P1 | P2>;
|
|
7
4
|
export declare function facade<T extends AnyRecord, P1 extends keyof T, P2 extends keyof T, P3 extends keyof T>(subject: T, prop1: P1, prop2: P2, prop3: P3): Pick<T, P1 | P2 | P3>;
|
package/cjs/object/facade.js
CHANGED
|
@@ -9,17 +9,14 @@ function facade(subject) {
|
|
|
9
9
|
return props.reduce(function (p, k) {
|
|
10
10
|
var prop = subject[k];
|
|
11
11
|
if (typeof prop === 'function') {
|
|
12
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call
|
|
13
12
|
p[k] = prop.bind(subject);
|
|
14
13
|
}
|
|
15
14
|
else {
|
|
16
15
|
Object.defineProperty(p, k, {
|
|
17
16
|
get: function () {
|
|
18
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
19
17
|
return subject[k];
|
|
20
18
|
},
|
|
21
19
|
set: function (value) {
|
|
22
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-assignment
|
|
23
20
|
return subject[k] = value;
|
|
24
21
|
},
|
|
25
22
|
});
|
package/cjs/object/facade.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"facade.js","sourceRoot":"","sources":["../../ts/object/facade.ts"],"names":[],"mappings":";;;AAiBA,SAAgB,MAAM,CAAsB,OAAU;IAAE,eAAqB;SAArB,UAAqB,EAArB,qBAAqB,EAArB,IAAqB;QAArB,8BAAqB;;IAC3E,OAAO,KAAK,CAAC,MAAM,CAAC,UAAC,CAAC,EAAE,CAAC;QACvB,IAAM,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;QACvB,IAAI,OAAO,IAAI,KAAK,UAAU,EAAE;
|
|
1
|
+
{"version":3,"file":"facade.js","sourceRoot":"","sources":["../../ts/object/facade.ts"],"names":[],"mappings":";;;AAiBA,SAAgB,MAAM,CAAsB,OAAU;IAAE,eAAqB;SAArB,UAAqB,EAArB,qBAAqB,EAArB,IAAqB;QAArB,8BAAqB;;IAC3E,OAAO,KAAK,CAAC,MAAM,CAAC,UAAC,CAAC,EAAE,CAAC;QACvB,IAAM,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;QACvB,IAAI,OAAO,IAAI,KAAK,UAAU,EAAE;YAE9B,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;SAC1B;aACI;YACH,MAAM,CAAC,cAAc,CAAC,CAAC,EAAE,CAAC,EAAE;gBAC1B,GAAG;oBAED,OAAO,OAAO,CAAC,CAAC,CAAC,CAAA;gBACnB,CAAC;gBACD,GAAG,EAAH,UAAI,KAAU;oBAEZ,OAAO,OAAO,CAAC,CAAC,CAAC,GAAG,KAAK,CAAA;gBAC3B,CAAC;aACF,CAAC,CAAA;SACH;QACD,OAAO,CAAC,CAAA;IACV,CAAC,EAAE,EAAO,CAAC,CAAA;AACb,CAAC;AArBD,wBAqBC"}
|
package/cjs/object/index.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ export * from './omit';
|
|
|
21
21
|
export type { OptionalKeys } from './OptionalKeys';
|
|
22
22
|
export type { PartialExcept, PartialOmit, PartialPick } from './Partial';
|
|
23
23
|
export * from './pick';
|
|
24
|
+
export * from './record';
|
|
24
25
|
export type { RecursiveIntersect } from './RecursiveIntersect';
|
|
25
26
|
export type { RecursivePartial } from './RecursivePartial';
|
|
26
27
|
export type { RecursiveRequired } from './RecursiveRequired';
|
package/cjs/object/index.js
CHANGED
|
@@ -26,6 +26,7 @@ __exportStar(require("./mapKey"), exports);
|
|
|
26
26
|
__exportStar(require("./mapProperties"), exports);
|
|
27
27
|
__exportStar(require("./omit"), exports);
|
|
28
28
|
__exportStar(require("./pick"), exports);
|
|
29
|
+
__exportStar(require("./record"), exports);
|
|
29
30
|
__exportStar(require("./reduceKey"), exports);
|
|
30
31
|
__exportStar(require("./replaceProperty"), exports);
|
|
31
32
|
__exportStar(require("./someKey"), exports);
|
package/cjs/object/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../ts/object/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAEA,6CAA0B;AAE1B,2CAAwB;AACxB,8CAA2B;AAC3B,4CAAyB;AACzB,+CAA4B;AAC5B,6CAA0B;AAC1B,2CAAwB;AACxB,gDAA6B;AAO7B,2CAAwB;AACxB,kDAA+B;AAC/B,yCAAsB;AAGtB,yCAAsB;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../ts/object/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAEA,6CAA0B;AAE1B,2CAAwB;AACxB,8CAA2B;AAC3B,4CAAyB;AACzB,+CAA4B;AAC5B,6CAA0B;AAC1B,2CAAwB;AACxB,gDAA6B;AAO7B,2CAAwB;AACxB,kDAA+B;AAC/B,yCAAsB;AAGtB,yCAAsB;AACtB,2CAAwB;AAIxB,8CAA2B;AAC3B,oDAAiC;AAGjC,4CAAyB;AACzB,0CAAuB;AAEvB,6DAA0C"}
|
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
import { AnyRecord } from './AnyRecord';
|
|
2
2
|
import { ValueOf } from './ValueOf';
|
|
3
|
-
/**
|
|
4
|
-
* An Object-specific version of `map`.
|
|
5
|
-
* Original source:
|
|
6
|
-
* <https://stackoverflow.com/questions/53964071/how-to-dynamically-create-mapped-type-in-typescript>
|
|
7
|
-
*
|
|
8
|
-
* `ramda` has a similar function (`mapObjIndexed()`) with different parameter order.
|
|
9
|
-
* I keep this parameter order because this parameter order provides better type inference.
|
|
10
|
-
*/
|
|
11
3
|
export declare function mapProperties<Subject extends AnyRecord, ResultProp>(subject: Subject, callbackfn: (value: ValueOf<Subject>, key: keyof Subject, obj: Subject) => ResultProp): {
|
|
12
4
|
[K in keyof Subject]: ResultProp;
|
|
13
5
|
};
|
|
@@ -2,14 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.mapProperties = void 0;
|
|
4
4
|
var reduceKey_1 = require("./reduceKey");
|
|
5
|
-
/**
|
|
6
|
-
* An Object-specific version of `map`.
|
|
7
|
-
* Original source:
|
|
8
|
-
* <https://stackoverflow.com/questions/53964071/how-to-dynamically-create-mapped-type-in-typescript>
|
|
9
|
-
*
|
|
10
|
-
* `ramda` has a similar function (`mapObjIndexed()`) with different parameter order.
|
|
11
|
-
* I keep this parameter order because this parameter order provides better type inference.
|
|
12
|
-
*/
|
|
13
5
|
function mapProperties(subject, callbackfn) {
|
|
14
6
|
return (0, reduceKey_1.reduceByKey)(subject, function (p, key) { return (p[key] = callbackfn(subject[key], key, subject),
|
|
15
7
|
p); }, {});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapProperties.js","sourceRoot":"","sources":["../../ts/object/mapProperties.ts"],"names":[],"mappings":";;;AACA,yCAAyC;
|
|
1
|
+
{"version":3,"file":"mapProperties.js","sourceRoot":"","sources":["../../ts/object/mapProperties.ts"],"names":[],"mappings":";;;AACA,yCAAyC;AAWzC,SAAgB,aAAa,CAI3B,OAAgB,EAChB,UAAqF;IAErF,OAAO,IAAA,uBAAW,EAAC,OAAO,EAAE,UAAC,CAAC,EAAE,GAAG,IAAK,OAAA,CACtC,CAAC,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC;QAC/C,CAAC,CAAC,EAFoC,CAEpC,EAAE,EAA0C,CAAC,CAAA;AACnD,CAAC;AAVD,sCAUC"}
|
package/cjs/object/omit.d.ts
CHANGED
|
@@ -2,9 +2,6 @@ import { AnyRecord } from '../object';
|
|
|
2
2
|
import { UnionKeys } from '../UnionKeys';
|
|
3
3
|
import { Pick } from './pick';
|
|
4
4
|
export declare type Omit<T, K extends UnionKeys<T>> = T extends T ? keyof T extends K ? {} : Pick<T, Exclude<keyof T, K>> : never;
|
|
5
|
-
/**
|
|
6
|
-
* @deprecated replaced by `Omit`
|
|
7
|
-
*/
|
|
8
5
|
export declare type Except<T, K extends keyof T> = Omit<T, K>;
|
|
9
6
|
export declare function omit<T extends AnyRecord, P1 extends UnionKeys<T>>(subject: T, prop1: P1): Omit<T, P1>;
|
|
10
7
|
export declare function omit<T extends AnyRecord, P1 extends UnionKeys<T>, P2 extends UnionKeys<T>>(subject: T, prop1: P1, prop2: P2): Omit<T, P1 | P2>;
|