@visulima/object 1.0.6 → 1.0.8
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 +26 -0
- package/LICENSE.md +122 -0
- package/README.md +8 -8
- package/dist/index.cjs +187 -1
- package/dist/index.d.cts +105 -97
- package/dist/index.d.mts +105 -97
- package/dist/index.d.ts +105 -97
- package/dist/index.mjs +176 -1
- package/dist/packem_shared/getProperty-BuSUBWTY.cjs +278 -0
- package/dist/packem_shared/getProperty-CqSBQFGO.mjs +269 -0
- package/dist/packem_shared/isPlainObject-BEp1xndO.mjs +12 -0
- package/dist/packem_shared/isPlainObject-D2hOGcuW.cjs +14 -0
- package/dist/packem_shared/omit-Bz46-jv-.mjs +38 -0
- package/dist/packem_shared/omit-DSwyUtN2.cjs +40 -0
- package/dist/packem_shared/paths-are-equal-BvHTDEDJ.cjs +15 -0
- package/dist/packem_shared/paths-are-equal-DY1QWTwZ.mjs +13 -0
- package/dist/packem_shared/pick-BX11mP2m.cjs +52 -0
- package/dist/packem_shared/pick-C9-E3eDJ.mjs +50 -0
- package/package.json +18 -18
- package/dist/packem_shared/getProperty-C5Q_YpVO.mjs +0 -1
- package/dist/packem_shared/getProperty-D34HTBAJ.cjs +0 -1
- package/dist/packem_shared/isPlainObject-BTLAczOE.cjs +0 -1
- package/dist/packem_shared/isPlainObject-CFPUbgRS.mjs +0 -1
- package/dist/packem_shared/omit-Cwc8rJUb.cjs +0 -1
- package/dist/packem_shared/omit-Df-0bpNu.mjs +0 -1
- package/dist/packem_shared/paths-are-equal-BgwMgI_D.mjs +0 -1
- package/dist/packem_shared/paths-are-equal-D8teV-Y-.cjs +0 -1
- package/dist/packem_shared/pick-CS1_JC9v.mjs +0 -1
- package/dist/packem_shared/pick-CkwC0jUm.cjs +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,29 @@
|
|
|
1
|
+
## @visulima/object [1.0.8](https://github.com/visulima/visulima/compare/@visulima/object@1.0.7...@visulima/object@1.0.8) (2025-01-12)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
* updated @visulima/packem, and all other dev dependencies ([7797a1c](https://github.com/visulima/visulima/commit/7797a1c3e6f1fc532895247bd88285a8a9883c40))
|
|
6
|
+
|
|
7
|
+
### Miscellaneous Chores
|
|
8
|
+
|
|
9
|
+
* updated dev dependencies ([9de2eab](https://github.com/visulima/visulima/commit/9de2eab91e95c8b9289d12f863a5167218770650))
|
|
10
|
+
|
|
11
|
+
## @visulima/object [1.0.7](https://github.com/visulima/visulima/compare/@visulima/object@1.0.6...@visulima/object@1.0.7) (2024-12-12)
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* allow node v23 ([8ca929a](https://github.com/visulima/visulima/commit/8ca929af311ce8036cbbfde68b6db05381b860a5))
|
|
16
|
+
* allowed node 23, updated dev dependencies ([f99d34e](https://github.com/visulima/visulima/commit/f99d34e01f6b13be8586a1b5d37dc8b8df0a5817))
|
|
17
|
+
* updated packem to v1.8.2 ([23f869b](https://github.com/visulima/visulima/commit/23f869b4120856cc97e2bffa6d508e2ae30420ea))
|
|
18
|
+
|
|
19
|
+
### Styles
|
|
20
|
+
|
|
21
|
+
* cs fixes ([46d31e0](https://github.com/visulima/visulima/commit/46d31e082e1865262bf380859c14fabd28ff456d))
|
|
22
|
+
|
|
23
|
+
### Miscellaneous Chores
|
|
24
|
+
|
|
25
|
+
* updated dev dependencies ([a916944](https://github.com/visulima/visulima/commit/a916944b888bb34c34b0c54328b38d29e4399857))
|
|
26
|
+
|
|
1
27
|
## @visulima/object [1.0.6](https://github.com/visulima/visulima/compare/@visulima/object@1.0.5...@visulima/object@1.0.6) (2024-10-05)
|
|
2
28
|
|
|
3
29
|
### Bug Fixes
|
package/LICENSE.md
CHANGED
|
@@ -121,4 +121,126 @@ License: (MIT OR CC0-1.0)
|
|
|
121
121
|
By: Sindre Sorhus
|
|
122
122
|
Repository: sindresorhus/type-fest
|
|
123
123
|
|
|
124
|
+
> Creative Commons Legal Code
|
|
125
|
+
>
|
|
126
|
+
> CC0 1.0 Universal
|
|
127
|
+
>
|
|
128
|
+
> CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
|
|
129
|
+
> LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
|
|
130
|
+
> ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
|
|
131
|
+
> INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
|
|
132
|
+
> REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
|
|
133
|
+
> PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
|
|
134
|
+
> THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
|
|
135
|
+
> HEREUNDER.
|
|
136
|
+
>
|
|
137
|
+
> Statement of Purpose
|
|
138
|
+
>
|
|
139
|
+
> The laws of most jurisdictions throughout the world automatically confer
|
|
140
|
+
> exclusive Copyright and Related Rights (defined below) upon the creator
|
|
141
|
+
> and subsequent owner(s) (each and all, an "owner") of an original work of
|
|
142
|
+
> authorship and/or a database (each, a "Work").
|
|
143
|
+
>
|
|
144
|
+
> Certain owners wish to permanently relinquish those rights to a Work for
|
|
145
|
+
> the purpose of contributing to a commons of creative, cultural and
|
|
146
|
+
> scientific works ("Commons") that the public can reliably and without fear
|
|
147
|
+
> of later claims of infringement build upon, modify, incorporate in other
|
|
148
|
+
> works, reuse and redistribute as freely as possible in any form whatsoever
|
|
149
|
+
> and for any purposes, including without limitation commercial purposes.
|
|
150
|
+
> These owners may contribute to the Commons to promote the ideal of a free
|
|
151
|
+
> culture and the further production of creative, cultural and scientific
|
|
152
|
+
> works, or to gain reputation or greater distribution for their Work in
|
|
153
|
+
> part through the use and efforts of others.
|
|
154
|
+
>
|
|
155
|
+
> For these and/or other purposes and motivations, and without any
|
|
156
|
+
> expectation of additional consideration or compensation, the person
|
|
157
|
+
> associating CC0 with a Work (the "Affirmer"), to the extent that he or she
|
|
158
|
+
> is an owner of Copyright and Related Rights in the Work, voluntarily
|
|
159
|
+
> elects to apply CC0 to the Work and publicly distribute the Work under its
|
|
160
|
+
> terms, with knowledge of his or her Copyright and Related Rights in the
|
|
161
|
+
> Work and the meaning and intended legal effect of CC0 on those rights.
|
|
162
|
+
>
|
|
163
|
+
> 1. Copyright and Related Rights. A Work made available under CC0 may be
|
|
164
|
+
> protected by copyright and related or neighboring rights ("Copyright and
|
|
165
|
+
> Related Rights"). Copyright and Related Rights include, but are not
|
|
166
|
+
> limited to, the following:
|
|
167
|
+
>
|
|
168
|
+
> i. the right to reproduce, adapt, distribute, perform, display,
|
|
169
|
+
> communicate, and translate a Work;
|
|
170
|
+
> ii. moral rights retained by the original author(s) and/or performer(s);
|
|
171
|
+
> iii. publicity and privacy rights pertaining to a person's image or
|
|
172
|
+
> likeness depicted in a Work;
|
|
173
|
+
> iv. rights protecting against unfair competition in regards to a Work,
|
|
174
|
+
> subject to the limitations in paragraph 4(a), below;
|
|
175
|
+
> v. rights protecting the extraction, dissemination, use and reuse of data
|
|
176
|
+
> in a Work;
|
|
177
|
+
> vi. database rights (such as those arising under Directive 96/9/EC of the
|
|
178
|
+
> European Parliament and of the Council of 11 March 1996 on the legal
|
|
179
|
+
> protection of databases, and under any national implementation
|
|
180
|
+
> thereof, including any amended or successor version of such
|
|
181
|
+
> directive); and
|
|
182
|
+
> vii. other similar, equivalent or corresponding rights throughout the
|
|
183
|
+
> world based on applicable law or treaty, and any national
|
|
184
|
+
> implementations thereof.
|
|
185
|
+
>
|
|
186
|
+
> 2. Waiver. To the greatest extent permitted by, but not in contravention
|
|
187
|
+
> of, applicable law, Affirmer hereby overtly, fully, permanently,
|
|
188
|
+
> irrevocably and unconditionally waives, abandons, and surrenders all of
|
|
189
|
+
> Affirmer's Copyright and Related Rights and associated claims and causes
|
|
190
|
+
> of action, whether now known or unknown (including existing as well as
|
|
191
|
+
> future claims and causes of action), in the Work (i) in all territories
|
|
192
|
+
> worldwide, (ii) for the maximum duration provided by applicable law or
|
|
193
|
+
> treaty (including future time extensions), (iii) in any current or future
|
|
194
|
+
> medium and for any number of copies, and (iv) for any purpose whatsoever,
|
|
195
|
+
> including without limitation commercial, advertising or promotional
|
|
196
|
+
> purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
|
|
197
|
+
> member of the public at large and to the detriment of Affirmer's heirs and
|
|
198
|
+
> successors, fully intending that such Waiver shall not be subject to
|
|
199
|
+
> revocation, rescission, cancellation, termination, or any other legal or
|
|
200
|
+
> equitable action to disrupt the quiet enjoyment of the Work by the public
|
|
201
|
+
> as contemplated by Affirmer's express Statement of Purpose.
|
|
202
|
+
>
|
|
203
|
+
> 3. Public License Fallback. Should any part of the Waiver for any reason
|
|
204
|
+
> be judged legally invalid or ineffective under applicable law, then the
|
|
205
|
+
> Waiver shall be preserved to the maximum extent permitted taking into
|
|
206
|
+
> account Affirmer's express Statement of Purpose. In addition, to the
|
|
207
|
+
> extent the Waiver is so judged Affirmer hereby grants to each affected
|
|
208
|
+
> person a royalty-free, non transferable, non sublicensable, non exclusive,
|
|
209
|
+
> irrevocable and unconditional license to exercise Affirmer's Copyright and
|
|
210
|
+
> Related Rights in the Work (i) in all territories worldwide, (ii) for the
|
|
211
|
+
> maximum duration provided by applicable law or treaty (including future
|
|
212
|
+
> time extensions), (iii) in any current or future medium and for any number
|
|
213
|
+
> of copies, and (iv) for any purpose whatsoever, including without
|
|
214
|
+
> limitation commercial, advertising or promotional purposes (the
|
|
215
|
+
> "License"). The License shall be deemed effective as of the date CC0 was
|
|
216
|
+
> applied by Affirmer to the Work. Should any part of the License for any
|
|
217
|
+
> reason be judged legally invalid or ineffective under applicable law, such
|
|
218
|
+
> partial invalidity or ineffectiveness shall not invalidate the remainder
|
|
219
|
+
> of the License, and in such case Affirmer hereby affirms that he or she
|
|
220
|
+
> will not (i) exercise any of his or her remaining Copyright and Related
|
|
221
|
+
> Rights in the Work or (ii) assert any associated claims and causes of
|
|
222
|
+
> action with respect to the Work, in either case contrary to Affirmer's
|
|
223
|
+
> express Statement of Purpose.
|
|
224
|
+
>
|
|
225
|
+
> 4. Limitations and Disclaimers.
|
|
226
|
+
>
|
|
227
|
+
> a. No trademark or patent rights held by Affirmer are waived, abandoned,
|
|
228
|
+
> surrendered, licensed or otherwise affected by this document.
|
|
229
|
+
> b. Affirmer offers the Work as-is and makes no representations or
|
|
230
|
+
> warranties of any kind concerning the Work, express, implied,
|
|
231
|
+
> statutory or otherwise, including without limitation warranties of
|
|
232
|
+
> title, merchantability, fitness for a particular purpose, non
|
|
233
|
+
> infringement, or the absence of latent or other defects, accuracy, or
|
|
234
|
+
> the present or absence of errors, whether or not discoverable, all to
|
|
235
|
+
> the greatest extent permissible under applicable law.
|
|
236
|
+
> c. Affirmer disclaims responsibility for clearing rights of other persons
|
|
237
|
+
> that may apply to the Work or any use thereof, including without
|
|
238
|
+
> limitation any person's Copyright and Related Rights in the Work.
|
|
239
|
+
> Further, Affirmer disclaims responsibility for obtaining any necessary
|
|
240
|
+
> consents, permissions or other rights required for any use of the
|
|
241
|
+
> Work.
|
|
242
|
+
> d. Affirmer understands and acknowledges that Creative Commons is not a
|
|
243
|
+
> party to this document and has no duty or obligation with respect to
|
|
244
|
+
> this CC0 or use of the Work.
|
|
245
|
+
|
|
124
246
|
<!-- /TYPE_DEPENDENCIES -->
|
package/README.md
CHANGED
|
@@ -101,12 +101,12 @@ omit(doc, ["items.discard"]);
|
|
|
101
101
|
|
|
102
102
|
## Related
|
|
103
103
|
|
|
104
|
-
-
|
|
105
|
-
-
|
|
106
|
-
-
|
|
107
|
-
-
|
|
108
|
-
-
|
|
109
|
-
-
|
|
104
|
+
- [is-plain-object](https://github.com/jonschlinkert/is-plain-object) - Returns true if the given value is an object created by the Object constructor.
|
|
105
|
+
- [is-plain-obj][is-plain-obj] - Check if a value is a plain object.
|
|
106
|
+
- [dot-prop][dot-prop] - Get, set, or delete a property from a nested object using a dot path.
|
|
107
|
+
- [ts-dot-prop](https://github.com/justinlettau/ts-dot-prop) - TypeScript utility to transform nested objects using a dot notation path.
|
|
108
|
+
- [dset](https://www.npmjs.com/package/dset) - A tiny (194B) utility for safely writing deep Object values~!
|
|
109
|
+
- [filter-anything](https://github.com/mesqueeb/filter-anything) - A simple (TypeScript) integration of "pick" and "omit" to filter props of an object.
|
|
110
110
|
|
|
111
111
|
## Supported Node.js Versions
|
|
112
112
|
|
|
@@ -121,8 +121,8 @@ If you would like to help take a look at the [list of issues](https://github.com
|
|
|
121
121
|
|
|
122
122
|
## Credits
|
|
123
123
|
|
|
124
|
-
-
|
|
125
|
-
-
|
|
124
|
+
- [Daniel Bannert](https://github.com/prisis)
|
|
125
|
+
- [All Contributors](https://github.com/visulima/visulima/graphs/contributors)
|
|
126
126
|
|
|
127
127
|
## License
|
|
128
128
|
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1,187 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
4
|
+
|
|
5
|
+
const omit = require('./packem_shared/omit-DSwyUtN2.cjs');
|
|
6
|
+
const pick = require('./packem_shared/pick-BX11mP2m.cjs');
|
|
7
|
+
const getProperty = require('./packem_shared/getProperty-BuSUBWTY.cjs');
|
|
8
|
+
const isPlainObject = require('./packem_shared/isPlainObject-D2hOGcuW.cjs');
|
|
9
|
+
|
|
10
|
+
var deeks = {};
|
|
11
|
+
|
|
12
|
+
var utils = {};
|
|
13
|
+
|
|
14
|
+
var hasRequiredUtils;
|
|
15
|
+
|
|
16
|
+
function requireUtils () {
|
|
17
|
+
if (hasRequiredUtils) return utils;
|
|
18
|
+
hasRequiredUtils = 1;
|
|
19
|
+
var __defProp = Object.defineProperty;
|
|
20
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
21
|
+
Object.defineProperty(utils, "__esModule", { value: true });
|
|
22
|
+
utils.isDocumentToRecurOn = utils.flatten = utils.unique = undefined;
|
|
23
|
+
function unique(array) {
|
|
24
|
+
return [...new Set(array)];
|
|
25
|
+
}
|
|
26
|
+
__name(unique, "unique");
|
|
27
|
+
utils.unique = unique;
|
|
28
|
+
function flatten(array) {
|
|
29
|
+
return [].concat(...array);
|
|
30
|
+
}
|
|
31
|
+
__name(flatten, "flatten");
|
|
32
|
+
utils.flatten = flatten;
|
|
33
|
+
function isDocumentToRecurOn(val) {
|
|
34
|
+
return typeof val === "object" && val !== null && !Array.isArray(val) && Object.keys(val).length;
|
|
35
|
+
}
|
|
36
|
+
__name(isDocumentToRecurOn, "isDocumentToRecurOn");
|
|
37
|
+
utils.isDocumentToRecurOn = isDocumentToRecurOn;
|
|
38
|
+
return utils;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
var types = {};
|
|
42
|
+
|
|
43
|
+
var hasRequiredTypes;
|
|
44
|
+
|
|
45
|
+
function requireTypes () {
|
|
46
|
+
if (hasRequiredTypes) return types;
|
|
47
|
+
hasRequiredTypes = 1;
|
|
48
|
+
Object.defineProperty(types, "__esModule", { value: true });
|
|
49
|
+
return types;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
var hasRequiredDeeks;
|
|
53
|
+
|
|
54
|
+
function requireDeeks () {
|
|
55
|
+
if (hasRequiredDeeks) return deeks;
|
|
56
|
+
hasRequiredDeeks = 1;
|
|
57
|
+
(function (exports) {
|
|
58
|
+
var __defProp = Object.defineProperty;
|
|
59
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
60
|
+
var __createBinding = deeks.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
61
|
+
if (k2 === undefined) k2 = k;
|
|
62
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
63
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
64
|
+
desc = { enumerable: true, get: /* @__PURE__ */ __name(function() {
|
|
65
|
+
return m[k];
|
|
66
|
+
}, "get") };
|
|
67
|
+
}
|
|
68
|
+
Object.defineProperty(o, k2, desc);
|
|
69
|
+
} : function(o, m, k, k2) {
|
|
70
|
+
if (k2 === undefined) k2 = k;
|
|
71
|
+
o[k2] = m[k];
|
|
72
|
+
});
|
|
73
|
+
var __setModuleDefault = deeks.__setModuleDefault || (Object.create ? function(o, v) {
|
|
74
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
75
|
+
} : function(o, v) {
|
|
76
|
+
o["default"] = v;
|
|
77
|
+
});
|
|
78
|
+
var __importStar = deeks.__importStar || function(mod) {
|
|
79
|
+
if (mod && mod.__esModule) return mod;
|
|
80
|
+
var result = {};
|
|
81
|
+
if (mod != null) {
|
|
82
|
+
for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
83
|
+
}
|
|
84
|
+
__setModuleDefault(result, mod);
|
|
85
|
+
return result;
|
|
86
|
+
};
|
|
87
|
+
var __exportStar = deeks.__exportStar || function(m, exports2) {
|
|
88
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p)) __createBinding(exports2, m, p);
|
|
89
|
+
};
|
|
90
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
91
|
+
exports.deepKeysFromList = exports.deepKeys = undefined;
|
|
92
|
+
const utils = __importStar(requireUtils());
|
|
93
|
+
__exportStar(requireTypes(), exports);
|
|
94
|
+
function deepKeys(object, options) {
|
|
95
|
+
const parsedOptions = mergeOptions(options);
|
|
96
|
+
if (typeof object === "object" && object !== null) {
|
|
97
|
+
return generateDeepKeysList("", object, parsedOptions);
|
|
98
|
+
}
|
|
99
|
+
return [];
|
|
100
|
+
}
|
|
101
|
+
__name(deepKeys, "deepKeys");
|
|
102
|
+
exports.deepKeys = deepKeys;
|
|
103
|
+
function deepKeysFromList(list, options) {
|
|
104
|
+
const parsedOptions = mergeOptions(options);
|
|
105
|
+
return list.map((document) => {
|
|
106
|
+
if (typeof document === "object" && document !== null) {
|
|
107
|
+
return deepKeys(document, parsedOptions);
|
|
108
|
+
}
|
|
109
|
+
return [];
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
__name(deepKeysFromList, "deepKeysFromList");
|
|
113
|
+
exports.deepKeysFromList = deepKeysFromList;
|
|
114
|
+
function generateDeepKeysList(heading, data, options) {
|
|
115
|
+
const keys = Object.keys(data).map((currentKey) => {
|
|
116
|
+
const keyName = buildKeyName(heading, escapeNestedDotsIfSpecified(currentKey, options));
|
|
117
|
+
if (options.expandNestedObjects && utils.isDocumentToRecurOn(data[currentKey]) || options.arrayIndexesAsKeys && Array.isArray(data[currentKey]) && data[currentKey].length) {
|
|
118
|
+
return generateDeepKeysList(keyName, data[currentKey], options);
|
|
119
|
+
} else if (options.expandArrayObjects && Array.isArray(data[currentKey])) {
|
|
120
|
+
return processArrayKeys(data[currentKey], keyName, options);
|
|
121
|
+
} else if (options.ignoreEmptyArrays && Array.isArray(data[currentKey]) && !data[currentKey].length) {
|
|
122
|
+
return [];
|
|
123
|
+
}
|
|
124
|
+
return keyName;
|
|
125
|
+
});
|
|
126
|
+
return utils.flatten(keys);
|
|
127
|
+
}
|
|
128
|
+
__name(generateDeepKeysList, "generateDeepKeysList");
|
|
129
|
+
function processArrayKeys(subArray, currentKeyPath, options) {
|
|
130
|
+
let subArrayKeys = deepKeysFromList(subArray, options);
|
|
131
|
+
if (!subArray.length) {
|
|
132
|
+
return options.ignoreEmptyArraysWhenExpanding ? [] : [currentKeyPath];
|
|
133
|
+
} else if (subArray.length && utils.flatten(subArrayKeys).length === 0) {
|
|
134
|
+
return [currentKeyPath];
|
|
135
|
+
} else {
|
|
136
|
+
subArrayKeys = subArrayKeys.map((schemaKeys) => {
|
|
137
|
+
if (Array.isArray(schemaKeys) && schemaKeys.length === 0) {
|
|
138
|
+
return [currentKeyPath];
|
|
139
|
+
}
|
|
140
|
+
return schemaKeys.map((subKey) => buildKeyName(currentKeyPath, escapeNestedDotsIfSpecified(subKey, options)));
|
|
141
|
+
});
|
|
142
|
+
return utils.unique(utils.flatten(subArrayKeys));
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
__name(processArrayKeys, "processArrayKeys");
|
|
146
|
+
function escapeNestedDotsIfSpecified(key, options) {
|
|
147
|
+
if (options.escapeNestedDots) {
|
|
148
|
+
return key.replace(/\./g, "\\.");
|
|
149
|
+
}
|
|
150
|
+
return key;
|
|
151
|
+
}
|
|
152
|
+
__name(escapeNestedDotsIfSpecified, "escapeNestedDotsIfSpecified");
|
|
153
|
+
function buildKeyName(upperKeyName, currentKeyName) {
|
|
154
|
+
if (upperKeyName) {
|
|
155
|
+
return upperKeyName + "." + currentKeyName;
|
|
156
|
+
}
|
|
157
|
+
return currentKeyName;
|
|
158
|
+
}
|
|
159
|
+
__name(buildKeyName, "buildKeyName");
|
|
160
|
+
function mergeOptions(options) {
|
|
161
|
+
return {
|
|
162
|
+
arrayIndexesAsKeys: false,
|
|
163
|
+
expandNestedObjects: true,
|
|
164
|
+
expandArrayObjects: false,
|
|
165
|
+
ignoreEmptyArraysWhenExpanding: false,
|
|
166
|
+
escapeNestedDots: false,
|
|
167
|
+
ignoreEmptyArrays: false,
|
|
168
|
+
...options ?? {}
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
__name(mergeOptions, "mergeOptions");
|
|
172
|
+
} (deeks));
|
|
173
|
+
return deeks;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
var deeksExports = requireDeeks();
|
|
177
|
+
|
|
178
|
+
exports.omit = omit;
|
|
179
|
+
exports.pick = pick;
|
|
180
|
+
exports.deleteProperty = getProperty.deleteProperty;
|
|
181
|
+
exports.escapePath = getProperty.escapePath;
|
|
182
|
+
exports.getProperty = getProperty.getProperty;
|
|
183
|
+
exports.hasProperty = getProperty.hasProperty;
|
|
184
|
+
exports.setProperty = getProperty.setProperty;
|
|
185
|
+
exports.isPlainObject = isPlainObject;
|
|
186
|
+
exports.deepKeys = deeksExports.deepKeys;
|
|
187
|
+
exports.deepKeysFromList = deeksExports.deepKeysFromList;
|
package/dist/index.d.cts
CHANGED
|
@@ -76,8 +76,8 @@ type Includes<Value extends readonly any[], Item> =
|
|
|
76
76
|
@category Utilities
|
|
77
77
|
*/
|
|
78
78
|
type IsEqual<A, B> =
|
|
79
|
-
(<G>() => G extends A ? 1 : 2) extends
|
|
80
|
-
(<G>() => G extends B ? 1 : 2)
|
|
79
|
+
(<G>() => G extends A & G | G ? 1 : 2) extends
|
|
80
|
+
(<G>() => G extends B & G | G ? 1 : 2)
|
|
81
81
|
? true
|
|
82
82
|
: false;
|
|
83
83
|
|
|
@@ -166,6 +166,72 @@ fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface`
|
|
|
166
166
|
*/
|
|
167
167
|
type Simplify<T> = {[KeyType in keyof T]: T[KeyType]} & {};
|
|
168
168
|
|
|
169
|
+
/**
|
|
170
|
+
Returns a boolean for whether the given type is `never`.
|
|
171
|
+
|
|
172
|
+
@link https://github.com/microsoft/TypeScript/issues/31751#issuecomment-498526919
|
|
173
|
+
@link https://stackoverflow.com/a/53984913/10292952
|
|
174
|
+
@link https://www.zhenghao.io/posts/ts-never
|
|
175
|
+
|
|
176
|
+
Useful in type utilities, such as checking if something does not occur.
|
|
177
|
+
|
|
178
|
+
@example
|
|
179
|
+
```
|
|
180
|
+
import type {IsNever, And} from 'type-fest';
|
|
181
|
+
|
|
182
|
+
// https://github.com/andnp/SimplyTyped/blob/master/src/types/strings.ts
|
|
183
|
+
type AreStringsEqual<A extends string, B extends string> =
|
|
184
|
+
And<
|
|
185
|
+
IsNever<Exclude<A, B>> extends true ? true : false,
|
|
186
|
+
IsNever<Exclude<B, A>> extends true ? true : false
|
|
187
|
+
>;
|
|
188
|
+
|
|
189
|
+
type EndIfEqual<I extends string, O extends string> =
|
|
190
|
+
AreStringsEqual<I, O> extends true
|
|
191
|
+
? never
|
|
192
|
+
: void;
|
|
193
|
+
|
|
194
|
+
function endIfEqual<I extends string, O extends string>(input: I, output: O): EndIfEqual<I, O> {
|
|
195
|
+
if (input === output) {
|
|
196
|
+
process.exit(0);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
endIfEqual('abc', 'abc');
|
|
201
|
+
//=> never
|
|
202
|
+
|
|
203
|
+
endIfEqual('abc', '123');
|
|
204
|
+
//=> void
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
@category Type Guard
|
|
208
|
+
@category Utilities
|
|
209
|
+
*/
|
|
210
|
+
type IsNever<T> = [T] extends [never] ? true : false;
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
An if-else-like type that resolves depending on whether the given type is `never`.
|
|
214
|
+
|
|
215
|
+
@see {@link IsNever}
|
|
216
|
+
|
|
217
|
+
@example
|
|
218
|
+
```
|
|
219
|
+
import type {IfNever} from 'type-fest';
|
|
220
|
+
|
|
221
|
+
type ShouldBeTrue = IfNever<never>;
|
|
222
|
+
//=> true
|
|
223
|
+
|
|
224
|
+
type ShouldBeBar = IfNever<'not never', 'foo', 'bar'>;
|
|
225
|
+
//=> 'bar'
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
@category Type Guard
|
|
229
|
+
@category Utilities
|
|
230
|
+
*/
|
|
231
|
+
type IfNever<T, TypeIfNever = true, TypeIfNotNever = false> = (
|
|
232
|
+
IsNever<T> extends true ? TypeIfNever : TypeIfNotNever
|
|
233
|
+
);
|
|
234
|
+
|
|
169
235
|
/**
|
|
170
236
|
Returns the static, fixed-length portion of the given array, excluding variable-length parts.
|
|
171
237
|
|
|
@@ -227,10 +293,14 @@ T extends readonly [...infer U] ?
|
|
|
227
293
|
/**
|
|
228
294
|
Returns whether the given array `T` is readonly.
|
|
229
295
|
*/
|
|
230
|
-
type IsArrayReadonly<T extends UnknownArray> = T extends unknown[] ? false : true
|
|
296
|
+
type IsArrayReadonly<T extends UnknownArray> = IfNever<T, false, T extends unknown[] ? false : true>;
|
|
231
297
|
|
|
232
298
|
type StringDigit = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9';
|
|
233
299
|
|
|
300
|
+
// Can eventually be replaced with the built-in once this library supports
|
|
301
|
+
// TS5.4+ only. Tracked in https://github.com/sindresorhus/type-fest/issues/848
|
|
302
|
+
type NoInfer<T> = T extends infer U ? U : never;
|
|
303
|
+
|
|
234
304
|
/**
|
|
235
305
|
Returns a boolean for whether the given type is `any`.
|
|
236
306
|
|
|
@@ -259,7 +329,7 @@ const anyA = get(anyObject, 'a');
|
|
|
259
329
|
@category Type Guard
|
|
260
330
|
@category Utilities
|
|
261
331
|
*/
|
|
262
|
-
type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
332
|
+
type IsAny<T> = 0 extends 1 & NoInfer<T> ? true : false;
|
|
263
333
|
|
|
264
334
|
type Numeric = number | bigint;
|
|
265
335
|
|
|
@@ -320,49 +390,6 @@ type ShouldBeTrue = IsNegative<-1>;
|
|
|
320
390
|
*/
|
|
321
391
|
type IsNegative<T extends Numeric> = T extends Negative<T> ? true : false;
|
|
322
392
|
|
|
323
|
-
/**
|
|
324
|
-
Returns a boolean for whether the given type is `never`.
|
|
325
|
-
|
|
326
|
-
@link https://github.com/microsoft/TypeScript/issues/31751#issuecomment-498526919
|
|
327
|
-
@link https://stackoverflow.com/a/53984913/10292952
|
|
328
|
-
@link https://www.zhenghao.io/posts/ts-never
|
|
329
|
-
|
|
330
|
-
Useful in type utilities, such as checking if something does not occur.
|
|
331
|
-
|
|
332
|
-
@example
|
|
333
|
-
```
|
|
334
|
-
import type {IsNever, And} from 'type-fest';
|
|
335
|
-
|
|
336
|
-
// https://github.com/andnp/SimplyTyped/blob/master/src/types/strings.ts
|
|
337
|
-
type AreStringsEqual<A extends string, B extends string> =
|
|
338
|
-
And<
|
|
339
|
-
IsNever<Exclude<A, B>> extends true ? true : false,
|
|
340
|
-
IsNever<Exclude<B, A>> extends true ? true : false
|
|
341
|
-
>;
|
|
342
|
-
|
|
343
|
-
type EndIfEqual<I extends string, O extends string> =
|
|
344
|
-
AreStringsEqual<I, O> extends true
|
|
345
|
-
? never
|
|
346
|
-
: void;
|
|
347
|
-
|
|
348
|
-
function endIfEqual<I extends string, O extends string>(input: I, output: O): EndIfEqual<I, O> {
|
|
349
|
-
if (input === output) {
|
|
350
|
-
process.exit(0);
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
endIfEqual('abc', 'abc');
|
|
355
|
-
//=> never
|
|
356
|
-
|
|
357
|
-
endIfEqual('abc', '123');
|
|
358
|
-
//=> void
|
|
359
|
-
```
|
|
360
|
-
|
|
361
|
-
@category Type Guard
|
|
362
|
-
@category Utilities
|
|
363
|
-
*/
|
|
364
|
-
type IsNever<T> = [T] extends [never] ? true : false;
|
|
365
|
-
|
|
366
393
|
/**
|
|
367
394
|
Returns a boolean for whether two given types are both true.
|
|
368
395
|
|
|
@@ -866,41 +893,6 @@ Matches non-recursive types.
|
|
|
866
893
|
*/
|
|
867
894
|
type NonRecursiveType = BuiltIns | Function | (new (...arguments_: any[]) => unknown);
|
|
868
895
|
|
|
869
|
-
/**
|
|
870
|
-
Returns a boolean for whether the given type is a union type.
|
|
871
|
-
|
|
872
|
-
@example
|
|
873
|
-
```
|
|
874
|
-
type A = IsUnion<string | number>;
|
|
875
|
-
//=> true
|
|
876
|
-
|
|
877
|
-
type B = IsUnion<string>;
|
|
878
|
-
//=> false
|
|
879
|
-
```
|
|
880
|
-
*/
|
|
881
|
-
type IsUnion<T> = InternalIsUnion<T>;
|
|
882
|
-
|
|
883
|
-
/**
|
|
884
|
-
The actual implementation of `IsUnion`.
|
|
885
|
-
*/
|
|
886
|
-
type InternalIsUnion<T, U = T> =
|
|
887
|
-
(
|
|
888
|
-
// @link https://ghaiklor.github.io/type-challenges-solutions/en/medium-isunion.html
|
|
889
|
-
IsNever<T> extends true
|
|
890
|
-
? false
|
|
891
|
-
: T extends any
|
|
892
|
-
? [U] extends [T]
|
|
893
|
-
? false
|
|
894
|
-
: true
|
|
895
|
-
: never
|
|
896
|
-
) extends infer Result
|
|
897
|
-
// In some cases `Result` will return `false | true` which is `boolean`,
|
|
898
|
-
// that means `T` has at least two types and it's a union type,
|
|
899
|
-
// so we will return `true` instead of `boolean`.
|
|
900
|
-
? boolean extends Result ? true
|
|
901
|
-
: Result
|
|
902
|
-
: never; // Should never happen
|
|
903
|
-
|
|
904
896
|
/**
|
|
905
897
|
Create an object type with the given key `<Key>` and value `<Value>`.
|
|
906
898
|
|
|
@@ -1725,13 +1717,13 @@ type Dog = {
|
|
|
1725
1717
|
function displayPetInfo(petInfo: (Cat | Dog)['info']) {
|
|
1726
1718
|
// typeof petInfo =>
|
|
1727
1719
|
// {
|
|
1728
|
-
//
|
|
1729
|
-
//
|
|
1730
|
-
//
|
|
1720
|
+
// name: string;
|
|
1721
|
+
// type: 'cat';
|
|
1722
|
+
// catType: string; // Needn't care about this field, because it's not a common pet info field.
|
|
1731
1723
|
// } | {
|
|
1732
|
-
//
|
|
1733
|
-
//
|
|
1734
|
-
//
|
|
1724
|
+
// name: string;
|
|
1725
|
+
// type: 'dog';
|
|
1726
|
+
// dogType: string; // Needn't care about this field, because it's not a common pet info field.
|
|
1735
1727
|
// }
|
|
1736
1728
|
|
|
1737
1729
|
// petInfo type is complex and have some needless fields
|
|
@@ -1743,8 +1735,8 @@ function displayPetInfo(petInfo: (Cat | Dog)['info']) {
|
|
|
1743
1735
|
function displayPetInfo(petInfo: SharedUnionFieldsDeep<Cat | Dog>['info']) {
|
|
1744
1736
|
// typeof petInfo =>
|
|
1745
1737
|
// {
|
|
1746
|
-
//
|
|
1747
|
-
//
|
|
1738
|
+
// name: string;
|
|
1739
|
+
// type: 'cat' | 'dog';
|
|
1748
1740
|
// }
|
|
1749
1741
|
|
|
1750
1742
|
// petInfo type is simple and clear
|
|
@@ -1754,17 +1746,16 @@ function displayPetInfo(petInfo: SharedUnionFieldsDeep<Cat | Dog>['info']) {
|
|
|
1754
1746
|
}
|
|
1755
1747
|
```
|
|
1756
1748
|
|
|
1749
|
+
@see SharedUnionFields
|
|
1750
|
+
|
|
1757
1751
|
@category Object
|
|
1758
1752
|
@category Union
|
|
1759
1753
|
*/
|
|
1760
1754
|
type SharedUnionFieldsDeep<Union, Options extends SharedUnionFieldsDeepOptions = {recurseIntoArrays: false}> =
|
|
1761
|
-
// If `Union` is not a union type, return `Union` directly.
|
|
1762
|
-
IsUnion<Union> extends false
|
|
1763
|
-
? Union
|
|
1764
1755
|
// `Union extends` will convert `Union`
|
|
1765
1756
|
// to a [distributive conditionaltype](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types).
|
|
1766
1757
|
// But this is not what we want, so we need to wrap `Union` with `[]` to prevent it.
|
|
1767
|
-
|
|
1758
|
+
[Union] extends [NonRecursiveType | ReadonlyMap<unknown, unknown> | ReadonlySet<unknown>]
|
|
1768
1759
|
? Union
|
|
1769
1760
|
: [Union] extends [UnknownArray]
|
|
1770
1761
|
? Options['recurseIntoArrays'] extends true
|
|
@@ -1778,13 +1769,18 @@ IsUnion<Union> extends false
|
|
|
1778
1769
|
Same as `SharedUnionFieldsDeep`, but accepts only `object`s and as inputs. Internal helper for `SharedUnionFieldsDeep`.
|
|
1779
1770
|
*/
|
|
1780
1771
|
type SharedObjectUnionFieldsDeep<Union, Options extends SharedUnionFieldsDeepOptions> =
|
|
1772
|
+
// `keyof Union` can extract the same key in union type, if there is no same key, return never.
|
|
1781
1773
|
keyof Union extends infer Keys
|
|
1782
1774
|
? IsNever<Keys> extends false
|
|
1783
1775
|
? {
|
|
1784
1776
|
[Key in keyof Union]:
|
|
1785
1777
|
Union[Key] extends NonRecursiveType
|
|
1786
1778
|
? Union[Key]
|
|
1787
|
-
|
|
1779
|
+
// Remove `undefined` from the union to support optional
|
|
1780
|
+
// fields, then recover `undefined` if union was already undefined.
|
|
1781
|
+
: SharedUnionFieldsDeep<Exclude<Union[Key], undefined>, Options> | (
|
|
1782
|
+
undefined extends Required<Union>[Key] ? undefined : never
|
|
1783
|
+
)
|
|
1788
1784
|
}
|
|
1789
1785
|
: {}
|
|
1790
1786
|
: Union;
|
|
@@ -2173,8 +2169,20 @@ type PropertyOf<BaseType, Key extends string, Options extends GetOptions = {}> =
|
|
|
2173
2169
|
? undefined
|
|
2174
2170
|
: Key extends keyof BaseType
|
|
2175
2171
|
? StrictPropertyOf<BaseType, Key, Options>
|
|
2176
|
-
|
|
2177
|
-
|
|
2172
|
+
// Handle arrays and tuples
|
|
2173
|
+
: BaseType extends readonly unknown[]
|
|
2174
|
+
? Key extends `${number}`
|
|
2175
|
+
// For arrays with unknown length (regular arrays)
|
|
2176
|
+
? number extends BaseType['length']
|
|
2177
|
+
? Strictify<BaseType[number], Options>
|
|
2178
|
+
// For tuples: check if the index is valid
|
|
2179
|
+
: Key extends keyof BaseType
|
|
2180
|
+
? Strictify<BaseType[Key & keyof BaseType], Options>
|
|
2181
|
+
// Out-of-bounds access for tuples
|
|
2182
|
+
: unknown
|
|
2183
|
+
// Non-numeric string key for arrays/tuples
|
|
2184
|
+
: unknown
|
|
2185
|
+
// Handle array-like objects
|
|
2178
2186
|
: BaseType extends {
|
|
2179
2187
|
[n: number]: infer Item;
|
|
2180
2188
|
length: number; // Note: This is needed to avoid being too lax with records types using number keys like `{0: string; 1: boolean}`.
|