bupkis 0.18.0 → 0.18.2
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 +14 -0
- package/package.json +1 -4
- package/src/assertion/assertion-types.ts +4 -4
- package/src/assertion/impl/async-parametric.ts +4 -21
- package/src/assertion/impl/sync-parametric.ts +5 -17
- package/src/expect.ts +0 -4
- package/src/guards.ts +24 -24
- package/src/internal-schema.ts +16 -32
- package/src/value-to-schema.ts +1 -1
- package/dist/assertion/assertion-async.cjs +0 -268
- package/dist/assertion/assertion-async.cjs.map +0 -1
- package/dist/assertion/assertion-async.d.cts +0 -40
- package/dist/assertion/assertion-async.d.cts.map +0 -1
- package/dist/assertion/assertion-async.d.ts +0 -40
- package/dist/assertion/assertion-async.d.ts.map +0 -1
- package/dist/assertion/assertion-async.js +0 -259
- package/dist/assertion/assertion-async.js.map +0 -1
- package/dist/assertion/assertion-standard-schema-async.cjs +0 -132
- package/dist/assertion/assertion-standard-schema-async.cjs.map +0 -1
- package/dist/assertion/assertion-standard-schema-async.d.cts +0 -52
- package/dist/assertion/assertion-standard-schema-async.d.cts.map +0 -1
- package/dist/assertion/assertion-standard-schema-async.d.ts +0 -52
- package/dist/assertion/assertion-standard-schema-async.d.ts.map +0 -1
- package/dist/assertion/assertion-standard-schema-async.js +0 -128
- package/dist/assertion/assertion-standard-schema-async.js.map +0 -1
- package/dist/assertion/assertion-standard-schema-sync.cjs +0 -141
- package/dist/assertion/assertion-standard-schema-sync.cjs.map +0 -1
- package/dist/assertion/assertion-standard-schema-sync.d.cts +0 -52
- package/dist/assertion/assertion-standard-schema-sync.d.cts.map +0 -1
- package/dist/assertion/assertion-standard-schema-sync.d.ts +0 -52
- package/dist/assertion/assertion-standard-schema-sync.d.ts.map +0 -1
- package/dist/assertion/assertion-standard-schema-sync.js +0 -137
- package/dist/assertion/assertion-standard-schema-sync.js.map +0 -1
- package/dist/assertion/assertion-sync.cjs +0 -284
- package/dist/assertion/assertion-sync.cjs.map +0 -1
- package/dist/assertion/assertion-sync.d.cts +0 -60
- package/dist/assertion/assertion-sync.d.cts.map +0 -1
- package/dist/assertion/assertion-sync.d.ts +0 -60
- package/dist/assertion/assertion-sync.d.ts.map +0 -1
- package/dist/assertion/assertion-sync.js +0 -275
- package/dist/assertion/assertion-sync.js.map +0 -1
- package/dist/assertion/assertion-types.cjs +0 -20
- package/dist/assertion/assertion-types.cjs.map +0 -1
- package/dist/assertion/assertion-types.d.cts +0 -1086
- package/dist/assertion/assertion-types.d.cts.map +0 -1
- package/dist/assertion/assertion-types.d.ts +0 -1086
- package/dist/assertion/assertion-types.d.ts.map +0 -1
- package/dist/assertion/assertion-types.js +0 -19
- package/dist/assertion/assertion-types.js.map +0 -1
- package/dist/assertion/assertion.cjs +0 -382
- package/dist/assertion/assertion.cjs.map +0 -1
- package/dist/assertion/assertion.d.cts +0 -109
- package/dist/assertion/assertion.d.cts.map +0 -1
- package/dist/assertion/assertion.d.ts +0 -109
- package/dist/assertion/assertion.d.ts.map +0 -1
- package/dist/assertion/assertion.js +0 -375
- package/dist/assertion/assertion.js.map +0 -1
- package/dist/assertion/create.cjs +0 -148
- package/dist/assertion/create.cjs.map +0 -1
- package/dist/assertion/create.d.cts +0 -85
- package/dist/assertion/create.d.cts.map +0 -1
- package/dist/assertion/create.d.ts +0 -85
- package/dist/assertion/create.d.ts.map +0 -1
- package/dist/assertion/create.js +0 -143
- package/dist/assertion/create.js.map +0 -1
- package/dist/assertion/format-assertion-failure.cjs +0 -63
- package/dist/assertion/format-assertion-failure.cjs.map +0 -1
- package/dist/assertion/format-assertion-failure.d.cts +0 -21
- package/dist/assertion/format-assertion-failure.d.cts.map +0 -1
- package/dist/assertion/format-assertion-failure.d.ts +0 -21
- package/dist/assertion/format-assertion-failure.d.ts.map +0 -1
- package/dist/assertion/format-assertion-failure.js +0 -59
- package/dist/assertion/format-assertion-failure.js.map +0 -1
- package/dist/assertion/impl/assertion-util.cjs +0 -68
- package/dist/assertion/impl/assertion-util.cjs.map +0 -1
- package/dist/assertion/impl/assertion-util.d.cts +0 -36
- package/dist/assertion/impl/assertion-util.d.cts.map +0 -1
- package/dist/assertion/impl/assertion-util.d.ts +0 -36
- package/dist/assertion/impl/assertion-util.d.ts.map +0 -1
- package/dist/assertion/impl/assertion-util.js +0 -62
- package/dist/assertion/impl/assertion-util.js.map +0 -1
- package/dist/assertion/impl/async-iterable.cjs +0 -627
- package/dist/assertion/impl/async-iterable.cjs.map +0 -1
- package/dist/assertion/impl/async-iterable.d.cts +0 -406
- package/dist/assertion/impl/async-iterable.d.cts.map +0 -1
- package/dist/assertion/impl/async-iterable.d.ts +0 -406
- package/dist/assertion/impl/async-iterable.d.ts.map +0 -1
- package/dist/assertion/impl/async-iterable.js +0 -624
- package/dist/assertion/impl/async-iterable.js.map +0 -1
- package/dist/assertion/impl/async-parametric.cjs +0 -423
- package/dist/assertion/impl/async-parametric.cjs.map +0 -1
- package/dist/assertion/impl/async-parametric.d.cts +0 -278
- package/dist/assertion/impl/async-parametric.d.cts.map +0 -1
- package/dist/assertion/impl/async-parametric.d.ts +0 -278
- package/dist/assertion/impl/async-parametric.d.ts.map +0 -1
- package/dist/assertion/impl/async-parametric.js +0 -420
- package/dist/assertion/impl/async-parametric.js.map +0 -1
- package/dist/assertion/impl/async.cjs +0 -56
- package/dist/assertion/impl/async.cjs.map +0 -1
- package/dist/assertion/impl/async.d.cts +0 -179
- package/dist/assertion/impl/async.d.cts.map +0 -1
- package/dist/assertion/impl/async.d.ts +0 -179
- package/dist/assertion/impl/async.d.ts.map +0 -1
- package/dist/assertion/impl/async.js +0 -39
- package/dist/assertion/impl/async.js.map +0 -1
- package/dist/assertion/impl/index.cjs +0 -37
- package/dist/assertion/impl/index.cjs.map +0 -1
- package/dist/assertion/impl/index.d.cts +0 -21
- package/dist/assertion/impl/index.d.cts.map +0 -1
- package/dist/assertion/impl/index.d.ts +0 -21
- package/dist/assertion/impl/index.d.ts.map +0 -1
- package/dist/assertion/impl/index.js +0 -21
- package/dist/assertion/impl/index.js.map +0 -1
- package/dist/assertion/impl/iteration-util.cjs +0 -297
- package/dist/assertion/impl/iteration-util.cjs.map +0 -1
- package/dist/assertion/impl/iteration-util.d.cts +0 -12
- package/dist/assertion/impl/iteration-util.d.cts.map +0 -1
- package/dist/assertion/impl/iteration-util.d.ts +0 -12
- package/dist/assertion/impl/iteration-util.d.ts.map +0 -1
- package/dist/assertion/impl/iteration-util.js +0 -282
- package/dist/assertion/impl/iteration-util.js.map +0 -1
- package/dist/assertion/impl/snapshot.cjs +0 -276
- package/dist/assertion/impl/snapshot.cjs.map +0 -1
- package/dist/assertion/impl/snapshot.d.cts +0 -278
- package/dist/assertion/impl/snapshot.d.cts.map +0 -1
- package/dist/assertion/impl/snapshot.d.ts +0 -278
- package/dist/assertion/impl/snapshot.d.ts.map +0 -1
- package/dist/assertion/impl/snapshot.js +0 -273
- package/dist/assertion/impl/snapshot.js.map +0 -1
- package/dist/assertion/impl/sync-basic.cjs +0 -553
- package/dist/assertion/impl/sync-basic.cjs.map +0 -1
- package/dist/assertion/impl/sync-basic.d.cts +0 -528
- package/dist/assertion/impl/sync-basic.d.cts.map +0 -1
- package/dist/assertion/impl/sync-basic.d.ts +0 -528
- package/dist/assertion/impl/sync-basic.d.ts.map +0 -1
- package/dist/assertion/impl/sync-basic.js +0 -550
- package/dist/assertion/impl/sync-basic.js.map +0 -1
- package/dist/assertion/impl/sync-collection.cjs +0 -856
- package/dist/assertion/impl/sync-collection.cjs.map +0 -1
- package/dist/assertion/impl/sync-collection.d.cts +0 -607
- package/dist/assertion/impl/sync-collection.d.cts.map +0 -1
- package/dist/assertion/impl/sync-collection.d.ts +0 -607
- package/dist/assertion/impl/sync-collection.d.ts.map +0 -1
- package/dist/assertion/impl/sync-collection.js +0 -850
- package/dist/assertion/impl/sync-collection.js.map +0 -1
- package/dist/assertion/impl/sync-date.cjs +0 -341
- package/dist/assertion/impl/sync-date.cjs.map +0 -1
- package/dist/assertion/impl/sync-date.d.cts +0 -209
- package/dist/assertion/impl/sync-date.d.cts.map +0 -1
- package/dist/assertion/impl/sync-date.d.ts +0 -209
- package/dist/assertion/impl/sync-date.d.ts.map +0 -1
- package/dist/assertion/impl/sync-date.js +0 -338
- package/dist/assertion/impl/sync-date.js.map +0 -1
- package/dist/assertion/impl/sync-esoteric.cjs +0 -214
- package/dist/assertion/impl/sync-esoteric.cjs.map +0 -1
- package/dist/assertion/impl/sync-esoteric.d.cts +0 -191
- package/dist/assertion/impl/sync-esoteric.d.cts.map +0 -1
- package/dist/assertion/impl/sync-esoteric.d.ts +0 -191
- package/dist/assertion/impl/sync-esoteric.d.ts.map +0 -1
- package/dist/assertion/impl/sync-esoteric.js +0 -211
- package/dist/assertion/impl/sync-esoteric.js.map +0 -1
- package/dist/assertion/impl/sync-iterable.cjs +0 -512
- package/dist/assertion/impl/sync-iterable.cjs.map +0 -1
- package/dist/assertion/impl/sync-iterable.d.cts +0 -334
- package/dist/assertion/impl/sync-iterable.d.cts.map +0 -1
- package/dist/assertion/impl/sync-iterable.d.ts +0 -334
- package/dist/assertion/impl/sync-iterable.d.ts.map +0 -1
- package/dist/assertion/impl/sync-iterable.js +0 -509
- package/dist/assertion/impl/sync-iterable.js.map +0 -1
- package/dist/assertion/impl/sync-parametric.cjs +0 -812
- package/dist/assertion/impl/sync-parametric.cjs.map +0 -1
- package/dist/assertion/impl/sync-parametric.d.cts +0 -560
- package/dist/assertion/impl/sync-parametric.d.cts.map +0 -1
- package/dist/assertion/impl/sync-parametric.d.ts +0 -560
- package/dist/assertion/impl/sync-parametric.d.ts.map +0 -1
- package/dist/assertion/impl/sync-parametric.js +0 -809
- package/dist/assertion/impl/sync-parametric.js.map +0 -1
- package/dist/assertion/impl/sync.cjs +0 -214
- package/dist/assertion/impl/sync.cjs.map +0 -1
- package/dist/assertion/impl/sync.d.cts +0 -512
- package/dist/assertion/impl/sync.d.cts.map +0 -1
- package/dist/assertion/impl/sync.d.ts +0 -512
- package/dist/assertion/impl/sync.d.ts.map +0 -1
- package/dist/assertion/impl/sync.js +0 -197
- package/dist/assertion/impl/sync.js.map +0 -1
- package/dist/assertion/index.cjs +0 -38
- package/dist/assertion/index.cjs.map +0 -1
- package/dist/assertion/index.d.cts +0 -18
- package/dist/assertion/index.d.cts.map +0 -1
- package/dist/assertion/index.d.ts +0 -18
- package/dist/assertion/index.d.ts.map +0 -1
- package/dist/assertion/index.js +0 -17
- package/dist/assertion/index.js.map +0 -1
- package/dist/assertion/slotify.cjs +0 -165
- package/dist/assertion/slotify.cjs.map +0 -1
- package/dist/assertion/slotify.d.cts +0 -11
- package/dist/assertion/slotify.d.cts.map +0 -1
- package/dist/assertion/slotify.d.ts +0 -11
- package/dist/assertion/slotify.d.ts.map +0 -1
- package/dist/assertion/slotify.js +0 -161
- package/dist/assertion/slotify.js.map +0 -1
- package/dist/bootstrap.cjs +0 -43
- package/dist/bootstrap.cjs.map +0 -1
- package/dist/bootstrap.d.cts +0 -27
- package/dist/bootstrap.d.cts.map +0 -1
- package/dist/bootstrap.d.ts +0 -27
- package/dist/bootstrap.d.ts.map +0 -1
- package/dist/bootstrap.js +0 -40
- package/dist/bootstrap.js.map +0 -1
- package/dist/constant.cjs +0 -82
- package/dist/constant.cjs.map +0 -1
- package/dist/constant.d.cts +0 -69
- package/dist/constant.d.cts.map +0 -1
- package/dist/constant.d.ts +0 -69
- package/dist/constant.d.ts.map +0 -1
- package/dist/constant.js +0 -79
- package/dist/constant.js.map +0 -1
- package/dist/diff.cjs +0 -340
- package/dist/diff.cjs.map +0 -1
- package/dist/diff.d.cts +0 -51
- package/dist/diff.d.cts.map +0 -1
- package/dist/diff.d.ts +0 -51
- package/dist/diff.d.ts.map +0 -1
- package/dist/diff.js +0 -334
- package/dist/diff.js.map +0 -1
- package/dist/error.cjs +0 -204
- package/dist/error.cjs.map +0 -1
- package/dist/error.d.cts +0 -212
- package/dist/error.d.cts.map +0 -1
- package/dist/error.d.ts +0 -212
- package/dist/error.d.ts.map +0 -1
- package/dist/error.js +0 -191
- package/dist/error.js.map +0 -1
- package/dist/expect.cjs +0 -590
- package/dist/expect.cjs.map +0 -1
- package/dist/expect.d.cts +0 -138
- package/dist/expect.d.cts.map +0 -1
- package/dist/expect.d.ts +0 -138
- package/dist/expect.d.ts.map +0 -1
- package/dist/expect.js +0 -582
- package/dist/expect.js.map +0 -1
- package/dist/guards.cjs +0 -297
- package/dist/guards.cjs.map +0 -1
- package/dist/guards.d.cts +0 -231
- package/dist/guards.d.cts.map +0 -1
- package/dist/guards.d.ts +0 -231
- package/dist/guards.d.ts.map +0 -1
- package/dist/guards.js +0 -277
- package/dist/guards.js.map +0 -1
- package/dist/index.cjs +0 -111
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -448
- package/dist/index.d.cts.map +0 -1
- package/dist/index.d.ts +0 -448
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -71
- package/dist/index.js.map +0 -1
- package/dist/internal-schema.cjs +0 -253
- package/dist/internal-schema.cjs.map +0 -1
- package/dist/internal-schema.d.cts +0 -8
- package/dist/internal-schema.d.cts.map +0 -1
- package/dist/internal-schema.d.ts +0 -8
- package/dist/internal-schema.d.ts.map +0 -1
- package/dist/internal-schema.js +0 -248
- package/dist/internal-schema.js.map +0 -1
- package/dist/metadata.cjs +0 -57
- package/dist/metadata.cjs.map +0 -1
- package/dist/metadata.d.cts +0 -27
- package/dist/metadata.d.cts.map +0 -1
- package/dist/metadata.d.ts +0 -27
- package/dist/metadata.d.ts.map +0 -1
- package/dist/metadata.js +0 -54
- package/dist/metadata.js.map +0 -1
- package/dist/schema.cjs +0 -1522
- package/dist/schema.cjs.map +0 -1
- package/dist/schema.d.cts +0 -1196
- package/dist/schema.d.cts.map +0 -1
- package/dist/schema.d.ts +0 -1196
- package/dist/schema.d.ts.map +0 -1
- package/dist/schema.js +0 -1516
- package/dist/schema.js.map +0 -1
- package/dist/snapshot/adapter.cjs +0 -31
- package/dist/snapshot/adapter.cjs.map +0 -1
- package/dist/snapshot/adapter.d.cts +0 -258
- package/dist/snapshot/adapter.d.cts.map +0 -1
- package/dist/snapshot/adapter.d.ts +0 -258
- package/dist/snapshot/adapter.d.ts.map +0 -1
- package/dist/snapshot/adapter.js +0 -27
- package/dist/snapshot/adapter.js.map +0 -1
- package/dist/snapshot/adapters/fallback.cjs +0 -453
- package/dist/snapshot/adapters/fallback.cjs.map +0 -1
- package/dist/snapshot/adapters/fallback.d.cts +0 -185
- package/dist/snapshot/adapters/fallback.d.cts.map +0 -1
- package/dist/snapshot/adapters/fallback.d.ts +0 -185
- package/dist/snapshot/adapters/fallback.d.ts.map +0 -1
- package/dist/snapshot/adapters/fallback.js +0 -446
- package/dist/snapshot/adapters/fallback.js.map +0 -1
- package/dist/snapshot/adapters/node-test.cjs +0 -301
- package/dist/snapshot/adapters/node-test.cjs.map +0 -1
- package/dist/snapshot/adapters/node-test.d.cts +0 -131
- package/dist/snapshot/adapters/node-test.d.cts.map +0 -1
- package/dist/snapshot/adapters/node-test.d.ts +0 -131
- package/dist/snapshot/adapters/node-test.d.ts.map +0 -1
- package/dist/snapshot/adapters/node-test.js +0 -297
- package/dist/snapshot/adapters/node-test.js.map +0 -1
- package/dist/snapshot/index.cjs +0 -61
- package/dist/snapshot/index.cjs.map +0 -1
- package/dist/snapshot/index.d.cts +0 -40
- package/dist/snapshot/index.d.cts.map +0 -1
- package/dist/snapshot/index.d.ts +0 -40
- package/dist/snapshot/index.d.ts.map +0 -1
- package/dist/snapshot/index.js +0 -44
- package/dist/snapshot/index.js.map +0 -1
- package/dist/snapshot/node-version.cjs +0 -49
- package/dist/snapshot/node-version.cjs.map +0 -1
- package/dist/snapshot/node-version.d.cts +0 -34
- package/dist/snapshot/node-version.d.cts.map +0 -1
- package/dist/snapshot/node-version.d.ts +0 -34
- package/dist/snapshot/node-version.d.ts.map +0 -1
- package/dist/snapshot/node-version.js +0 -44
- package/dist/snapshot/node-version.js.map +0 -1
- package/dist/snapshot/select-adapter.cjs +0 -170
- package/dist/snapshot/select-adapter.cjs.map +0 -1
- package/dist/snapshot/select-adapter.d.cts +0 -128
- package/dist/snapshot/select-adapter.d.cts.map +0 -1
- package/dist/snapshot/select-adapter.d.ts +0 -128
- package/dist/snapshot/select-adapter.d.ts.map +0 -1
- package/dist/snapshot/select-adapter.js +0 -164
- package/dist/snapshot/select-adapter.js.map +0 -1
- package/dist/snapshot/serializer.cjs +0 -246
- package/dist/snapshot/serializer.cjs.map +0 -1
- package/dist/snapshot/serializer.d.cts +0 -126
- package/dist/snapshot/serializer.d.cts.map +0 -1
- package/dist/snapshot/serializer.d.ts +0 -126
- package/dist/snapshot/serializer.d.ts.map +0 -1
- package/dist/snapshot/serializer.js +0 -238
- package/dist/snapshot/serializer.js.map +0 -1
- package/dist/standard-schema.cjs +0 -13
- package/dist/standard-schema.cjs.map +0 -1
- package/dist/standard-schema.d.cts +0 -192
- package/dist/standard-schema.d.cts.map +0 -1
- package/dist/standard-schema.d.ts +0 -192
- package/dist/standard-schema.d.ts.map +0 -1
- package/dist/standard-schema.js +0 -12
- package/dist/standard-schema.js.map +0 -1
- package/dist/types.cjs +0 -22
- package/dist/types.cjs.map +0 -1
- package/dist/types.d.cts +0 -905
- package/dist/types.d.cts.map +0 -1
- package/dist/types.d.ts +0 -905
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -21
- package/dist/types.js.map +0 -1
- package/dist/use.cjs +0 -240
- package/dist/use.cjs.map +0 -1
- package/dist/use.d.cts +0 -8
- package/dist/use.d.cts.map +0 -1
- package/dist/use.d.ts +0 -8
- package/dist/use.d.ts.map +0 -1
- package/dist/use.js +0 -236
- package/dist/use.js.map +0 -1
- package/dist/util.cjs +0 -255
- package/dist/util.cjs.map +0 -1
- package/dist/util.d.cts +0 -141
- package/dist/util.d.cts.map +0 -1
- package/dist/util.d.ts +0 -141
- package/dist/util.d.ts.map +0 -1
- package/dist/util.js +0 -234
- package/dist/util.js.map +0 -1
- package/dist/value-to-schema.cjs +0 -537
- package/dist/value-to-schema.cjs.map +0 -1
- package/dist/value-to-schema.d.cts +0 -144
- package/dist/value-to-schema.d.cts.map +0 -1
- package/dist/value-to-schema.d.ts +0 -144
- package/dist/value-to-schema.d.ts.map +0 -1
- package/dist/value-to-schema.js +0 -533
- package/dist/value-to-schema.js.map +0 -1
package/dist/util.cjs
DELETED
|
@@ -1,255 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Utility functions.
|
|
4
|
-
*
|
|
5
|
-
* @module util
|
|
6
|
-
* @category API
|
|
7
|
-
* @example
|
|
8
|
-
*
|
|
9
|
-
* ```ts
|
|
10
|
-
* import * as util from 'bupkis/util';
|
|
11
|
-
* ```
|
|
12
|
-
*/
|
|
13
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
-
if (k2 === undefined) k2 = k;
|
|
15
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
-
}
|
|
19
|
-
Object.defineProperty(o, k2, desc);
|
|
20
|
-
}) : (function(o, m, k, k2) {
|
|
21
|
-
if (k2 === undefined) k2 = k;
|
|
22
|
-
o[k2] = m[k];
|
|
23
|
-
}));
|
|
24
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
25
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
26
|
-
};
|
|
27
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
-
exports.parseKeypath = exports.keyBy = exports.has = exports.get = void 0;
|
|
29
|
-
__exportStar(require("./value-to-schema.cjs"), exports);
|
|
30
|
-
const { isInteger, isNaN } = Number;
|
|
31
|
-
/**
|
|
32
|
-
* Retrieves the value at a given keypath from an object using dot or bracket
|
|
33
|
-
* notation.
|
|
34
|
-
*
|
|
35
|
-
* Supports keypaths like:
|
|
36
|
-
*
|
|
37
|
-
* - `'foo.bar'` - dot notation
|
|
38
|
-
* - `'foo[1].spam'` - bracket notation with array indices
|
|
39
|
-
* - `'foo["bar-baz"].quux'` - bracket notation with quoted strings
|
|
40
|
-
* - `"foo['bar-baz'].quux"` - bracket notation with single quotes
|
|
41
|
-
*
|
|
42
|
-
* This function cannot retrieve values associated with symbol keys.
|
|
43
|
-
*
|
|
44
|
-
* @example
|
|
45
|
-
*
|
|
46
|
-
* ```ts
|
|
47
|
-
* const obj = {
|
|
48
|
-
* foo: {
|
|
49
|
-
* bar: 'hello',
|
|
50
|
-
* 'bar-baz': { quux: 'world' },
|
|
51
|
-
* },
|
|
52
|
-
* arr: [{ spam: 'eggs' }],
|
|
53
|
-
* };
|
|
54
|
-
*
|
|
55
|
-
* get(obj, 'foo.bar');
|
|
56
|
-
* get(obj, 'arr[0].spam');
|
|
57
|
-
* get(obj, 'foo["bar-baz"].quux');
|
|
58
|
-
* get(obj, 'foo.nonexistent');
|
|
59
|
-
* get(obj, 'foo.nonexistent', 'default');
|
|
60
|
-
* ```
|
|
61
|
-
*
|
|
62
|
-
* @function
|
|
63
|
-
* @param obj The object to retrieve the value from
|
|
64
|
-
* @param keypath The keypath using dot or bracket notation
|
|
65
|
-
* @param defaultValue Optional default value to return if the keypath is not
|
|
66
|
-
* found
|
|
67
|
-
* @returns The value at the keypath, or defaultValue if not found
|
|
68
|
-
*/
|
|
69
|
-
const get = (obj, keypath, defaultValue) => {
|
|
70
|
-
if (typeof obj !== 'object' || obj === null || typeof keypath !== 'string') {
|
|
71
|
-
return defaultValue;
|
|
72
|
-
}
|
|
73
|
-
const keys = (0, exports.parseKeypath)(keypath);
|
|
74
|
-
if (keys.length === 0) {
|
|
75
|
-
return defaultValue;
|
|
76
|
-
}
|
|
77
|
-
let current = obj;
|
|
78
|
-
for (const key of keys) {
|
|
79
|
-
if (current == null || typeof current !== 'object') {
|
|
80
|
-
return defaultValue;
|
|
81
|
-
}
|
|
82
|
-
const currentObj = current;
|
|
83
|
-
if (!(key in currentObj)) {
|
|
84
|
-
return defaultValue;
|
|
85
|
-
}
|
|
86
|
-
current = currentObj[key];
|
|
87
|
-
}
|
|
88
|
-
return current;
|
|
89
|
-
};
|
|
90
|
-
exports.get = get;
|
|
91
|
-
/**
|
|
92
|
-
* Returns whether a value exists at a given keypath within an object using dot
|
|
93
|
-
* or bracket notation.
|
|
94
|
-
*
|
|
95
|
-
* Supports keypaths like:
|
|
96
|
-
*
|
|
97
|
-
* - `'foo.bar'` - dot notation
|
|
98
|
-
* - `'foo[1].spam'` - bracket notation with array indices
|
|
99
|
-
* - `'foo["bar-baz"].quux'` - bracket notation with quoted strings
|
|
100
|
-
* - `"foo['bar-baz'].quux"` - bracket notation with single quotes
|
|
101
|
-
*
|
|
102
|
-
* This function cannot consider values associated with symbol keys.
|
|
103
|
-
*
|
|
104
|
-
* @example
|
|
105
|
-
*
|
|
106
|
-
* ```ts
|
|
107
|
-
* const obj = {
|
|
108
|
-
* foo: {
|
|
109
|
-
* bar: 'hello',
|
|
110
|
-
* 'bar-baz': { quux: 'world' },
|
|
111
|
-
* },
|
|
112
|
-
* arr: [{ spam: 'eggs' }],
|
|
113
|
-
* };
|
|
114
|
-
*
|
|
115
|
-
* has(obj, 'foo.bar');
|
|
116
|
-
* has(obj, 'arr[0].spam');
|
|
117
|
-
* has(obj, 'foo["bar-baz"].quux');
|
|
118
|
-
* has(obj, 'foo.nonexistent');
|
|
119
|
-
* ```
|
|
120
|
-
*
|
|
121
|
-
* @function
|
|
122
|
-
* @param obj The object to examine the value from
|
|
123
|
-
* @param keypath The keypath using dot or bracket notation
|
|
124
|
-
* @returns `true` if the keypath exists, `false` otherwise
|
|
125
|
-
*/
|
|
126
|
-
const has = (obj, keypath) => {
|
|
127
|
-
if (typeof obj !== 'object' || obj === null || typeof keypath !== 'string') {
|
|
128
|
-
return false;
|
|
129
|
-
}
|
|
130
|
-
const keys = (0, exports.parseKeypath)(keypath);
|
|
131
|
-
if (keys.length === 0) {
|
|
132
|
-
return false;
|
|
133
|
-
}
|
|
134
|
-
let current = obj;
|
|
135
|
-
for (const key of keys) {
|
|
136
|
-
if (current == null || typeof current !== 'object') {
|
|
137
|
-
return false;
|
|
138
|
-
}
|
|
139
|
-
const currentObj = current;
|
|
140
|
-
if (!(key in currentObj)) {
|
|
141
|
-
return false;
|
|
142
|
-
}
|
|
143
|
-
current = currentObj[key];
|
|
144
|
-
}
|
|
145
|
-
return true;
|
|
146
|
-
};
|
|
147
|
-
exports.has = has;
|
|
148
|
-
/**
|
|
149
|
-
* Maps an array of objects to an object keyed by the specified key.
|
|
150
|
-
*
|
|
151
|
-
* @function
|
|
152
|
-
* @param collection Array of objects
|
|
153
|
-
* @param key Name of key
|
|
154
|
-
* @returns Object mapping key values to objects
|
|
155
|
-
*/
|
|
156
|
-
const keyBy = (collection, key) => {
|
|
157
|
-
const result = {};
|
|
158
|
-
for (const item of collection) {
|
|
159
|
-
const keyValue = item[key];
|
|
160
|
-
if (typeof keyValue === 'string' ||
|
|
161
|
-
typeof keyValue === 'number' ||
|
|
162
|
-
typeof keyValue === 'symbol') {
|
|
163
|
-
result[String(keyValue)] = item;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
return result;
|
|
167
|
-
};
|
|
168
|
-
exports.keyBy = keyBy;
|
|
169
|
-
/**
|
|
170
|
-
* Parses a keypath string into an array of individual keys, supporting dot and
|
|
171
|
-
* bracket notation.
|
|
172
|
-
*
|
|
173
|
-
* Parsing rules:
|
|
174
|
-
*
|
|
175
|
-
* - Dot notation: Splits keys by `.` (e.g., `'foo.bar'` → `['foo', 'bar']`).
|
|
176
|
-
* - Bracket notation: Extracts keys inside `[]`. If the key is a quoted string
|
|
177
|
-
* (single or double quotes), the quotes are removed (e.g., `'foo["bar-baz"]'`
|
|
178
|
-
* → `['foo', 'bar-baz']`). If the key is an integer (e.g., `'foo[0]'`), it is
|
|
179
|
-
* parsed as a number.
|
|
180
|
-
* - Mixed notation: Supports combinations (e.g., `'foo.bar[0].baz'` → `['foo',
|
|
181
|
-
* 'bar', 0, 'baz']`).
|
|
182
|
-
* - Quoted keys: Keys inside brackets can be quoted with single or double quotes.
|
|
183
|
-
* Quotes are stripped, and the content is used as the key.
|
|
184
|
-
* - Numeric keys: If a bracketed key is an integer, it is returned as a number;
|
|
185
|
-
* otherwise, as a string.
|
|
186
|
-
* - Whitespace inside brackets is preserved as part of the key.
|
|
187
|
-
* - Does not support escape sequences inside quotes.
|
|
188
|
-
*
|
|
189
|
-
* Limitations:
|
|
190
|
-
*
|
|
191
|
-
* - Does not support symbol keys.
|
|
192
|
-
* - Does not handle escape characters inside quoted keys.
|
|
193
|
-
*
|
|
194
|
-
* @example
|
|
195
|
-
*
|
|
196
|
-
* ```ts
|
|
197
|
-
* parseKeypath('foo.bar'); // ['foo', 'bar']
|
|
198
|
-
* parseKeypath('foo[0].baz'); // ['foo', 0, 'baz']
|
|
199
|
-
* parseKeypath('foo["bar-baz"].quux'); // ['foo', 'bar-baz', 'quux']
|
|
200
|
-
* parseKeypath("foo['bar-baz'].quux"); // ['foo', 'bar-baz', 'quux']
|
|
201
|
-
* parseKeypath("arr[10]['spam']"); // ['arr', 10, 'spam']
|
|
202
|
-
* ```
|
|
203
|
-
*
|
|
204
|
-
* @function
|
|
205
|
-
* @param keypath The keypath string to parse, using dot and/or bracket
|
|
206
|
-
* notation.
|
|
207
|
-
* @returns An array of keys, where each key is a string or number. Bracketed
|
|
208
|
-
* integer keys are returned as numbers; all others as strings.
|
|
209
|
-
*/
|
|
210
|
-
const parseKeypath = (keypath) => {
|
|
211
|
-
const keys = [];
|
|
212
|
-
let i = 0;
|
|
213
|
-
while (i < keypath.length) {
|
|
214
|
-
if (keypath[i] === '[') {
|
|
215
|
-
i++;
|
|
216
|
-
let key = '';
|
|
217
|
-
let inQuotes = false;
|
|
218
|
-
let quoteChar = '';
|
|
219
|
-
while (i < keypath.length && (keypath[i] !== ']' || inQuotes)) {
|
|
220
|
-
const char = keypath[i];
|
|
221
|
-
if (!inQuotes && (char === '"' || char === "'")) {
|
|
222
|
-
inQuotes = true;
|
|
223
|
-
quoteChar = char;
|
|
224
|
-
}
|
|
225
|
-
else if (inQuotes && char === quoteChar) {
|
|
226
|
-
inQuotes = false;
|
|
227
|
-
quoteChar = '';
|
|
228
|
-
}
|
|
229
|
-
else {
|
|
230
|
-
key += char;
|
|
231
|
-
}
|
|
232
|
-
i++;
|
|
233
|
-
}
|
|
234
|
-
i++;
|
|
235
|
-
const numKey = Number(key);
|
|
236
|
-
keys.push(isInteger(numKey) && !isNaN(numKey) ? numKey : key);
|
|
237
|
-
}
|
|
238
|
-
else if (keypath[i] === '.') {
|
|
239
|
-
i++;
|
|
240
|
-
}
|
|
241
|
-
else {
|
|
242
|
-
let key = '';
|
|
243
|
-
while (i < keypath.length && keypath[i] !== '.' && keypath[i] !== '[') {
|
|
244
|
-
key += keypath[i];
|
|
245
|
-
i++;
|
|
246
|
-
}
|
|
247
|
-
if (key) {
|
|
248
|
-
keys.push(key);
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
return keys;
|
|
253
|
-
};
|
|
254
|
-
exports.parseKeypath = parseKeypath;
|
|
255
|
-
//# sourceMappingURL=util.js.map
|
package/dist/util.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;;;;;;;;;;;;;;;AAMH,wDAAqC;AAErC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;AAEpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACI,MAAM,GAAG,GAAG,CACjB,GAAY,EACZ,OAAgB,EAChB,YAAgB,EACD,EAAE;IACjB,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,G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AE,CAAC;gBACR,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACjB,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAlDW,QAAA,YAAY,gBAkDvB"}
|
package/dist/util.d.cts
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Utility functions.
|
|
3
|
-
*
|
|
4
|
-
* @module util
|
|
5
|
-
* @category API
|
|
6
|
-
* @example
|
|
7
|
-
*
|
|
8
|
-
* ```ts
|
|
9
|
-
* import * as util from 'bupkis/util';
|
|
10
|
-
* ```
|
|
11
|
-
*/
|
|
12
|
-
import { type StringKeyOf } from 'type-fest';
|
|
13
|
-
import { type Keypath } from "./types.cjs";
|
|
14
|
-
export * from "./value-to-schema.cjs";
|
|
15
|
-
/**
|
|
16
|
-
* Retrieves the value at a given keypath from an object using dot or bracket
|
|
17
|
-
* notation.
|
|
18
|
-
*
|
|
19
|
-
* Supports keypaths like:
|
|
20
|
-
*
|
|
21
|
-
* - `'foo.bar'` - dot notation
|
|
22
|
-
* - `'foo[1].spam'` - bracket notation with array indices
|
|
23
|
-
* - `'foo["bar-baz"].quux'` - bracket notation with quoted strings
|
|
24
|
-
* - `"foo['bar-baz'].quux"` - bracket notation with single quotes
|
|
25
|
-
*
|
|
26
|
-
* This function cannot retrieve values associated with symbol keys.
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
*
|
|
30
|
-
* ```ts
|
|
31
|
-
* const obj = {
|
|
32
|
-
* foo: {
|
|
33
|
-
* bar: 'hello',
|
|
34
|
-
* 'bar-baz': { quux: 'world' },
|
|
35
|
-
* },
|
|
36
|
-
* arr: [{ spam: 'eggs' }],
|
|
37
|
-
* };
|
|
38
|
-
*
|
|
39
|
-
* get(obj, 'foo.bar');
|
|
40
|
-
* get(obj, 'arr[0].spam');
|
|
41
|
-
* get(obj, 'foo["bar-baz"].quux');
|
|
42
|
-
* get(obj, 'foo.nonexistent');
|
|
43
|
-
* get(obj, 'foo.nonexistent', 'default');
|
|
44
|
-
* ```
|
|
45
|
-
*
|
|
46
|
-
* @function
|
|
47
|
-
* @param obj The object to retrieve the value from
|
|
48
|
-
* @param keypath The keypath using dot or bracket notation
|
|
49
|
-
* @param defaultValue Optional default value to return if the keypath is not
|
|
50
|
-
* found
|
|
51
|
-
* @returns The value at the keypath, or defaultValue if not found
|
|
52
|
-
*/
|
|
53
|
-
export declare const get: <T = unknown>(obj: unknown, keypath: Keypath, defaultValue?: T) => T | undefined;
|
|
54
|
-
/**
|
|
55
|
-
* Returns whether a value exists at a given keypath within an object using dot
|
|
56
|
-
* or bracket notation.
|
|
57
|
-
*
|
|
58
|
-
* Supports keypaths like:
|
|
59
|
-
*
|
|
60
|
-
* - `'foo.bar'` - dot notation
|
|
61
|
-
* - `'foo[1].spam'` - bracket notation with array indices
|
|
62
|
-
* - `'foo["bar-baz"].quux'` - bracket notation with quoted strings
|
|
63
|
-
* - `"foo['bar-baz'].quux"` - bracket notation with single quotes
|
|
64
|
-
*
|
|
65
|
-
* This function cannot consider values associated with symbol keys.
|
|
66
|
-
*
|
|
67
|
-
* @example
|
|
68
|
-
*
|
|
69
|
-
* ```ts
|
|
70
|
-
* const obj = {
|
|
71
|
-
* foo: {
|
|
72
|
-
* bar: 'hello',
|
|
73
|
-
* 'bar-baz': { quux: 'world' },
|
|
74
|
-
* },
|
|
75
|
-
* arr: [{ spam: 'eggs' }],
|
|
76
|
-
* };
|
|
77
|
-
*
|
|
78
|
-
* has(obj, 'foo.bar');
|
|
79
|
-
* has(obj, 'arr[0].spam');
|
|
80
|
-
* has(obj, 'foo["bar-baz"].quux');
|
|
81
|
-
* has(obj, 'foo.nonexistent');
|
|
82
|
-
* ```
|
|
83
|
-
*
|
|
84
|
-
* @function
|
|
85
|
-
* @param obj The object to examine the value from
|
|
86
|
-
* @param keypath The keypath using dot or bracket notation
|
|
87
|
-
* @returns `true` if the keypath exists, `false` otherwise
|
|
88
|
-
*/
|
|
89
|
-
export declare const has: (obj: unknown, keypath: Keypath) => boolean;
|
|
90
|
-
/**
|
|
91
|
-
* Maps an array of objects to an object keyed by the specified key.
|
|
92
|
-
*
|
|
93
|
-
* @function
|
|
94
|
-
* @param collection Array of objects
|
|
95
|
-
* @param key Name of key
|
|
96
|
-
* @returns Object mapping key values to objects
|
|
97
|
-
*/
|
|
98
|
-
export declare const keyBy: <const T extends readonly Record<PropertyKey, any>[], K extends StringKeyOf<T[number]>>(collection: T, key: K) => Record<string, T[number]>;
|
|
99
|
-
/**
|
|
100
|
-
* Parses a keypath string into an array of individual keys, supporting dot and
|
|
101
|
-
* bracket notation.
|
|
102
|
-
*
|
|
103
|
-
* Parsing rules:
|
|
104
|
-
*
|
|
105
|
-
* - Dot notation: Splits keys by `.` (e.g., `'foo.bar'` → `['foo', 'bar']`).
|
|
106
|
-
* - Bracket notation: Extracts keys inside `[]`. If the key is a quoted string
|
|
107
|
-
* (single or double quotes), the quotes are removed (e.g., `'foo["bar-baz"]'`
|
|
108
|
-
* → `['foo', 'bar-baz']`). If the key is an integer (e.g., `'foo[0]'`), it is
|
|
109
|
-
* parsed as a number.
|
|
110
|
-
* - Mixed notation: Supports combinations (e.g., `'foo.bar[0].baz'` → `['foo',
|
|
111
|
-
* 'bar', 0, 'baz']`).
|
|
112
|
-
* - Quoted keys: Keys inside brackets can be quoted with single or double quotes.
|
|
113
|
-
* Quotes are stripped, and the content is used as the key.
|
|
114
|
-
* - Numeric keys: If a bracketed key is an integer, it is returned as a number;
|
|
115
|
-
* otherwise, as a string.
|
|
116
|
-
* - Whitespace inside brackets is preserved as part of the key.
|
|
117
|
-
* - Does not support escape sequences inside quotes.
|
|
118
|
-
*
|
|
119
|
-
* Limitations:
|
|
120
|
-
*
|
|
121
|
-
* - Does not support symbol keys.
|
|
122
|
-
* - Does not handle escape characters inside quoted keys.
|
|
123
|
-
*
|
|
124
|
-
* @example
|
|
125
|
-
*
|
|
126
|
-
* ```ts
|
|
127
|
-
* parseKeypath('foo.bar'); // ['foo', 'bar']
|
|
128
|
-
* parseKeypath('foo[0].baz'); // ['foo', 0, 'baz']
|
|
129
|
-
* parseKeypath('foo["bar-baz"].quux'); // ['foo', 'bar-baz', 'quux']
|
|
130
|
-
* parseKeypath("foo['bar-baz'].quux"); // ['foo', 'bar-baz', 'quux']
|
|
131
|
-
* parseKeypath("arr[10]['spam']"); // ['arr', 10, 'spam']
|
|
132
|
-
* ```
|
|
133
|
-
*
|
|
134
|
-
* @function
|
|
135
|
-
* @param keypath The keypath string to parse, using dot and/or bracket
|
|
136
|
-
* notation.
|
|
137
|
-
* @returns An array of keys, where each key is a string or number. Bracketed
|
|
138
|
-
* integer keys are returned as numbers; all others as strings.
|
|
139
|
-
*/
|
|
140
|
-
export declare const parseKeypath: <S extends string = string>(keypath: Keypath<S>) => (number | string)[];
|
|
141
|
-
//# sourceMappingURL=util.d.ts.map
|
package/dist/util.d.cts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AAE7C,OAAO,EAAE,KAAK,OAAO,EAAE,oBAAmB;AAE1C,sCAAqC;AAIrC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,eAAO,MAAM,GAAG,GAAI,CAAC,GAAG,OAAO,EAC7B,KAAK,OAAO,EACZ,SAAS,OAAO,EAChB,eAAe,CAAC,KACf,CAAC,GAAG,SA4BN,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,eAAO,MAAM,GAAG,GAAI,KAAK,OAAO,EAAE,SAAS,OAAO,KAAG,OA2BpD,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,KAAK,GAChB,KAAK,CAAC,CAAC,SAAS,SAAS,MAAM,CAAC,WAAW,EAAE,GAAG,CAAC,EAAE,EACnD,CAAC,SAAS,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,EAEhC,YAAY,CAAC,EACb,KAAK,CAAC,KACL,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAe1B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,MAAM,GAAG,MAAM,EACpD,SAAS,OAAO,CAAC,CAAC,CAAC,KAClB,CAAC,MAAM,GAAG,MAAM,CAAC,EAgDnB,CAAC"}
|
package/dist/util.d.ts
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Utility functions.
|
|
3
|
-
*
|
|
4
|
-
* @module util
|
|
5
|
-
* @category API
|
|
6
|
-
* @example
|
|
7
|
-
*
|
|
8
|
-
* ```ts
|
|
9
|
-
* import * as util from 'bupkis/util';
|
|
10
|
-
* ```
|
|
11
|
-
*/
|
|
12
|
-
import { type StringKeyOf } from 'type-fest';
|
|
13
|
-
import { type Keypath } from "./types.js";
|
|
14
|
-
export * from "./value-to-schema.js";
|
|
15
|
-
/**
|
|
16
|
-
* Retrieves the value at a given keypath from an object using dot or bracket
|
|
17
|
-
* notation.
|
|
18
|
-
*
|
|
19
|
-
* Supports keypaths like:
|
|
20
|
-
*
|
|
21
|
-
* - `'foo.bar'` - dot notation
|
|
22
|
-
* - `'foo[1].spam'` - bracket notation with array indices
|
|
23
|
-
* - `'foo["bar-baz"].quux'` - bracket notation with quoted strings
|
|
24
|
-
* - `"foo['bar-baz'].quux"` - bracket notation with single quotes
|
|
25
|
-
*
|
|
26
|
-
* This function cannot retrieve values associated with symbol keys.
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
*
|
|
30
|
-
* ```ts
|
|
31
|
-
* const obj = {
|
|
32
|
-
* foo: {
|
|
33
|
-
* bar: 'hello',
|
|
34
|
-
* 'bar-baz': { quux: 'world' },
|
|
35
|
-
* },
|
|
36
|
-
* arr: [{ spam: 'eggs' }],
|
|
37
|
-
* };
|
|
38
|
-
*
|
|
39
|
-
* get(obj, 'foo.bar');
|
|
40
|
-
* get(obj, 'arr[0].spam');
|
|
41
|
-
* get(obj, 'foo["bar-baz"].quux');
|
|
42
|
-
* get(obj, 'foo.nonexistent');
|
|
43
|
-
* get(obj, 'foo.nonexistent', 'default');
|
|
44
|
-
* ```
|
|
45
|
-
*
|
|
46
|
-
* @function
|
|
47
|
-
* @param obj The object to retrieve the value from
|
|
48
|
-
* @param keypath The keypath using dot or bracket notation
|
|
49
|
-
* @param defaultValue Optional default value to return if the keypath is not
|
|
50
|
-
* found
|
|
51
|
-
* @returns The value at the keypath, or defaultValue if not found
|
|
52
|
-
*/
|
|
53
|
-
export declare const get: <T = unknown>(obj: unknown, keypath: Keypath, defaultValue?: T) => T | undefined;
|
|
54
|
-
/**
|
|
55
|
-
* Returns whether a value exists at a given keypath within an object using dot
|
|
56
|
-
* or bracket notation.
|
|
57
|
-
*
|
|
58
|
-
* Supports keypaths like:
|
|
59
|
-
*
|
|
60
|
-
* - `'foo.bar'` - dot notation
|
|
61
|
-
* - `'foo[1].spam'` - bracket notation with array indices
|
|
62
|
-
* - `'foo["bar-baz"].quux'` - bracket notation with quoted strings
|
|
63
|
-
* - `"foo['bar-baz'].quux"` - bracket notation with single quotes
|
|
64
|
-
*
|
|
65
|
-
* This function cannot consider values associated with symbol keys.
|
|
66
|
-
*
|
|
67
|
-
* @example
|
|
68
|
-
*
|
|
69
|
-
* ```ts
|
|
70
|
-
* const obj = {
|
|
71
|
-
* foo: {
|
|
72
|
-
* bar: 'hello',
|
|
73
|
-
* 'bar-baz': { quux: 'world' },
|
|
74
|
-
* },
|
|
75
|
-
* arr: [{ spam: 'eggs' }],
|
|
76
|
-
* };
|
|
77
|
-
*
|
|
78
|
-
* has(obj, 'foo.bar');
|
|
79
|
-
* has(obj, 'arr[0].spam');
|
|
80
|
-
* has(obj, 'foo["bar-baz"].quux');
|
|
81
|
-
* has(obj, 'foo.nonexistent');
|
|
82
|
-
* ```
|
|
83
|
-
*
|
|
84
|
-
* @function
|
|
85
|
-
* @param obj The object to examine the value from
|
|
86
|
-
* @param keypath The keypath using dot or bracket notation
|
|
87
|
-
* @returns `true` if the keypath exists, `false` otherwise
|
|
88
|
-
*/
|
|
89
|
-
export declare const has: (obj: unknown, keypath: Keypath) => boolean;
|
|
90
|
-
/**
|
|
91
|
-
* Maps an array of objects to an object keyed by the specified key.
|
|
92
|
-
*
|
|
93
|
-
* @function
|
|
94
|
-
* @param collection Array of objects
|
|
95
|
-
* @param key Name of key
|
|
96
|
-
* @returns Object mapping key values to objects
|
|
97
|
-
*/
|
|
98
|
-
export declare const keyBy: <const T extends readonly Record<PropertyKey, any>[], K extends StringKeyOf<T[number]>>(collection: T, key: K) => Record<string, T[number]>;
|
|
99
|
-
/**
|
|
100
|
-
* Parses a keypath string into an array of individual keys, supporting dot and
|
|
101
|
-
* bracket notation.
|
|
102
|
-
*
|
|
103
|
-
* Parsing rules:
|
|
104
|
-
*
|
|
105
|
-
* - Dot notation: Splits keys by `.` (e.g., `'foo.bar'` → `['foo', 'bar']`).
|
|
106
|
-
* - Bracket notation: Extracts keys inside `[]`. If the key is a quoted string
|
|
107
|
-
* (single or double quotes), the quotes are removed (e.g., `'foo["bar-baz"]'`
|
|
108
|
-
* → `['foo', 'bar-baz']`). If the key is an integer (e.g., `'foo[0]'`), it is
|
|
109
|
-
* parsed as a number.
|
|
110
|
-
* - Mixed notation: Supports combinations (e.g., `'foo.bar[0].baz'` → `['foo',
|
|
111
|
-
* 'bar', 0, 'baz']`).
|
|
112
|
-
* - Quoted keys: Keys inside brackets can be quoted with single or double quotes.
|
|
113
|
-
* Quotes are stripped, and the content is used as the key.
|
|
114
|
-
* - Numeric keys: If a bracketed key is an integer, it is returned as a number;
|
|
115
|
-
* otherwise, as a string.
|
|
116
|
-
* - Whitespace inside brackets is preserved as part of the key.
|
|
117
|
-
* - Does not support escape sequences inside quotes.
|
|
118
|
-
*
|
|
119
|
-
* Limitations:
|
|
120
|
-
*
|
|
121
|
-
* - Does not support symbol keys.
|
|
122
|
-
* - Does not handle escape characters inside quoted keys.
|
|
123
|
-
*
|
|
124
|
-
* @example
|
|
125
|
-
*
|
|
126
|
-
* ```ts
|
|
127
|
-
* parseKeypath('foo.bar'); // ['foo', 'bar']
|
|
128
|
-
* parseKeypath('foo[0].baz'); // ['foo', 0, 'baz']
|
|
129
|
-
* parseKeypath('foo["bar-baz"].quux'); // ['foo', 'bar-baz', 'quux']
|
|
130
|
-
* parseKeypath("foo['bar-baz'].quux"); // ['foo', 'bar-baz', 'quux']
|
|
131
|
-
* parseKeypath("arr[10]['spam']"); // ['arr', 10, 'spam']
|
|
132
|
-
* ```
|
|
133
|
-
*
|
|
134
|
-
* @function
|
|
135
|
-
* @param keypath The keypath string to parse, using dot and/or bracket
|
|
136
|
-
* notation.
|
|
137
|
-
* @returns An array of keys, where each key is a string or number. Bracketed
|
|
138
|
-
* integer keys are returned as numbers; all others as strings.
|
|
139
|
-
*/
|
|
140
|
-
export declare const parseKeypath: <S extends string = string>(keypath: Keypath<S>) => (number | string)[];
|
|
141
|
-
//# sourceMappingURL=util.d.ts.map
|
package/dist/util.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AAE7C,OAAO,EAAE,KAAK,OAAO,EAAE,mBAAmB;AAE1C,qCAAqC;AAIrC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,eAAO,MAAM,GAAG,GAAI,CAAC,GAAG,OAAO,EAC7B,KAAK,OAAO,EACZ,SAAS,OAAO,EAChB,eAAe,CAAC,KACf,CAAC,GAAG,SA4BN,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,eAAO,MAAM,GAAG,GAAI,KAAK,OAAO,EAAE,SAAS,OAAO,KAAG,OA2BpD,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,KAAK,GAChB,KAAK,CAAC,CAAC,SAAS,SAAS,MAAM,CAAC,WAAW,EAAE,GAAG,CAAC,EAAE,EACnD,CAAC,SAAS,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,EAEhC,YAAY,CAAC,EACb,KAAK,CAAC,KACL,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAe1B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,MAAM,GAAG,MAAM,EACpD,SAAS,OAAO,CAAC,CAAC,CAAC,KAClB,CAAC,MAAM,GAAG,MAAM,CAAC,EAgDnB,CAAC"}
|