@transcend-io/type-utils 1.8.5 → 2.0.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/build/aggregateObjects.js +1 -5
- package/build/aggregateObjects.js.map +1 -1
- package/build/apply.d.ts +1 -1
- package/build/apply.d.ts.map +1 -1
- package/build/apply.js +7 -13
- package/build/apply.js.map +1 -1
- package/build/codecTools/FixedLengthArray.js +2 -29
- package/build/codecTools/FixedLengthArray.js.map +1 -1
- package/build/codecTools/FixedLengthString.js +2 -29
- package/build/codecTools/FixedLengthString.js.map +1 -1
- package/build/codecTools/NonEmptyString.js +2 -28
- package/build/codecTools/NonEmptyString.js.map +1 -1
- package/build/codecTools/createDefaultCodec.js +8 -35
- package/build/codecTools/createDefaultCodec.js.map +1 -1
- package/build/codecTools/decodeCodec.js +8 -12
- package/build/codecTools/decodeCodec.js.map +1 -1
- package/build/codecTools/dictionary.js +3 -30
- package/build/codecTools/dictionary.js.map +1 -1
- package/build/codecTools/index.d.ts +9 -9
- package/build/codecTools/index.d.ts.map +1 -1
- package/build/codecTools/index.js +9 -25
- package/build/codecTools/index.js.map +1 -1
- package/build/codecTools/isCodecError.js +1 -5
- package/build/codecTools/isCodecError.js.map +1 -1
- package/build/codecTools/partialRecord.js +2 -29
- package/build/codecTools/partialRecord.js.map +1 -1
- package/build/codecTools/toJsonSchema.js +10 -14
- package/build/codecTools/toJsonSchema.js.map +1 -1
- package/build/enum.d.ts +1 -1
- package/build/enum.d.ts.map +1 -1
- package/build/enum.js +4 -11
- package/build/enum.js.map +1 -1
- package/build/enums.js +2 -5
- package/build/enums.js.map +1 -1
- package/build/findAllWithRegex.js +1 -5
- package/build/findAllWithRegex.js.map +1 -1
- package/build/flattenObject.js +5 -9
- package/build/flattenObject.js.map +1 -1
- package/build/fromEntries.js +1 -5
- package/build/fromEntries.js.map +1 -1
- package/build/getEntries.d.ts +1 -1
- package/build/getEntries.d.ts.map +1 -1
- package/build/getEntries.js +1 -5
- package/build/getEntries.js.map +1 -1
- package/build/getKeys.d.ts +1 -1
- package/build/getKeys.d.ts.map +1 -1
- package/build/getKeys.js +2 -7
- package/build/getKeys.js.map +1 -1
- package/build/getValues.js +1 -5
- package/build/getValues.js.map +1 -1
- package/build/gql.js +4 -8
- package/build/gql.js.map +1 -1
- package/build/groupBy.js +1 -5
- package/build/groupBy.js.map +1 -1
- package/build/index.d.ts +18 -17
- package/build/index.d.ts.map +1 -1
- package/build/index.js +18 -33
- package/build/index.js.map +1 -1
- package/build/invert.js +5 -10
- package/build/invert.js.map +1 -1
- package/build/noExcess.d.ts +33 -0
- package/build/noExcess.d.ts.map +1 -0
- package/build/noExcess.js +153 -0
- package/build/noExcess.js.map +1 -0
- package/build/tests/FixedLengthArray.test.js +6 -31
- package/build/tests/FixedLengthArray.test.js.map +1 -1
- package/build/tests/aggregateObjects.test.js +20 -22
- package/build/tests/aggregateObjects.test.js.map +1 -1
- package/build/tests/createDefaultCodec.test.js +39 -67
- package/build/tests/createDefaultCodec.test.js.map +1 -1
- package/build/tests/decodeCodec.test.js +7 -32
- package/build/tests/decodeCodec.test.js.map +1 -1
- package/build/tests/enum.test.js +7 -9
- package/build/tests/enum.test.js.map +1 -1
- package/build/tests/flattenObject.test.js +16 -18
- package/build/tests/flattenObject.test.js.map +1 -1
- package/build/tests/gql.test.js +6 -8
- package/build/tests/gql.test.js.map +1 -1
- package/build/tests/groupBy.test.js +3 -5
- package/build/tests/groupBy.test.js.map +1 -1
- package/build/tests/invert.test.js +6 -8
- package/build/tests/invert.test.js.map +1 -1
- package/build/tests/noExcess.test.d.ts +2 -0
- package/build/tests/noExcess.test.d.ts.map +1 -0
- package/build/tests/noExcess.test.js +65 -0
- package/build/tests/noExcess.test.js.map +1 -0
- package/build/tests/transposeObjectArray.test.js +22 -24
- package/build/tests/transposeObjectArray.test.js.map +1 -1
- package/build/transposeObjectArray.js +1 -5
- package/build/transposeObjectArray.js.map +1 -1
- package/build/tsbuildinfo +1 -1
- package/build/types.js +1 -2
- package/build/valuesOf.js +4 -31
- package/build/valuesOf.js.map +1 -1
- package/package.json +14 -8
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toJsonSchema = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Convert an io-ts codec to a JSON Schema (v7)
|
|
6
3
|
* @param _type - an io-ts codec
|
|
@@ -9,7 +6,7 @@ exports.toJsonSchema = void 0;
|
|
|
9
6
|
* @returns a JSON schema object
|
|
10
7
|
* @see https://json-schema.org/understanding-json-schema/basics.html
|
|
11
8
|
*/
|
|
12
|
-
const toJsonSchema = (_type, strict = false, alwaysIncludeRequired = false) => {
|
|
9
|
+
export const toJsonSchema = (_type, strict = false, alwaysIncludeRequired = false) => {
|
|
13
10
|
const type = _type;
|
|
14
11
|
if (type._tag === 'StringType') {
|
|
15
12
|
return { type: 'string' };
|
|
@@ -31,16 +28,16 @@ const toJsonSchema = (_type, strict = false, alwaysIncludeRequired = false) => {
|
|
|
31
28
|
}
|
|
32
29
|
if (type._tag === 'UnionType') {
|
|
33
30
|
return {
|
|
34
|
-
anyOf: type.types.map((t) =>
|
|
31
|
+
anyOf: type.types.map((t) => toJsonSchema(t, strict, alwaysIncludeRequired)),
|
|
35
32
|
};
|
|
36
33
|
}
|
|
37
34
|
if (type._tag === 'IntersectionType' && !alwaysIncludeRequired) {
|
|
38
35
|
return {
|
|
39
|
-
allOf: type.types.map((t) =>
|
|
36
|
+
allOf: type.types.map((t) => toJsonSchema(t, strict, alwaysIncludeRequired)),
|
|
40
37
|
};
|
|
41
38
|
}
|
|
42
39
|
if (type._tag === 'IntersectionType' && alwaysIncludeRequired) {
|
|
43
|
-
const results = type.types.map((t) =>
|
|
40
|
+
const results = type.types.map((t) => toJsonSchema(t, strict, alwaysIncludeRequired));
|
|
44
41
|
if (!results.every((r) => r.type === 'object')) {
|
|
45
42
|
throw new Error('InterfaceType must have all children as type=object');
|
|
46
43
|
}
|
|
@@ -57,7 +54,7 @@ const toJsonSchema = (_type, strict = false, alwaysIncludeRequired = false) => {
|
|
|
57
54
|
required: Object.keys(type.props),
|
|
58
55
|
properties: Object.fromEntries(Object.entries(type.props).map(([key, subtype]) => [
|
|
59
56
|
key,
|
|
60
|
-
|
|
57
|
+
toJsonSchema(subtype, strict, alwaysIncludeRequired),
|
|
61
58
|
])),
|
|
62
59
|
...(strict ? { additionalProperties: false } : {}),
|
|
63
60
|
};
|
|
@@ -65,7 +62,7 @@ const toJsonSchema = (_type, strict = false, alwaysIncludeRequired = false) => {
|
|
|
65
62
|
if (type._tag === 'DictionaryType') {
|
|
66
63
|
return {
|
|
67
64
|
type: 'object',
|
|
68
|
-
additionalProperties:
|
|
65
|
+
additionalProperties: toJsonSchema(type.codomain, strict, alwaysIncludeRequired),
|
|
69
66
|
};
|
|
70
67
|
}
|
|
71
68
|
if (type._tag === 'PartialType') {
|
|
@@ -73,7 +70,7 @@ const toJsonSchema = (_type, strict = false, alwaysIncludeRequired = false) => {
|
|
|
73
70
|
type: 'object',
|
|
74
71
|
...(alwaysIncludeRequired ? { required: Object.keys(type.props) } : {}),
|
|
75
72
|
properties: Object.fromEntries(Object.entries(type.props).map(([key, subtype]) => {
|
|
76
|
-
const result =
|
|
73
|
+
const result = toJsonSchema(subtype, strict, alwaysIncludeRequired);
|
|
77
74
|
return [
|
|
78
75
|
key,
|
|
79
76
|
alwaysIncludeRequired && result.type
|
|
@@ -90,13 +87,13 @@ const toJsonSchema = (_type, strict = false, alwaysIncludeRequired = false) => {
|
|
|
90
87
|
if (type._tag === 'ArrayType') {
|
|
91
88
|
return {
|
|
92
89
|
type: 'array',
|
|
93
|
-
items:
|
|
90
|
+
items: toJsonSchema(type.type, strict, alwaysIncludeRequired),
|
|
94
91
|
};
|
|
95
92
|
}
|
|
96
93
|
if (type._tag === 'TupleType') {
|
|
97
94
|
return {
|
|
98
95
|
type: 'array',
|
|
99
|
-
items: type.types.map((t) =>
|
|
96
|
+
items: type.types.map((t) => toJsonSchema(t, strict, alwaysIncludeRequired)),
|
|
100
97
|
};
|
|
101
98
|
}
|
|
102
99
|
if (type._tag === 'RefinementType') {
|
|
@@ -104,14 +101,13 @@ const toJsonSchema = (_type, strict = false, alwaysIncludeRequired = false) => {
|
|
|
104
101
|
return { type: 'integer' };
|
|
105
102
|
}
|
|
106
103
|
return {
|
|
107
|
-
...
|
|
104
|
+
...toJsonSchema(type.type, strict, alwaysIncludeRequired),
|
|
108
105
|
description: `Predicate: ${type.predicate.name || type.name}`,
|
|
109
106
|
};
|
|
110
107
|
}
|
|
111
108
|
// could add more here for DateFromISOString, etc. etc.
|
|
112
109
|
return unhandledType(type);
|
|
113
110
|
};
|
|
114
|
-
exports.toJsonSchema = toJsonSchema;
|
|
115
111
|
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type, @typescript-eslint/no-unused-vars
|
|
116
112
|
const unhandledType = (_shouldBeNever) => ({});
|
|
117
113
|
/* eslint-enable @typescript-eslint/no-explicit-any */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toJsonSchema.js","sourceRoot":"","sources":["../../src/codecTools/toJsonSchema.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"toJsonSchema.js","sourceRoot":"","sources":["../../src/codecTools/toJsonSchema.ts"],"names":[],"mappings":"AAyBA;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,KAAU,EACV,MAAM,GAAG,KAAK,EACd,qBAAqB,GAAG,KAAK,EAChB,EAAE;IACf,MAAM,IAAI,GAAG,KAAqB,CAAC;IAEnC,IAAI,IAAI,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;QAC/B,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;IAC5B,CAAC;IACD,IAAI,IAAI,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;QAC/B,OAAO,EAAE,IAAI,EAAE,QAAQ,EAA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AAE,CAAC;QAC9B,OAAO;YACL,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAM,EAAE,EAAE,CAC/B,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,qBAAqB,CAAC,CAC/C;SACF,CAAC;IACJ,CAAC;IACD,IAAI,IAAI,CAAC,IAAI,KAAK,gBAAgB,EAAE,CAAC;QACnC,IAAI,IAAI,CAAC,IAAI,KAAK,KAAK,EAAE,CAAC;YACxB,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;QAC7B,CAAC;QACD,OAAO;YACL,GAAG,YAAY,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,qBAAqB,CAAC;YACzD,WAAW,EAAE,cAAc,IAAI,CAAC,SAAS,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,EAAE;SAC9D,CAAC;IACJ,CAAC;IACD,uDAAuD;IACvD,OAAO,aAAa,CAAC,IAAa,CAAC,CAAC;AACtC,CAAC,CAAC;AAEF,+GAA+G;AAC/G,MAAM,aAAa,GAAG,CAAC,cAAqB,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;AAEtD,sDAAsD;AACtD,wCAAwC"}
|
package/build/enum.d.ts
CHANGED
package/build/enum.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enum.d.ts","sourceRoot":"","sources":["../src/enum.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"enum.d.ts","sourceRoot":"","sources":["../src/enum.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C;;GAEG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,GAAG,MAAM,EAAE,IAAI,SAAS,MAAM,GAAG,MAAM,IAAI;KAC/D,GAAG,IAAI,IAAI,GAAG,CAAC;CAC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filterEnum = exports.createEnum = exports.listToEnum = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Convert a list of strings to an "enum" object
|
|
6
3
|
* @param attributes - The attributes of the enum
|
|
7
4
|
* @returns The input to become an enum
|
|
8
5
|
*/
|
|
9
|
-
function listToEnum(attributes) {
|
|
6
|
+
export function listToEnum(attributes) {
|
|
10
7
|
const init = {};
|
|
11
8
|
return attributes.reduce((acc, val) => {
|
|
12
9
|
acc[val] = val;
|
|
13
10
|
return acc;
|
|
14
11
|
}, init);
|
|
15
12
|
}
|
|
16
|
-
exports.listToEnum = listToEnum;
|
|
17
13
|
/**
|
|
18
14
|
* Create an enum object with a proxy handler that will throw an error when a property is access that is not in the enum
|
|
19
15
|
* @param attributes - The enums to merge into a single enum (all properties)
|
|
20
16
|
* @returns The object proxy with error logger when a value is accessed outside of enum
|
|
21
17
|
*/
|
|
22
|
-
function createEnum(...attributes) {
|
|
18
|
+
export function createEnum(...attributes) {
|
|
23
19
|
// Convert all to enums to objects
|
|
24
20
|
const objAttributes = attributes.map((attrs) => Array.isArray(attrs) ? listToEnum(attrs) : attrs);
|
|
25
21
|
return Object.assign({}, ...objAttributes);
|
|
26
22
|
}
|
|
27
|
-
exports.createEnum = createEnum;
|
|
28
23
|
/**
|
|
29
24
|
* Filter an enum and return the keys that remain
|
|
30
25
|
* @param obj - The object to filter
|
|
31
26
|
* @param filterFunc - The function to filter the enum key/values by
|
|
32
27
|
* @returns The object keys that remained
|
|
33
28
|
*/
|
|
34
|
-
function filterEnum(obj, filterFunc) {
|
|
29
|
+
export function filterEnum(obj, filterFunc) {
|
|
35
30
|
return (Object.keys(obj)
|
|
36
31
|
// Filter by value
|
|
37
32
|
.filter((key) => filterFunc(obj[key], key, obj))
|
|
38
33
|
// Return keys
|
|
39
34
|
.map((key) => key));
|
|
40
35
|
}
|
|
41
|
-
exports.filterEnum = filterEnum;
|
|
42
36
|
/**
|
|
43
37
|
* Make an enum compatible with types -- in separate file because Logger/enums and Enum/index circular dependency
|
|
44
38
|
* @param x - The enum
|
|
45
39
|
* @returns The object proxy with error logger when a value is accessed outside of enum
|
|
46
40
|
*/
|
|
47
|
-
function makeEnum(x) {
|
|
41
|
+
export function makeEnum(x) {
|
|
48
42
|
return x;
|
|
49
43
|
}
|
|
50
|
-
exports.makeEnum = makeEnum;
|
|
51
44
|
//# sourceMappingURL=enum.js.map
|
package/build/enum.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enum.js","sourceRoot":"","sources":["../src/enum.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"enum.js","sourceRoot":"","sources":["../src/enum.ts"],"names":[],"mappings":"AAwBA;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,UAAoB;IAC7C,MAAM,IAAI,GAAsB,EAAE,CAAC;IACnC,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QACpC,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;QACf,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,IAAI,CAAC,CAAC;AACX,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU,CACxB,GAAG,UAAgC;IAEnC,kCAAkC;IAClC,MAAM,aAAa,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAC7C,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CACjD,CAAC;IAEF,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,aAAa,CAAC,CAAC;AAC7C,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CACxB,GAAM,EACN,UAIY;IAEZ,OAAO,CACJ,MAAM,CAAC,IAAI,CAAC,GAAG,CAAiB;QAC/B,kBAAkB;SACjB,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;QAChD,cAAc;SACb,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,CACrB,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAGtB,CAAI;IACJ,OAAO,CAAC,CAAC;AACX,CAAC"}
|
package/build/enums.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HttpMethod = void 0;
|
|
4
1
|
// local
|
|
5
|
-
|
|
2
|
+
import { makeEnum } from './enum.js';
|
|
6
3
|
/**
|
|
7
4
|
* The http method types
|
|
8
5
|
*/
|
|
9
|
-
|
|
6
|
+
export const HttpMethod = makeEnum({
|
|
10
7
|
/** A get request */
|
|
11
8
|
Get: 'GET',
|
|
12
9
|
/** A post request */
|
package/build/enums.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enums.js","sourceRoot":"","sources":["../src/enums.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"enums.js","sourceRoot":"","sources":["../src/enums.ts"],"names":[],"mappings":"AAAA,QAAQ;AACR,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,QAAQ,CAAC;IACjC,oBAAoB;IACpB,GAAG,EAAE,KAAK;IACV,qBAAqB;IACrB,IAAI,EAAE,MAAM;IACZ,uBAAuB;IACvB,MAAM,EAAE,QAAQ;IAChB,oBAAoB;IACpB,GAAG,EAAE,KAAK;IACV,sBAAsB;IACtB,KAAK,EAAE,OAAO;CACf,CAAC,CAAC"}
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.findAllWithRegex = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Use a regex with the global flag to find all matches and return the list of matches with match groups mapped to parameter names
|
|
6
3
|
* @param regex - The regex definition and match attributes
|
|
7
4
|
* @param text - The text to find all in
|
|
8
5
|
* @returns The matches all converted to type T
|
|
9
6
|
*/
|
|
10
|
-
function findAllWithRegex(regex, text) {
|
|
7
|
+
export function findAllWithRegex(regex, text) {
|
|
11
8
|
// Validate the parameters
|
|
12
9
|
if (!regex.value.flags.includes('g')) {
|
|
13
10
|
throw new Error('Regex.value must have a g flag');
|
|
@@ -41,5 +38,4 @@ function findAllWithRegex(regex, text) {
|
|
|
41
38
|
}
|
|
42
39
|
return results;
|
|
43
40
|
}
|
|
44
|
-
exports.findAllWithRegex = findAllWithRegex;
|
|
45
41
|
//# sourceMappingURL=findAllWithRegex.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findAllWithRegex.js","sourceRoot":"","sources":["../src/findAllWithRegex.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"findAllWithRegex.js","sourceRoot":"","sources":["../src/findAllWithRegex.ts"],"names":[],"mappings":"AAiCA;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAC9B,KAAgC,EAChC,IAAY;IAEZ,0BAA0B;IAC1B,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QACrC,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;IACpD,CAAC;IAED,+BAA+B;IAC/B,MAAM,WAAW,GAAG,CAAC,WAAW,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC;IAEpD,cAAc;IACd,MAAM,OAAO,GAAoD,EAAE,CAAC;IAEpE,0BAA0B;IAC1B,IAAI,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACnC,IAAI,CAAC,GAAG,CAAC,CAAC;IAEV,wBAAwB;IACxB,OAAO,KAAK,EAAE,CAAC;QACb,0CAA0C;QAC1C,IAAI,WAAW,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,mBAAmB,EAAE,CAAC;YACtE,MAAM,IAAI,KAAK,CACb,sCAAsC,CAAC,OAAO,KAAK,CAAC,MAAM,mBAAmB,WAAW,CAAC,MAAM,GAAG,CACnG,CAAC;QACJ,CAAC;QAED,sEAAsE;QACtE,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CACzB,CAAC,GAAG,EAAE,WAAW,EAAE,GAAG,EAAE,EAAE,CACxB,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,EACzD,EAAE,CAC4C,CAAC;QAEjD,iBAAiB;QACjB,MAAM,CAAC,UAAU,GAAG,KAAK,CAAC,KAAK,CAAC;QAEhC,kCAAkC;QAClC,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;YACjB,MAAM,CAAC,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QACxD,CAAC;QAED,kBAAkB;QAClB,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAErB,oBAAoB;QACpB,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC/B,CAAC,IAAI,CAAC,CAAC;IACT,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/build/flattenObject.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// eslint-disable-next-line eslint-comments/disable-enable-pair
|
|
3
2
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
4
|
-
|
|
5
|
-
exports.flattenObject = void 0;
|
|
6
|
-
const aggregateObjects_1 = require("./aggregateObjects");
|
|
3
|
+
import { aggregateObjects } from './aggregateObjects.js';
|
|
7
4
|
/**
|
|
8
5
|
*
|
|
9
6
|
* Flattens a nested object into a single-level object with concatenated key names. Useful
|
|
@@ -30,7 +27,7 @@ const aggregateObjects_1 = require("./aggregateObjects");
|
|
|
30
27
|
* // user_hobbies: 'reading,gaming'
|
|
31
28
|
* // }
|
|
32
29
|
*/
|
|
33
|
-
const flattenObject = ({ obj, prefix = '', }) => !obj
|
|
30
|
+
export const flattenObject = ({ obj, prefix = '', }) => !obj
|
|
34
31
|
? {}
|
|
35
32
|
: Object.keys(obj !== null && obj !== void 0 ? obj : []).reduce((acc, key) => {
|
|
36
33
|
const newKey = prefix ? `${prefix}_${key}` : key;
|
|
@@ -41,9 +38,9 @@ const flattenObject = ({ obj, prefix = '', }) => !obj
|
|
|
41
38
|
entry.some((item) => typeof item === 'object' && item !== null)) {
|
|
42
39
|
// Flatten each object in the array
|
|
43
40
|
const objEntries = entry.filter((item) => typeof item === 'object' && item !== null);
|
|
44
|
-
const flattenedObjects = objEntries.map((item) =>
|
|
41
|
+
const flattenedObjects = objEntries.map((item) => flattenObject({ obj: item }));
|
|
45
42
|
// Aggregate the flattened objects
|
|
46
|
-
const aggregated =
|
|
43
|
+
const aggregated = aggregateObjects({ objs: flattenedObjects });
|
|
47
44
|
// Add prefix to all keys
|
|
48
45
|
Object.entries(aggregated).forEach(([k, v]) => {
|
|
49
46
|
acc[`${newKey}_${k}`] = v;
|
|
@@ -53,7 +50,7 @@ const flattenObject = ({ obj, prefix = '', }) => !obj
|
|
|
53
50
|
else if (typeof entry === 'object' &&
|
|
54
51
|
entry !== null &&
|
|
55
52
|
!Array.isArray(entry)) {
|
|
56
|
-
Object.assign(acc,
|
|
53
|
+
Object.assign(acc, flattenObject({ obj: entry, prefix: newKey }));
|
|
57
54
|
}
|
|
58
55
|
// Handle primitive arrays and other values
|
|
59
56
|
else {
|
|
@@ -72,5 +69,4 @@ const flattenObject = ({ obj, prefix = '', }) => !obj
|
|
|
72
69
|
}
|
|
73
70
|
return acc;
|
|
74
71
|
}, {});
|
|
75
|
-
exports.flattenObject = flattenObject;
|
|
76
72
|
//# sourceMappingURL=flattenObject.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flattenObject.js","sourceRoot":"","sources":["../src/flattenObject.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"flattenObject.js","sourceRoot":"","sources":["../src/flattenObject.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,uDAAuD;AAEvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,EAC5B,GAAG,EACH,MAAM,GAAG,EAAE,GAMZ,EAAO,EAAE,CACR,CAAC,GAAG;IACF,CAAC,CAAC,EAAE;IACJ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,aAAH,GAAG,cAAH,GAAG,GAAI,EAAE,CAAC,CAAC,MAAM,CAC3B,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QACX,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;QACjD,MAAM,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;QAEvB,2BAA2B;QAC3B,IACE,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;YACpB,KAAK,CAAC,MAAM,GAAG,CAAC;YAChB,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,CAAC,EAC/D,CAAC;YACD,mCAAmC;YACnC,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,CAC7B,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,CACpD,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AU,CAAC,GAAG,EAAE,EAAE,CAAC;oBAC3B,CAAC,CAAC,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,EAAE,CAAC;QAClB,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC,EACD,EAAyB,CAC1B,CAAC"}
|
package/build/fromEntries.js
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fromEntries = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Object.fromEntries that actually preserves entries as types.
|
|
6
3
|
* @param entries - The entries to build the object from
|
|
7
4
|
* @returns The object as built from the entries
|
|
8
5
|
*/
|
|
9
|
-
function fromEntries(entries) {
|
|
6
|
+
export function fromEntries(entries) {
|
|
10
7
|
return Object.fromEntries(entries);
|
|
11
8
|
}
|
|
12
|
-
exports.fromEntries = fromEntries;
|
|
13
9
|
//# sourceMappingURL=fromEntries.js.map
|
package/build/fromEntries.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fromEntries.js","sourceRoot":"","sources":["../src/fromEntries.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fromEntries.js","sourceRoot":"","sources":["../src/fromEntries.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAEzB,OAAU;IACV,OAAO,MAAM,CAAC,WAAW,CAAC,OAAO,CAAuC,CAAC;AAC3E,CAAC"}
|
package/build/getEntries.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getEntries.d.ts","sourceRoot":"","sources":["../src/getEntries.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"getEntries.d.ts","sourceRoot":"","sources":["../src/getEntries.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,SAAS,MAAM,IAAI,EAAE,IAAI,SAAS,WAAW,EAC1E,CAAC,EAAE,IAAI,GACN,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,CAGtB"}
|
package/build/getEntries.js
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getEntries = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Object.entries that actually preserves entries as types.
|
|
6
3
|
* @param o - The object to get the entries from
|
|
7
4
|
* @returns The entries of the object preserving type
|
|
8
5
|
*/
|
|
9
|
-
function getEntries(o) {
|
|
6
|
+
export function getEntries(o) {
|
|
10
7
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11
8
|
return Object.entries(o);
|
|
12
9
|
}
|
|
13
|
-
exports.getEntries = getEntries;
|
|
14
10
|
//# sourceMappingURL=getEntries.js.map
|
package/build/getEntries.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getEntries.js","sourceRoot":"","sources":["../src/getEntries.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getEntries.js","sourceRoot":"","sources":["../src/getEntries.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,MAAM,UAAU,UAAU,CACxB,CAAO;IAEP,8DAA8D;IAC9D,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC,CAAQ,CAAC;AAClC,CAAC"}
|
package/build/getKeys.d.ts
CHANGED
package/build/getKeys.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getKeys.d.ts","sourceRoot":"","sources":["../src/getKeys.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"getKeys.d.ts","sourceRoot":"","sources":["../src/getKeys.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAG7C;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,EAAE,CAEjE;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE,CAEvD"}
|
package/build/getKeys.js
CHANGED
|
@@ -1,24 +1,19 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getKeys = exports.getStringKeys = void 0;
|
|
4
1
|
/* eslint-disable @typescript-eslint/ban-types */
|
|
5
2
|
/**
|
|
6
3
|
* Object.keys for string keys only
|
|
7
4
|
* @param o - The object to get the keys from
|
|
8
5
|
* @returns The string keys of the object preserving type
|
|
9
6
|
*/
|
|
10
|
-
function getStringKeys(o) {
|
|
7
|
+
export function getStringKeys(o) {
|
|
11
8
|
return Object.keys(o).filter((k) => typeof k === 'string');
|
|
12
9
|
}
|
|
13
|
-
exports.getStringKeys = getStringKeys;
|
|
14
10
|
/**
|
|
15
11
|
* Object.keys that actually preserves keys as types.
|
|
16
12
|
* @param o - The object to get the keys from
|
|
17
13
|
* @returns The keys of the object preserving type
|
|
18
14
|
*/
|
|
19
|
-
function getKeys(o) {
|
|
15
|
+
export function getKeys(o) {
|
|
20
16
|
return Object.keys(o);
|
|
21
17
|
}
|
|
22
|
-
exports.getKeys = getKeys;
|
|
23
18
|
/* eslint-enable @typescript-eslint/ban-types */
|
|
24
19
|
//# sourceMappingURL=getKeys.js.map
|
package/build/getKeys.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getKeys.js","sourceRoot":"","sources":["../src/getKeys.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getKeys.js","sourceRoot":"","sources":["../src/getKeys.ts"],"names":[],"mappings":"AAGA,iDAAiD;AACjD;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAe,CAAI;IAC9C,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAoB,CAAC;AAChF,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,OAAO,CAAe,CAAI;IACxC,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,CAAgB,CAAC;AACvC,CAAC;AACD,gDAAgD"}
|
package/build/getValues.js
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getValues = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Object.values that actually preserves values as types.
|
|
6
3
|
* @param o - The object to get the values from
|
|
7
4
|
* @returns The values of the object preserving type
|
|
8
5
|
*/
|
|
9
|
-
function getValues(o) {
|
|
6
|
+
export function getValues(o) {
|
|
10
7
|
return Object.values(o);
|
|
11
8
|
}
|
|
12
|
-
exports.getValues = getValues;
|
|
13
9
|
//# sourceMappingURL=getValues.js.map
|
package/build/getValues.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getValues.js","sourceRoot":"","sources":["../src/getValues.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getValues.js","sourceRoot":"","sources":["../src/getValues.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAO,CAE/B;IACC,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,CAAW,CAAC;AACpC,CAAC"}
|
package/build/gql.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.gql = exports.INTERFACE_REGEX = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Identify if a string is an interface
|
|
6
3
|
*/
|
|
7
|
-
|
|
4
|
+
export const INTERFACE_REGEX = /(interface|type|input) [a-zA-Z0-9]* (implements .+?|){([\s\S]+?)}/;
|
|
8
5
|
/**
|
|
9
6
|
* Create a gql tag. This may one day be replaced by apollo graphql-tag.
|
|
10
7
|
* I like being able to create un-named fragments that can be constructed into a graphql statement.
|
|
@@ -14,7 +11,7 @@ exports.INTERFACE_REGEX = /(interface|type|input) [a-zA-Z0-9]* (implements .+?|)
|
|
|
14
11
|
* @param expressions - The expressions injected into the template
|
|
15
12
|
* @returns The gql string that was the inputs
|
|
16
13
|
*/
|
|
17
|
-
function gql(strings, ...expressions) {
|
|
14
|
+
export function gql(strings, ...expressions) {
|
|
18
15
|
// If there are no expressions included in the literal
|
|
19
16
|
if (expressions.length === 0) {
|
|
20
17
|
return strings[0];
|
|
@@ -24,13 +21,12 @@ function gql(strings, ...expressions) {
|
|
|
24
21
|
for (let i = 0; i < n; i += 1) {
|
|
25
22
|
const expression = expressions[i];
|
|
26
23
|
// Get properties from an interface
|
|
27
|
-
const useExpression =
|
|
28
|
-
? (
|
|
24
|
+
const useExpression = INTERFACE_REGEX.test(typeof expression === 'string' ? expression : expression.toString())
|
|
25
|
+
? (INTERFACE_REGEX.exec(typeof expression === 'string' ? expression : expression.toString()) || [])[3]
|
|
29
26
|
: expression;
|
|
30
27
|
result += strings[i] + useExpression;
|
|
31
28
|
}
|
|
32
29
|
result += strings[n];
|
|
33
30
|
return result;
|
|
34
31
|
}
|
|
35
|
-
exports.gql = gql;
|
|
36
32
|
//# sourceMappingURL=gql.js.map
|
package/build/gql.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gql.js","sourceRoot":"","sources":["../src/gql.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"gql.js","sourceRoot":"","sources":["../src/gql.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAC1B,mEAAmE,CAAC;AAUtE;;;;;;;;GAQG;AACH,MAAM,UAAU,GAAG,CACjB,OAA6B,EAC7B,GAAG,WAAgC;IAEnC,sDAAsD;IACtD,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC7B,OAAO,OAAO,CAAC,CAAC,CAAsB,CAAC;IACzC,CAAC;IACD,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;IAC7B,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QAC9B,MAAM,UAAU,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;QAClC,mCAAmC;QACnC,MAAM,aAAa,GAAG,eAAe,CAAC,IAAI,CACxC,OAAO,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,QAAQ,EAAE,CACpE;YACC,CAAC,CAAC,CAAC,eAAe,CAAC,IAAI,CACnB,OAAO,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,QAAQ,EAAE,CACpE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;YACb,CAAC,CAAC,UAAU,CAAC;QACf,MAAM,IAAI,OAAO,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC;IACvC,CAAC;IACD,MAAM,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC;IACrB,OAAO,MAA2B,CAAC;AACrC,CAAC"}
|
package/build/groupBy.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.groupBy = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* A typed version of lodash's _.groupBy.
|
|
6
3
|
*
|
|
@@ -10,7 +7,7 @@ exports.groupBy = void 0;
|
|
|
10
7
|
* @param getKey - the function to apply to an element of the list to get the key it should belong in
|
|
11
8
|
* @returns a map of identifiers to values that mapped to that identifier
|
|
12
9
|
*/
|
|
13
|
-
function groupBy(iterable, getKey) {
|
|
10
|
+
export function groupBy(iterable, getKey) {
|
|
14
11
|
return iterable.reduce((groupedItems, item) => {
|
|
15
12
|
var _a;
|
|
16
13
|
const groupedKey = getKey(item);
|
|
@@ -20,5 +17,4 @@ function groupBy(iterable, getKey) {
|
|
|
20
17
|
]);
|
|
21
18
|
}, new Map());
|
|
22
19
|
}
|
|
23
|
-
exports.groupBy = groupBy;
|
|
24
20
|
//# sourceMappingURL=groupBy.js.map
|
package/build/groupBy.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"groupBy.js","sourceRoot":"","sources":["../src/groupBy.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"groupBy.js","sourceRoot":"","sources":["../src/groupBy.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,UAAU,OAAO,CACrB,QAAa,EACb,MAAsB;IAEtB,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,YAAY,EAAE,IAAI,EAAE,EAAE;;QAC5C,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;QAChC,OAAO,YAAY,CAAC,GAAG,CAAC,UAAU,EAAE;YAClC,GAAG,CAAC,MAAA,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC,mCAAI,EAAE,CAAC;YACvC,IAAI;SACL,CAAC,CAAC;IACL,CAAC,EAAE,IAAI,GAAG,EAAU,CAAC,CAAC;AACxB,CAAC"}
|
package/build/index.d.ts
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
export * from './apply';
|
|
2
|
-
export * from './codecTools';
|
|
3
|
-
export * from './enum';
|
|
4
|
-
export * from './enums';
|
|
5
|
-
export * from './getEntries';
|
|
6
|
-
export * from './getKeys';
|
|
7
|
-
export * from './getValues';
|
|
8
|
-
export * from './groupBy';
|
|
9
|
-
export * from './gql';
|
|
10
|
-
export * from './invert';
|
|
11
|
-
export * from './types';
|
|
12
|
-
export * from './valuesOf';
|
|
13
|
-
export * from './findAllWithRegex';
|
|
14
|
-
export * from './flattenObject';
|
|
15
|
-
export * from './aggregateObjects';
|
|
16
|
-
export * from './transposeObjectArray';
|
|
17
|
-
export * from './fromEntries';
|
|
1
|
+
export * from './apply.js';
|
|
2
|
+
export * from './codecTools/index.js';
|
|
3
|
+
export * from './enum.js';
|
|
4
|
+
export * from './enums.js';
|
|
5
|
+
export * from './getEntries.js';
|
|
6
|
+
export * from './getKeys.js';
|
|
7
|
+
export * from './getValues.js';
|
|
8
|
+
export * from './groupBy.js';
|
|
9
|
+
export * from './gql.js';
|
|
10
|
+
export * from './invert.js';
|
|
11
|
+
export * from './types.js';
|
|
12
|
+
export * from './valuesOf.js';
|
|
13
|
+
export * from './findAllWithRegex.js';
|
|
14
|
+
export * from './flattenObject.js';
|
|
15
|
+
export * from './aggregateObjects.js';
|
|
16
|
+
export * from './transposeObjectArray.js';
|
|
17
|
+
export * from './fromEntries.js';
|
|
18
|
+
export * from './noExcess.js';
|
|
18
19
|
//# sourceMappingURL=index.d.ts.map
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,uBAAuB,CAAC;AACtC,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC"}
|
package/build/index.js
CHANGED
|
@@ -1,34 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
__exportStar(require("./enum"), exports);
|
|
20
|
-
__exportStar(require("./enums"), exports);
|
|
21
|
-
__exportStar(require("./getEntries"), exports);
|
|
22
|
-
__exportStar(require("./getKeys"), exports);
|
|
23
|
-
__exportStar(require("./getValues"), exports);
|
|
24
|
-
__exportStar(require("./groupBy"), exports);
|
|
25
|
-
__exportStar(require("./gql"), exports);
|
|
26
|
-
__exportStar(require("./invert"), exports);
|
|
27
|
-
__exportStar(require("./types"), exports);
|
|
28
|
-
__exportStar(require("./valuesOf"), exports);
|
|
29
|
-
__exportStar(require("./findAllWithRegex"), exports);
|
|
30
|
-
__exportStar(require("./flattenObject"), exports);
|
|
31
|
-
__exportStar(require("./aggregateObjects"), exports);
|
|
32
|
-
__exportStar(require("./transposeObjectArray"), exports);
|
|
33
|
-
__exportStar(require("./fromEntries"), exports);
|
|
1
|
+
export * from './apply.js';
|
|
2
|
+
export * from './codecTools/index.js';
|
|
3
|
+
export * from './enum.js';
|
|
4
|
+
export * from './enums.js';
|
|
5
|
+
export * from './getEntries.js';
|
|
6
|
+
export * from './getKeys.js';
|
|
7
|
+
export * from './getValues.js';
|
|
8
|
+
export * from './groupBy.js';
|
|
9
|
+
export * from './gql.js';
|
|
10
|
+
export * from './invert.js';
|
|
11
|
+
export * from './types.js';
|
|
12
|
+
export * from './valuesOf.js';
|
|
13
|
+
export * from './findAllWithRegex.js';
|
|
14
|
+
export * from './flattenObject.js';
|
|
15
|
+
export * from './aggregateObjects.js';
|
|
16
|
+
export * from './transposeObjectArray.js';
|
|
17
|
+
export * from './fromEntries.js';
|
|
18
|
+
export * from './noExcess.js';
|
|
34
19
|
//# sourceMappingURL=index.js.map
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,uBAAuB,CAAC;AACtC,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC"}
|