@metamask/utils 8.4.0 → 8.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -1
- package/dist/assert.cjs +127 -0
- package/dist/assert.cjs.map +1 -0
- package/dist/{types/assert.d.ts → assert.d.cts} +3 -3
- package/dist/assert.d.cts.map +1 -0
- package/dist/assert.d.mts +61 -0
- package/dist/assert.d.mts.map +1 -0
- package/dist/assert.mjs +119 -15
- package/dist/assert.mjs.map +1 -1
- package/dist/base64.cjs +34 -0
- package/dist/base64.cjs.map +1 -0
- package/dist/{types/base64.d.ts → base64.d.cts} +3 -3
- package/dist/base64.d.cts.map +1 -0
- package/dist/base64.d.mts +25 -0
- package/dist/base64.d.mts.map +1 -0
- package/dist/base64.mjs +28 -9
- package/dist/base64.mjs.map +1 -1
- package/dist/bytes.cjs +400 -0
- package/dist/{chunk-QEPVHEP7.js.map → bytes.cjs.map} +1 -1
- package/dist/{types/bytes.d.ts → bytes.d.cts} +3 -3
- package/dist/bytes.d.cts.map +1 -0
- package/dist/bytes.d.mts +183 -0
- package/dist/bytes.d.mts.map +1 -0
- package/dist/bytes.mjs +379 -42
- package/dist/bytes.mjs.map +1 -1
- package/dist/caip-types.cjs +151 -0
- package/dist/caip-types.cjs.map +1 -0
- package/dist/{types/caip-types.d.ts → caip-types.d.cts} +12 -12
- package/dist/caip-types.d.cts.map +1 -0
- package/dist/caip-types.d.mts +114 -0
- package/dist/caip-types.d.mts.map +1 -0
- package/dist/caip-types.mjs +139 -43
- package/dist/caip-types.mjs.map +1 -1
- package/dist/checksum.cjs +7 -0
- package/dist/checksum.cjs.map +1 -0
- package/dist/checksum.d.cts +2 -0
- package/dist/checksum.d.cts.map +1 -0
- package/dist/checksum.d.mts +2 -0
- package/dist/checksum.d.mts.map +1 -0
- package/dist/checksum.mjs +3 -11
- package/dist/checksum.mjs.map +1 -1
- package/dist/coercers.cjs +162 -0
- package/dist/coercers.cjs.map +1 -0
- package/dist/{types/coercers.d.ts → coercers.d.cts} +7 -7
- package/dist/coercers.d.cts.map +1 -0
- package/dist/coercers.d.mts +97 -0
- package/dist/coercers.d.mts.map +1 -0
- package/dist/coercers.mjs +154 -17
- package/dist/coercers.mjs.map +1 -1
- package/dist/collections.cjs +109 -0
- package/dist/collections.cjs.map +1 -0
- package/dist/{types/collections.d.ts → collections.d.cts} +1 -1
- package/dist/collections.d.cts.map +1 -0
- package/dist/collections.d.mts +39 -0
- package/dist/collections.d.mts.map +1 -0
- package/dist/collections.mjs +103 -8
- package/dist/collections.mjs.map +1 -1
- package/dist/encryption-types.cjs +3 -0
- package/dist/encryption-types.cjs.map +1 -0
- package/dist/{types/encryption-types.d.ts → encryption-types.d.cts} +2 -2
- package/dist/encryption-types.d.cts.map +1 -0
- package/dist/encryption-types.d.mts +7 -0
- package/dist/encryption-types.d.mts.map +1 -0
- package/dist/encryption-types.mjs +1 -1
- package/dist/encryption-types.mjs.map +1 -1
- package/dist/errors.cjs +111 -0
- package/dist/errors.cjs.map +1 -0
- package/dist/{types/errors.d.ts → errors.d.cts} +1 -1
- package/dist/errors.d.cts.map +1 -0
- package/dist/errors.d.mts +58 -0
- package/dist/errors.d.mts.map +1 -0
- package/dist/errors.mjs +102 -16
- package/dist/errors.mjs.map +1 -1
- package/dist/fs.cjs +248 -0
- package/dist/fs.cjs.map +1 -0
- package/dist/{types/fs.d.ts → fs.d.cts} +3 -3
- package/dist/fs.d.cts.map +1 -0
- package/dist/fs.d.mts +133 -0
- package/dist/fs.d.mts.map +1 -0
- package/dist/fs.mjs +209 -25
- package/dist/fs.mjs.map +1 -1
- package/dist/hex.cjs +134 -0
- package/dist/hex.cjs.map +1 -0
- package/dist/{types/hex.d.ts → hex.d.cts} +3 -3
- package/dist/hex.d.cts.map +1 -0
- package/dist/hex.d.mts +77 -0
- package/dist/hex.d.mts.map +1 -0
- package/dist/hex.mjs +121 -34
- package/dist/hex.mjs.map +1 -1
- package/dist/index.cjs +37 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +21 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +21 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +20 -296
- package/dist/index.mjs.map +1 -1
- package/dist/json.cjs +413 -0
- package/dist/json.cjs.map +1 -0
- package/dist/{types/json.d.ts → json.d.cts} +21 -22
- package/dist/json.d.cts.map +1 -0
- package/dist/json.d.mts +383 -0
- package/dist/json.d.mts.map +1 -0
- package/dist/json.mjs +389 -74
- package/dist/json.mjs.map +1 -1
- package/dist/keyring.cjs +3 -0
- package/dist/keyring.cjs.map +1 -0
- package/dist/{types/keyring.d.ts → keyring.d.cts} +7 -7
- package/dist/keyring.d.cts.map +1 -0
- package/dist/keyring.d.mts +224 -0
- package/dist/keyring.d.mts.map +1 -0
- package/dist/keyring.mjs +1 -1
- package/dist/keyring.mjs.map +1 -1
- package/dist/logging.cjs +43 -0
- package/dist/logging.cjs.map +1 -0
- package/dist/{types/logging.d.ts → logging.d.cts} +2 -2
- package/dist/logging.d.cts.map +1 -0
- package/dist/logging.d.mts +30 -0
- package/dist/logging.d.mts.map +1 -0
- package/dist/logging.mjs +34 -9
- package/dist/logging.mjs.map +1 -1
- package/dist/misc.cjs +149 -0
- package/dist/misc.cjs.map +1 -0
- package/dist/{types/misc.d.ts → misc.d.cts} +6 -6
- package/dist/misc.d.cts.map +1 -0
- package/dist/misc.d.mts +119 -0
- package/dist/misc.d.mts.map +1 -0
- package/dist/misc.mjs +136 -27
- package/dist/misc.mjs.map +1 -1
- package/dist/node.cjs +19 -0
- package/dist/node.cjs.map +1 -0
- package/dist/node.d.cts +3 -0
- package/dist/node.d.cts.map +1 -0
- package/dist/node.d.mts +3 -0
- package/dist/node.d.mts.map +1 -0
- package/dist/node.mjs +2 -316
- package/dist/node.mjs.map +1 -1
- package/dist/number.cjs +102 -0
- package/dist/number.cjs.map +1 -0
- package/dist/{types/number.d.ts → number.d.cts} +1 -1
- package/dist/number.d.cts.map +1 -0
- package/dist/number.d.mts +73 -0
- package/dist/number.d.mts.map +1 -0
- package/dist/number.mjs +93 -16
- package/dist/number.mjs.map +1 -1
- package/dist/opaque.cjs +3 -0
- package/dist/opaque.cjs.map +1 -0
- package/dist/opaque.d.cts +6 -0
- package/dist/opaque.d.cts.map +1 -0
- package/dist/opaque.d.mts +6 -0
- package/dist/opaque.d.mts.map +1 -0
- package/dist/opaque.mjs +1 -1
- package/dist/opaque.mjs.map +1 -1
- package/dist/promise.cjs +40 -0
- package/dist/promise.cjs.map +1 -0
- package/dist/{types/promise.d.ts → promise.d.cts} +2 -2
- package/dist/promise.d.cts.map +1 -0
- package/dist/promise.d.mts +45 -0
- package/dist/promise.d.mts.map +1 -0
- package/dist/promise.mjs +35 -7
- package/dist/promise.mjs.map +1 -1
- package/dist/time.cjs +67 -0
- package/dist/time.cjs.map +1 -0
- package/dist/{types/time.d.ts → time.d.cts} +1 -1
- package/dist/time.d.cts.map +1 -0
- package/dist/time.d.mts +49 -0
- package/dist/time.d.mts.map +1 -0
- package/dist/time.mjs +60 -10
- package/dist/time.mjs.map +1 -1
- package/dist/transaction-types.cjs +3 -0
- package/dist/transaction-types.cjs.map +1 -0
- package/dist/{types/transaction-types.d.ts → transaction-types.d.cts} +11 -11
- package/dist/transaction-types.d.cts.map +1 -0
- package/dist/transaction-types.d.mts +117 -0
- package/dist/transaction-types.d.mts.map +1 -0
- package/dist/transaction-types.mjs +1 -1
- package/dist/transaction-types.mjs.map +1 -1
- package/dist/versions.cjs +95 -0
- package/dist/versions.cjs.map +1 -0
- package/dist/{types/versions.d.ts → versions.d.cts} +5 -5
- package/dist/versions.d.cts.map +1 -0
- package/dist/versions.d.mts +101 -0
- package/dist/versions.d.mts.map +1 -0
- package/dist/versions.mjs +85 -26
- package/dist/versions.mjs.map +1 -1
- package/package.json +26 -17
- package/dist/assert.js +0 -16
- package/dist/assert.js.map +0 -1
- package/dist/base64.js +0 -11
- package/dist/base64.js.map +0 -1
- package/dist/bytes.js +0 -43
- package/dist/bytes.js.map +0 -1
- package/dist/caip-types.js +0 -44
- package/dist/caip-types.js.map +0 -1
- package/dist/checksum.js +0 -12
- package/dist/checksum.js.map +0 -1
- package/dist/chunk-2LBGT4GH.js +0 -15
- package/dist/chunk-2LBGT4GH.js.map +0 -1
- package/dist/chunk-3W5G4CYI.js +0 -25
- package/dist/chunk-3W5G4CYI.js.map +0 -1
- package/dist/chunk-4D6XQBHA.js +0 -69
- package/dist/chunk-4D6XQBHA.js.map +0 -1
- package/dist/chunk-4RMX5YWE.js +0 -34
- package/dist/chunk-4RMX5YWE.js.map +0 -1
- package/dist/chunk-5AVWINSB.js +0 -1
- package/dist/chunk-5AVWINSB.js.map +0 -1
- package/dist/chunk-622IOGVI.mjs +0 -1
- package/dist/chunk-622IOGVI.mjs.map +0 -1
- package/dist/chunk-6C35XQOF.mjs +0 -257
- package/dist/chunk-6C35XQOF.mjs.map +0 -1
- package/dist/chunk-6NZW4WK4.js +0 -35
- package/dist/chunk-6NZW4WK4.js.map +0 -1
- package/dist/chunk-6ZDHSOUV.js +0 -59
- package/dist/chunk-6ZDHSOUV.js.map +0 -1
- package/dist/chunk-74DGVJVE.mjs +0 -59
- package/dist/chunk-74DGVJVE.mjs.map +0 -1
- package/dist/chunk-AY6FDCBT.mjs +0 -1
- package/dist/chunk-AY6FDCBT.mjs.map +0 -1
- package/dist/chunk-C6HGFEYL.js +0 -23
- package/dist/chunk-C6HGFEYL.js.map +0 -1
- package/dist/chunk-DHVKFDHQ.js +0 -95
- package/dist/chunk-DHVKFDHQ.js.map +0 -1
- package/dist/chunk-DYRKZQMK.mjs +0 -122
- package/dist/chunk-DYRKZQMK.mjs.map +0 -1
- package/dist/chunk-E4C7EW4R.js +0 -16
- package/dist/chunk-E4C7EW4R.js.map +0 -1
- package/dist/chunk-EQMZL4XU.js +0 -1
- package/dist/chunk-EQMZL4XU.js.map +0 -1
- package/dist/chunk-GZS3IQBZ.mjs +0 -16
- package/dist/chunk-GZS3IQBZ.mjs.map +0 -1
- package/dist/chunk-H4YFDLB7.mjs +0 -70
- package/dist/chunk-H4YFDLB7.mjs.map +0 -1
- package/dist/chunk-I575FZFH.mjs +0 -1
- package/dist/chunk-I575FZFH.mjs.map +0 -1
- package/dist/chunk-IZC266HS.js +0 -55
- package/dist/chunk-IZC266HS.js.map +0 -1
- package/dist/chunk-JPAL7Q5S.mjs +0 -90
- package/dist/chunk-JPAL7Q5S.mjs.map +0 -1
- package/dist/chunk-LC2CRSWD.js +0 -1
- package/dist/chunk-LC2CRSWD.js.map +0 -1
- package/dist/chunk-NQMRFZHB.mjs +0 -35
- package/dist/chunk-NQMRFZHB.mjs.map +0 -1
- package/dist/chunk-O3EIM33O.mjs +0 -95
- package/dist/chunk-O3EIM33O.mjs.map +0 -1
- package/dist/chunk-OLLG4H35.js +0 -257
- package/dist/chunk-OLLG4H35.js.map +0 -1
- package/dist/chunk-OUZ3LSLX.mjs +0 -94
- package/dist/chunk-OUZ3LSLX.mjs.map +0 -1
- package/dist/chunk-QEPVHEP7.js +0 -273
- package/dist/chunk-QVEKZRZ2.js +0 -70
- package/dist/chunk-QVEKZRZ2.js.map +0 -1
- package/dist/chunk-RIRDOQPX.mjs +0 -15
- package/dist/chunk-RIRDOQPX.mjs.map +0 -1
- package/dist/chunk-RKRGAFXY.js +0 -1
- package/dist/chunk-RKRGAFXY.js.map +0 -1
- package/dist/chunk-RNEXSCNP.js +0 -122
- package/dist/chunk-RNEXSCNP.js.map +0 -1
- package/dist/chunk-ROQSKDP5.mjs +0 -69
- package/dist/chunk-ROQSKDP5.mjs.map +0 -1
- package/dist/chunk-RRYOWRCV.mjs +0 -1
- package/dist/chunk-RRYOWRCV.mjs.map +0 -1
- package/dist/chunk-S3UHBN2Z.mjs +0 -44
- package/dist/chunk-S3UHBN2Z.mjs.map +0 -1
- package/dist/chunk-THNLGEXV.mjs +0 -34
- package/dist/chunk-THNLGEXV.mjs.map +0 -1
- package/dist/chunk-UOTVU7OQ.js +0 -1
- package/dist/chunk-UOTVU7OQ.js.map +0 -1
- package/dist/chunk-VA2DRBDE.mjs +0 -273
- package/dist/chunk-VA2DRBDE.mjs.map +0 -1
- package/dist/chunk-VFXTVNXN.js +0 -44
- package/dist/chunk-VFXTVNXN.js.map +0 -1
- package/dist/chunk-W5XI7ERF.mjs +0 -23
- package/dist/chunk-W5XI7ERF.mjs.map +0 -1
- package/dist/chunk-WA4DHIND.mjs +0 -1
- package/dist/chunk-WA4DHIND.mjs.map +0 -1
- package/dist/chunk-X66SUIEF.mjs +0 -25
- package/dist/chunk-X66SUIEF.mjs.map +0 -1
- package/dist/chunk-XYGUOY6N.mjs +0 -55
- package/dist/chunk-XYGUOY6N.mjs.map +0 -1
- package/dist/chunk-YWAID473.js +0 -94
- package/dist/chunk-YWAID473.js.map +0 -1
- package/dist/chunk-Z2RGWDD7.js +0 -90
- package/dist/chunk-Z2RGWDD7.js.map +0 -1
- package/dist/coercers.js +0 -18
- package/dist/coercers.js.map +0 -1
- package/dist/collections.js +0 -10
- package/dist/collections.js.map +0 -1
- package/dist/encryption-types.js +0 -2
- package/dist/encryption-types.js.map +0 -1
- package/dist/errors.js +0 -17
- package/dist/errors.js.map +0 -1
- package/dist/fs.js +0 -26
- package/dist/fs.js.map +0 -1
- package/dist/hex.js +0 -35
- package/dist/hex.js.map +0 -1
- package/dist/index.js +0 -297
- package/dist/index.js.map +0 -1
- package/dist/json.js +0 -75
- package/dist/json.js.map +0 -1
- package/dist/keyring.js +0 -2
- package/dist/keyring.js.map +0 -1
- package/dist/logging.js +0 -10
- package/dist/logging.js.map +0 -1
- package/dist/misc.js +0 -28
- package/dist/misc.js.map +0 -1
- package/dist/node.js +0 -317
- package/dist/node.js.map +0 -1
- package/dist/number.js +0 -18
- package/dist/number.js.map +0 -1
- package/dist/opaque.js +0 -2
- package/dist/opaque.js.map +0 -1
- package/dist/promise.js +0 -8
- package/dist/promise.js.map +0 -1
- package/dist/time.js +0 -12
- package/dist/time.js.map +0 -1
- package/dist/transaction-types.js +0 -2
- package/dist/transaction-types.js.map +0 -1
- package/dist/types/assert.d.ts.map +0 -1
- package/dist/types/base64.d.ts.map +0 -1
- package/dist/types/bytes.d.ts.map +0 -1
- package/dist/types/caip-types.d.ts.map +0 -1
- package/dist/types/checksum.d.ts +0 -2
- package/dist/types/checksum.d.ts.map +0 -1
- package/dist/types/coercers.d.ts.map +0 -1
- package/dist/types/collections.d.ts.map +0 -1
- package/dist/types/encryption-types.d.ts.map +0 -1
- package/dist/types/errors.d.ts.map +0 -1
- package/dist/types/fs.d.ts.map +0 -1
- package/dist/types/hex.d.ts.map +0 -1
- package/dist/types/index.d.ts +0 -21
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/json.d.ts.map +0 -1
- package/dist/types/keyring.d.ts.map +0 -1
- package/dist/types/logging.d.ts.map +0 -1
- package/dist/types/misc.d.ts.map +0 -1
- package/dist/types/node.d.ts +0 -3
- package/dist/types/node.d.ts.map +0 -1
- package/dist/types/number.d.ts.map +0 -1
- package/dist/types/opaque.d.ts +0 -6
- package/dist/types/opaque.d.ts.map +0 -1
- package/dist/types/promise.d.ts.map +0 -1
- package/dist/types/time.d.ts.map +0 -1
- package/dist/types/transaction-types.d.ts.map +0 -1
- package/dist/types/versions.d.ts.map +0 -1
- package/dist/versions.js +0 -27
- package/dist/versions.js.map +0 -1
package/dist/misc.d.mts
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Makes every specified property of the specified object type mutable.
|
|
3
|
+
*
|
|
4
|
+
* @template ObjectValue - The object whose readonly properties to make mutable.
|
|
5
|
+
* @template TargetKey - The property key(s) to make mutable.
|
|
6
|
+
*/
|
|
7
|
+
export type Mutable<ObjectValue extends Record<string, unknown>, TargetKey extends keyof ObjectValue> = {
|
|
8
|
+
-readonly [Key in keyof Pick<ObjectValue, TargetKey>]: ObjectValue[Key];
|
|
9
|
+
} & {
|
|
10
|
+
[Key in keyof Omit<ObjectValue, TargetKey>]: ObjectValue[Key];
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Useful for representing some value that _might_ be present and / or complete.
|
|
14
|
+
*
|
|
15
|
+
* @template Value - The value that might be present or complete.
|
|
16
|
+
*/
|
|
17
|
+
export type PartialOrAbsent<Value> = Partial<Value> | null | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* Like {@link Array}, but always non-empty.
|
|
20
|
+
*
|
|
21
|
+
* @template Element - The non-empty array member type.
|
|
22
|
+
*/
|
|
23
|
+
export type NonEmptyArray<Element> = [Element, ...Element[]];
|
|
24
|
+
/**
|
|
25
|
+
* A JavaScript object that is not `null`, a function, or an array.
|
|
26
|
+
*/
|
|
27
|
+
export type RuntimeObject = Record<PropertyKey, unknown>;
|
|
28
|
+
/**
|
|
29
|
+
* A {@link NonEmptyArray} type guard.
|
|
30
|
+
*
|
|
31
|
+
* @template Element - The non-empty array member type.
|
|
32
|
+
* @param value - The value to check.
|
|
33
|
+
* @returns Whether the value is a non-empty array.
|
|
34
|
+
*/
|
|
35
|
+
export declare function isNonEmptyArray<Element>(value: Element[]): value is NonEmptyArray<Element>;
|
|
36
|
+
/**
|
|
37
|
+
* Type guard for "nullishness".
|
|
38
|
+
*
|
|
39
|
+
* @param value - Any value.
|
|
40
|
+
* @returns `true` if the value is null or undefined, `false` otherwise.
|
|
41
|
+
*/
|
|
42
|
+
export declare function isNullOrUndefined(value: unknown): value is null | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* A type guard for {@link RuntimeObject}.
|
|
45
|
+
*
|
|
46
|
+
* @param value - The value to check.
|
|
47
|
+
* @returns Whether the specified value has a runtime type of `object` and is
|
|
48
|
+
* neither `null` nor an `Array`.
|
|
49
|
+
*/
|
|
50
|
+
export declare function isObject(value: unknown): value is RuntimeObject;
|
|
51
|
+
/**
|
|
52
|
+
* A type guard for ensuring an object has a property.
|
|
53
|
+
*
|
|
54
|
+
* @param objectToCheck - The object to check.
|
|
55
|
+
* @param name - The property name to check for.
|
|
56
|
+
* @returns Whether the specified object has an own property with the specified
|
|
57
|
+
* name, regardless of whether it is enumerable or not.
|
|
58
|
+
*/
|
|
59
|
+
export declare const hasProperty: <ObjectToCheck extends Object, Property extends PropertyKey>(objectToCheck: ObjectToCheck, name: Property) => objectToCheck is ObjectToCheck & Record<Property, Property extends keyof ObjectToCheck ? ObjectToCheck[Property] : unknown>;
|
|
60
|
+
/**
|
|
61
|
+
* `Object.getOwnPropertyNames()` is intentionally generic: it returns the
|
|
62
|
+
* immediate property names of an object, but it cannot make guarantees about
|
|
63
|
+
* the contents of that object, so the type of the property names is merely
|
|
64
|
+
* `string[]`. While this is technically accurate, it is also unnecessary if we
|
|
65
|
+
* have an object with a type that we own (such as an enum).
|
|
66
|
+
*
|
|
67
|
+
* @param object - The plain object.
|
|
68
|
+
* @returns The own property names of the object which are assigned a type
|
|
69
|
+
* derived from the object itself.
|
|
70
|
+
*/
|
|
71
|
+
export declare function getKnownPropertyNames<Key extends PropertyKey>(object: Partial<Record<Key, any>>): Key[];
|
|
72
|
+
export type PlainObject = Record<number | string | symbol, unknown>;
|
|
73
|
+
/**
|
|
74
|
+
* Predefined sizes (in Bytes) of specific parts of JSON structure.
|
|
75
|
+
*/
|
|
76
|
+
export declare enum JsonSize {
|
|
77
|
+
Null = 4,
|
|
78
|
+
Comma = 1,
|
|
79
|
+
Wrapper = 1,
|
|
80
|
+
True = 4,
|
|
81
|
+
False = 5,
|
|
82
|
+
Quote = 1,
|
|
83
|
+
Colon = 1,
|
|
84
|
+
Date = 24
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Regular expression with pattern matching for (special) escaped characters.
|
|
88
|
+
*/
|
|
89
|
+
export declare const ESCAPE_CHARACTERS_REGEXP: RegExp;
|
|
90
|
+
/**
|
|
91
|
+
* Check if the value is plain object.
|
|
92
|
+
*
|
|
93
|
+
* @param value - Value to be checked.
|
|
94
|
+
* @returns True if an object is the plain JavaScript object,
|
|
95
|
+
* false if the object is not plain (e.g. function).
|
|
96
|
+
*/
|
|
97
|
+
export declare function isPlainObject(value: unknown): value is PlainObject;
|
|
98
|
+
/**
|
|
99
|
+
* Check if character is ASCII.
|
|
100
|
+
*
|
|
101
|
+
* @param character - Character.
|
|
102
|
+
* @returns True if a character code is ASCII, false if not.
|
|
103
|
+
*/
|
|
104
|
+
export declare function isASCII(character: string): boolean;
|
|
105
|
+
/**
|
|
106
|
+
* Calculate string size.
|
|
107
|
+
*
|
|
108
|
+
* @param value - String value to calculate size.
|
|
109
|
+
* @returns Number of bytes used to store whole string value.
|
|
110
|
+
*/
|
|
111
|
+
export declare function calculateStringSize(value: string): number;
|
|
112
|
+
/**
|
|
113
|
+
* Calculate size of a number ofter JSON serialization.
|
|
114
|
+
*
|
|
115
|
+
* @param value - Number value to calculate size.
|
|
116
|
+
* @returns Number of bytes used to store whole number in JSON.
|
|
117
|
+
*/
|
|
118
|
+
export declare function calculateNumberSize(value: number): number;
|
|
119
|
+
//# sourceMappingURL=misc.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"misc.d.mts","sourceRoot":"","sources":["../src/misc.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,MAAM,MAAM,OAAO,CACjB,WAAW,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC3C,SAAS,SAAS,MAAM,WAAW,IACjC;IACF,CAAC,UAAU,GAAG,IAAI,MAAM,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC,GAAG,WAAW,CAAC,GAAG,CAAC;CACxE,GAAG;KACD,GAAG,IAAI,MAAM,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC,GAAG,WAAW,CAAC,GAAG,CAAC;CAC9D,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,eAAe,CAAC,KAAK,IAAI,OAAO,CAAC,KAAK,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC;AAEvE;;;;GAIG;AACH,MAAM,MAAM,aAAa,CAAC,OAAO,IAAI,CAAC,OAAO,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;AAE7D;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;AAMzD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,OAAO,EACrC,KAAK,EAAE,OAAO,EAAE,GACf,KAAK,IAAI,aAAa,CAAC,OAAO,CAAC,CAEjC;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,IAAI,GAAG,SAAS,CAE3E;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAE/D;AAMD;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,2OAW8B,CAAC;AAEvD;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,SAAS,WAAW,EAC3D,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,GAChC,GAAG,EAAE,CAEP;AAED,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,OAAO,CAAC,CAAC;AAEpE;;GAEG;AACH,oBAAY,QAAQ;IAClB,IAAI,IAAI;IACR,KAAK,IAAI;IACT,OAAO,IAAI;IACX,IAAI,IAAI;IACR,KAAK,IAAI;IACT,KAAK,IAAI;IACT,KAAK,IAAI;IAET,IAAI,KAAK;CACV;AAED;;GAEG;AACH,eAAO,MAAM,wBAAwB,QAAoB,CAAC;AAE1D;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW,CAelE;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,SAAS,EAAE,MAAM,WAExC;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAUzD;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEzD"}
|
package/dist/misc.mjs
CHANGED
|
@@ -1,28 +1,137 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
1
|
+
//
|
|
2
|
+
// Types
|
|
3
|
+
//
|
|
4
|
+
//
|
|
5
|
+
// Type Guards
|
|
6
|
+
//
|
|
7
|
+
/**
|
|
8
|
+
* A {@link NonEmptyArray} type guard.
|
|
9
|
+
*
|
|
10
|
+
* @template Element - The non-empty array member type.
|
|
11
|
+
* @param value - The value to check.
|
|
12
|
+
* @returns Whether the value is a non-empty array.
|
|
13
|
+
*/
|
|
14
|
+
export function isNonEmptyArray(value) {
|
|
15
|
+
return Array.isArray(value) && value.length > 0;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Type guard for "nullishness".
|
|
19
|
+
*
|
|
20
|
+
* @param value - Any value.
|
|
21
|
+
* @returns `true` if the value is null or undefined, `false` otherwise.
|
|
22
|
+
*/
|
|
23
|
+
export function isNullOrUndefined(value) {
|
|
24
|
+
return value === null || value === undefined;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* A type guard for {@link RuntimeObject}.
|
|
28
|
+
*
|
|
29
|
+
* @param value - The value to check.
|
|
30
|
+
* @returns Whether the specified value has a runtime type of `object` and is
|
|
31
|
+
* neither `null` nor an `Array`.
|
|
32
|
+
*/
|
|
33
|
+
export function isObject(value) {
|
|
34
|
+
return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
|
|
35
|
+
}
|
|
36
|
+
//
|
|
37
|
+
// Other utility functions
|
|
38
|
+
//
|
|
39
|
+
/**
|
|
40
|
+
* A type guard for ensuring an object has a property.
|
|
41
|
+
*
|
|
42
|
+
* @param objectToCheck - The object to check.
|
|
43
|
+
* @param name - The property name to check for.
|
|
44
|
+
* @returns Whether the specified object has an own property with the specified
|
|
45
|
+
* name, regardless of whether it is enumerable or not.
|
|
46
|
+
*/
|
|
47
|
+
export const hasProperty = (objectToCheck, name) => Object.hasOwnProperty.call(objectToCheck, name);
|
|
48
|
+
/**
|
|
49
|
+
* `Object.getOwnPropertyNames()` is intentionally generic: it returns the
|
|
50
|
+
* immediate property names of an object, but it cannot make guarantees about
|
|
51
|
+
* the contents of that object, so the type of the property names is merely
|
|
52
|
+
* `string[]`. While this is technically accurate, it is also unnecessary if we
|
|
53
|
+
* have an object with a type that we own (such as an enum).
|
|
54
|
+
*
|
|
55
|
+
* @param object - The plain object.
|
|
56
|
+
* @returns The own property names of the object which are assigned a type
|
|
57
|
+
* derived from the object itself.
|
|
58
|
+
*/
|
|
59
|
+
export function getKnownPropertyNames(object) {
|
|
60
|
+
return Object.getOwnPropertyNames(object);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Predefined sizes (in Bytes) of specific parts of JSON structure.
|
|
64
|
+
*/
|
|
65
|
+
export var JsonSize;
|
|
66
|
+
(function (JsonSize) {
|
|
67
|
+
JsonSize[JsonSize["Null"] = 4] = "Null";
|
|
68
|
+
JsonSize[JsonSize["Comma"] = 1] = "Comma";
|
|
69
|
+
JsonSize[JsonSize["Wrapper"] = 1] = "Wrapper";
|
|
70
|
+
JsonSize[JsonSize["True"] = 4] = "True";
|
|
71
|
+
JsonSize[JsonSize["False"] = 5] = "False";
|
|
72
|
+
JsonSize[JsonSize["Quote"] = 1] = "Quote";
|
|
73
|
+
JsonSize[JsonSize["Colon"] = 1] = "Colon";
|
|
74
|
+
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
75
|
+
JsonSize[JsonSize["Date"] = 24] = "Date";
|
|
76
|
+
})(JsonSize = JsonSize || (JsonSize = {}));
|
|
77
|
+
/**
|
|
78
|
+
* Regular expression with pattern matching for (special) escaped characters.
|
|
79
|
+
*/
|
|
80
|
+
export const ESCAPE_CHARACTERS_REGEXP = /"|\\|\n|\r|\t/gu;
|
|
81
|
+
/**
|
|
82
|
+
* Check if the value is plain object.
|
|
83
|
+
*
|
|
84
|
+
* @param value - Value to be checked.
|
|
85
|
+
* @returns True if an object is the plain JavaScript object,
|
|
86
|
+
* false if the object is not plain (e.g. function).
|
|
87
|
+
*/
|
|
88
|
+
export function isPlainObject(value) {
|
|
89
|
+
if (typeof value !== 'object' || value === null) {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
try {
|
|
93
|
+
let proto = value;
|
|
94
|
+
while (Object.getPrototypeOf(proto) !== null) {
|
|
95
|
+
proto = Object.getPrototypeOf(proto);
|
|
96
|
+
}
|
|
97
|
+
return Object.getPrototypeOf(value) === proto;
|
|
98
|
+
}
|
|
99
|
+
catch (_) {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Check if character is ASCII.
|
|
105
|
+
*
|
|
106
|
+
* @param character - Character.
|
|
107
|
+
* @returns True if a character code is ASCII, false if not.
|
|
108
|
+
*/
|
|
109
|
+
export function isASCII(character) {
|
|
110
|
+
return character.charCodeAt(0) <= 127;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Calculate string size.
|
|
114
|
+
*
|
|
115
|
+
* @param value - String value to calculate size.
|
|
116
|
+
* @returns Number of bytes used to store whole string value.
|
|
117
|
+
*/
|
|
118
|
+
export function calculateStringSize(value) {
|
|
119
|
+
const size = value.split('').reduce((total, character) => {
|
|
120
|
+
if (isASCII(character)) {
|
|
121
|
+
return total + 1;
|
|
122
|
+
}
|
|
123
|
+
return total + 2;
|
|
124
|
+
}, 0);
|
|
125
|
+
// Also detect characters that need backslash escape
|
|
126
|
+
return size + (value.match(ESCAPE_CHARACTERS_REGEXP) ?? []).length;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Calculate size of a number ofter JSON serialization.
|
|
130
|
+
*
|
|
131
|
+
* @param value - Number value to calculate size.
|
|
132
|
+
* @returns Number of bytes used to store whole number in JSON.
|
|
133
|
+
*/
|
|
134
|
+
export function calculateNumberSize(value) {
|
|
135
|
+
return value.toString().length;
|
|
136
|
+
}
|
|
28
137
|
//# sourceMappingURL=misc.mjs.map
|
package/dist/misc.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"
|
|
1
|
+
{"version":3,"file":"misc.mjs","sourceRoot":"","sources":["../src/misc.ts"],"names":[],"mappings":"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","sourcesContent":["//\n// Types\n//\n\n/**\n * Makes every specified property of the specified object type mutable.\n *\n * @template ObjectValue - The object whose readonly properties to make mutable.\n * @template TargetKey - The property key(s) to make mutable.\n */\nexport type Mutable<\n ObjectValue extends Record<string, unknown>,\n TargetKey extends keyof ObjectValue,\n> = {\n -readonly [Key in keyof Pick<ObjectValue, TargetKey>]: ObjectValue[Key];\n} & {\n [Key in keyof Omit<ObjectValue, TargetKey>]: ObjectValue[Key];\n};\n\n/**\n * Useful for representing some value that _might_ be present and / or complete.\n *\n * @template Value - The value that might be present or complete.\n */\nexport type PartialOrAbsent<Value> = Partial<Value> | null | undefined;\n\n/**\n * Like {@link Array}, but always non-empty.\n *\n * @template Element - The non-empty array member type.\n */\nexport type NonEmptyArray<Element> = [Element, ...Element[]];\n\n/**\n * A JavaScript object that is not `null`, a function, or an array.\n */\nexport type RuntimeObject = Record<PropertyKey, unknown>;\n\n//\n// Type Guards\n//\n\n/**\n * A {@link NonEmptyArray} type guard.\n *\n * @template Element - The non-empty array member type.\n * @param value - The value to check.\n * @returns Whether the value is a non-empty array.\n */\nexport function isNonEmptyArray<Element>(\n value: Element[],\n): value is NonEmptyArray<Element> {\n return Array.isArray(value) && value.length > 0;\n}\n\n/**\n * Type guard for \"nullishness\".\n *\n * @param value - Any value.\n * @returns `true` if the value is null or undefined, `false` otherwise.\n */\nexport function isNullOrUndefined(value: unknown): value is null | undefined {\n return value === null || value === undefined;\n}\n\n/**\n * A type guard for {@link RuntimeObject}.\n *\n * @param value - The value to check.\n * @returns Whether the specified value has a runtime type of `object` and is\n * neither `null` nor an `Array`.\n */\nexport function isObject(value: unknown): value is RuntimeObject {\n return Boolean(value) && typeof value === 'object' && !Array.isArray(value);\n}\n\n//\n// Other utility functions\n//\n\n/**\n * A type guard for ensuring an object has a property.\n *\n * @param objectToCheck - The object to check.\n * @param name - The property name to check for.\n * @returns Whether the specified object has an own property with the specified\n * name, regardless of whether it is enumerable or not.\n */\nexport const hasProperty = <\n // eslint-disable-next-line @typescript-eslint/ban-types\n ObjectToCheck extends Object,\n Property extends PropertyKey,\n>(\n objectToCheck: ObjectToCheck,\n name: Property,\n): objectToCheck is ObjectToCheck &\n Record<\n Property,\n Property extends keyof ObjectToCheck ? ObjectToCheck[Property] : unknown\n > => Object.hasOwnProperty.call(objectToCheck, name);\n\n/**\n * `Object.getOwnPropertyNames()` is intentionally generic: it returns the\n * immediate property names of an object, but it cannot make guarantees about\n * the contents of that object, so the type of the property names is merely\n * `string[]`. While this is technically accurate, it is also unnecessary if we\n * have an object with a type that we own (such as an enum).\n *\n * @param object - The plain object.\n * @returns The own property names of the object which are assigned a type\n * derived from the object itself.\n */\nexport function getKnownPropertyNames<Key extends PropertyKey>(\n object: Partial<Record<Key, any>>,\n): Key[] {\n return Object.getOwnPropertyNames(object) as Key[];\n}\n\nexport type PlainObject = Record<number | string | symbol, unknown>;\n\n/**\n * Predefined sizes (in Bytes) of specific parts of JSON structure.\n */\nexport enum JsonSize {\n Null = 4,\n Comma = 1,\n Wrapper = 1,\n True = 4,\n False = 5,\n Quote = 1,\n Colon = 1,\n // eslint-disable-next-line @typescript-eslint/no-shadow\n Date = 24,\n}\n\n/**\n * Regular expression with pattern matching for (special) escaped characters.\n */\nexport const ESCAPE_CHARACTERS_REGEXP = /\"|\\\\|\\n|\\r|\\t/gu;\n\n/**\n * Check if the value is plain object.\n *\n * @param value - Value to be checked.\n * @returns True if an object is the plain JavaScript object,\n * false if the object is not plain (e.g. function).\n */\nexport function isPlainObject(value: unknown): value is PlainObject {\n if (typeof value !== 'object' || value === null) {\n return false;\n }\n\n try {\n let proto = value;\n while (Object.getPrototypeOf(proto) !== null) {\n proto = Object.getPrototypeOf(proto);\n }\n\n return Object.getPrototypeOf(value) === proto;\n } catch (_) {\n return false;\n }\n}\n\n/**\n * Check if character is ASCII.\n *\n * @param character - Character.\n * @returns True if a character code is ASCII, false if not.\n */\nexport function isASCII(character: string) {\n return character.charCodeAt(0) <= 127;\n}\n\n/**\n * Calculate string size.\n *\n * @param value - String value to calculate size.\n * @returns Number of bytes used to store whole string value.\n */\nexport function calculateStringSize(value: string): number {\n const size = value.split('').reduce((total, character) => {\n if (isASCII(character)) {\n return total + 1;\n }\n return total + 2;\n }, 0);\n\n // Also detect characters that need backslash escape\n return size + (value.match(ESCAPE_CHARACTERS_REGEXP) ?? []).length;\n}\n\n/**\n * Calculate size of a number ofter JSON serialization.\n *\n * @param value - Number value to calculate size.\n * @returns Number of bytes used to store whole number in JSON.\n */\nexport function calculateNumberSize(value: number): number {\n return value.toString().length;\n}\n"]}
|
package/dist/node.cjs
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./index.cjs"), exports);
|
|
18
|
+
__exportStar(require("./fs.cjs"), exports);
|
|
19
|
+
//# sourceMappingURL=node.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.cjs","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAAkB;AAClB,2CAAqB","sourcesContent":["export * from '.';\nexport * from './fs';\n"]}
|
package/dist/node.d.cts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.d.cts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA,4BAAkB;AAClB,yBAAqB"}
|
package/dist/node.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.d.mts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA,4BAAkB;AAClB,yBAAqB"}
|
package/dist/node.mjs
CHANGED
|
@@ -1,317 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
directoryExists,
|
|
4
|
-
ensureDirectoryStructureExists,
|
|
5
|
-
fileExists,
|
|
6
|
-
forceRemove,
|
|
7
|
-
readFile,
|
|
8
|
-
readJsonFile,
|
|
9
|
-
writeFile,
|
|
10
|
-
writeJsonFile
|
|
11
|
-
} from "./chunk-DYRKZQMK.mjs";
|
|
12
|
-
import "./chunk-622IOGVI.mjs";
|
|
13
|
-
import {
|
|
14
|
-
bigIntToHex,
|
|
15
|
-
hexToBigInt,
|
|
16
|
-
hexToNumber,
|
|
17
|
-
numberToHex
|
|
18
|
-
} from "./chunk-S3UHBN2Z.mjs";
|
|
19
|
-
import "./chunk-AY6FDCBT.mjs";
|
|
20
|
-
import {
|
|
21
|
-
createDeferredPromise
|
|
22
|
-
} from "./chunk-W5XI7ERF.mjs";
|
|
23
|
-
import {
|
|
24
|
-
Duration,
|
|
25
|
-
inMilliseconds,
|
|
26
|
-
timeSince
|
|
27
|
-
} from "./chunk-THNLGEXV.mjs";
|
|
28
|
-
import "./chunk-RRYOWRCV.mjs";
|
|
29
|
-
import {
|
|
30
|
-
VersionRangeStruct,
|
|
31
|
-
VersionStruct,
|
|
32
|
-
assertIsSemVerRange,
|
|
33
|
-
assertIsSemVerVersion,
|
|
34
|
-
gtRange,
|
|
35
|
-
gtVersion,
|
|
36
|
-
isValidSemVerRange,
|
|
37
|
-
isValidSemVerVersion,
|
|
38
|
-
satisfiesVersionRange
|
|
39
|
-
} from "./chunk-ROQSKDP5.mjs";
|
|
40
|
-
import {
|
|
41
|
-
JsonRpcErrorStruct,
|
|
42
|
-
JsonRpcFailureStruct,
|
|
43
|
-
JsonRpcIdStruct,
|
|
44
|
-
JsonRpcNotificationStruct,
|
|
45
|
-
JsonRpcParamsStruct,
|
|
46
|
-
JsonRpcRequestStruct,
|
|
47
|
-
JsonRpcResponseStruct,
|
|
48
|
-
JsonRpcSuccessStruct,
|
|
49
|
-
JsonRpcVersionStruct,
|
|
50
|
-
JsonStruct,
|
|
51
|
-
PendingJsonRpcResponseStruct,
|
|
52
|
-
UnsafeJsonStruct,
|
|
53
|
-
assertIsJsonRpcError,
|
|
54
|
-
assertIsJsonRpcFailure,
|
|
55
|
-
assertIsJsonRpcNotification,
|
|
56
|
-
assertIsJsonRpcRequest,
|
|
57
|
-
assertIsJsonRpcResponse,
|
|
58
|
-
assertIsJsonRpcSuccess,
|
|
59
|
-
assertIsPendingJsonRpcResponse,
|
|
60
|
-
exactOptional,
|
|
61
|
-
getJsonRpcIdValidator,
|
|
62
|
-
getJsonSize,
|
|
63
|
-
getSafeJson,
|
|
64
|
-
isJsonRpcError,
|
|
65
|
-
isJsonRpcFailure,
|
|
66
|
-
isJsonRpcNotification,
|
|
67
|
-
isJsonRpcRequest,
|
|
68
|
-
isJsonRpcResponse,
|
|
69
|
-
isJsonRpcSuccess,
|
|
70
|
-
isPendingJsonRpcResponse,
|
|
71
|
-
isValidJson,
|
|
72
|
-
jsonrpc2,
|
|
73
|
-
object
|
|
74
|
-
} from "./chunk-6C35XQOF.mjs";
|
|
75
|
-
import "./chunk-I575FZFH.mjs";
|
|
76
|
-
import {
|
|
77
|
-
createModuleLogger,
|
|
78
|
-
createProjectLogger
|
|
79
|
-
} from "./chunk-RIRDOQPX.mjs";
|
|
80
|
-
import {
|
|
81
|
-
CAIP_ACCOUNT_ADDRESS_REGEX,
|
|
82
|
-
CAIP_ACCOUNT_ID_REGEX,
|
|
83
|
-
CAIP_CHAIN_ID_REGEX,
|
|
84
|
-
CAIP_NAMESPACE_REGEX,
|
|
85
|
-
CAIP_REFERENCE_REGEX,
|
|
86
|
-
CaipAccountAddressStruct,
|
|
87
|
-
CaipAccountIdStruct,
|
|
88
|
-
CaipChainIdStruct,
|
|
89
|
-
CaipNamespaceStruct,
|
|
90
|
-
CaipReferenceStruct,
|
|
91
|
-
KnownCaipNamespace,
|
|
92
|
-
isCaipAccountAddress,
|
|
93
|
-
isCaipAccountId,
|
|
94
|
-
isCaipChainId,
|
|
95
|
-
isCaipNamespace,
|
|
96
|
-
isCaipReference,
|
|
97
|
-
parseCaipAccountId,
|
|
98
|
-
parseCaipChainId,
|
|
99
|
-
toCaipChainId
|
|
100
|
-
} from "./chunk-OUZ3LSLX.mjs";
|
|
101
|
-
import {
|
|
102
|
-
ChecksumStruct
|
|
103
|
-
} from "./chunk-GZS3IQBZ.mjs";
|
|
104
|
-
import {
|
|
105
|
-
base64
|
|
106
|
-
} from "./chunk-NQMRFZHB.mjs";
|
|
107
|
-
import {
|
|
108
|
-
createBigInt,
|
|
109
|
-
createBytes,
|
|
110
|
-
createHex,
|
|
111
|
-
createNumber
|
|
112
|
-
} from "./chunk-O3EIM33O.mjs";
|
|
113
|
-
import {
|
|
114
|
-
HexAddressStruct,
|
|
115
|
-
HexChecksumAddressStruct,
|
|
116
|
-
HexStruct,
|
|
117
|
-
StrictHexStruct,
|
|
118
|
-
add0x,
|
|
119
|
-
assertIsBytes,
|
|
120
|
-
assertIsHexString,
|
|
121
|
-
assertIsStrictHexString,
|
|
122
|
-
base64ToBytes,
|
|
123
|
-
bigIntToBytes,
|
|
124
|
-
bytesToBase64,
|
|
125
|
-
bytesToBigInt,
|
|
126
|
-
bytesToHex,
|
|
127
|
-
bytesToNumber,
|
|
128
|
-
bytesToSignedBigInt,
|
|
129
|
-
bytesToString,
|
|
130
|
-
concatBytes,
|
|
131
|
-
createDataView,
|
|
132
|
-
getChecksumAddress,
|
|
133
|
-
hexToBytes,
|
|
134
|
-
isBytes,
|
|
135
|
-
isHexString,
|
|
136
|
-
isStrictHexString,
|
|
137
|
-
isValidChecksumAddress,
|
|
138
|
-
isValidHexAddress,
|
|
139
|
-
numberToBytes,
|
|
140
|
-
remove0x,
|
|
141
|
-
signedBigIntToBytes,
|
|
142
|
-
stringToBytes,
|
|
143
|
-
valueToBytes
|
|
144
|
-
} from "./chunk-VA2DRBDE.mjs";
|
|
145
|
-
import {
|
|
146
|
-
AssertionError,
|
|
147
|
-
assert,
|
|
148
|
-
assertExhaustive,
|
|
149
|
-
assertStruct
|
|
150
|
-
} from "./chunk-74DGVJVE.mjs";
|
|
151
|
-
import {
|
|
152
|
-
getErrorMessage,
|
|
153
|
-
isErrorWithCode,
|
|
154
|
-
isErrorWithMessage,
|
|
155
|
-
isErrorWithStack,
|
|
156
|
-
wrapError
|
|
157
|
-
} from "./chunk-XYGUOY6N.mjs";
|
|
158
|
-
import {
|
|
159
|
-
ESCAPE_CHARACTERS_REGEXP,
|
|
160
|
-
JsonSize,
|
|
161
|
-
calculateNumberSize,
|
|
162
|
-
calculateStringSize,
|
|
163
|
-
getKnownPropertyNames,
|
|
164
|
-
hasProperty,
|
|
165
|
-
isASCII,
|
|
166
|
-
isNonEmptyArray,
|
|
167
|
-
isNullOrUndefined,
|
|
168
|
-
isObject,
|
|
169
|
-
isPlainObject
|
|
170
|
-
} from "./chunk-H4YFDLB7.mjs";
|
|
171
|
-
import {
|
|
172
|
-
FrozenMap,
|
|
173
|
-
FrozenSet
|
|
174
|
-
} from "./chunk-JPAL7Q5S.mjs";
|
|
175
|
-
import "./chunk-X66SUIEF.mjs";
|
|
176
|
-
import "./chunk-WA4DHIND.mjs";
|
|
177
|
-
export {
|
|
178
|
-
AssertionError,
|
|
179
|
-
CAIP_ACCOUNT_ADDRESS_REGEX,
|
|
180
|
-
CAIP_ACCOUNT_ID_REGEX,
|
|
181
|
-
CAIP_CHAIN_ID_REGEX,
|
|
182
|
-
CAIP_NAMESPACE_REGEX,
|
|
183
|
-
CAIP_REFERENCE_REGEX,
|
|
184
|
-
CaipAccountAddressStruct,
|
|
185
|
-
CaipAccountIdStruct,
|
|
186
|
-
CaipChainIdStruct,
|
|
187
|
-
CaipNamespaceStruct,
|
|
188
|
-
CaipReferenceStruct,
|
|
189
|
-
ChecksumStruct,
|
|
190
|
-
Duration,
|
|
191
|
-
ESCAPE_CHARACTERS_REGEXP,
|
|
192
|
-
FrozenMap,
|
|
193
|
-
FrozenSet,
|
|
194
|
-
HexAddressStruct,
|
|
195
|
-
HexChecksumAddressStruct,
|
|
196
|
-
HexStruct,
|
|
197
|
-
JsonRpcErrorStruct,
|
|
198
|
-
JsonRpcFailureStruct,
|
|
199
|
-
JsonRpcIdStruct,
|
|
200
|
-
JsonRpcNotificationStruct,
|
|
201
|
-
JsonRpcParamsStruct,
|
|
202
|
-
JsonRpcRequestStruct,
|
|
203
|
-
JsonRpcResponseStruct,
|
|
204
|
-
JsonRpcSuccessStruct,
|
|
205
|
-
JsonRpcVersionStruct,
|
|
206
|
-
JsonSize,
|
|
207
|
-
JsonStruct,
|
|
208
|
-
KnownCaipNamespace,
|
|
209
|
-
PendingJsonRpcResponseStruct,
|
|
210
|
-
StrictHexStruct,
|
|
211
|
-
UnsafeJsonStruct,
|
|
212
|
-
VersionRangeStruct,
|
|
213
|
-
VersionStruct,
|
|
214
|
-
add0x,
|
|
215
|
-
assert,
|
|
216
|
-
assertExhaustive,
|
|
217
|
-
assertIsBytes,
|
|
218
|
-
assertIsHexString,
|
|
219
|
-
assertIsJsonRpcError,
|
|
220
|
-
assertIsJsonRpcFailure,
|
|
221
|
-
assertIsJsonRpcNotification,
|
|
222
|
-
assertIsJsonRpcRequest,
|
|
223
|
-
assertIsJsonRpcResponse,
|
|
224
|
-
assertIsJsonRpcSuccess,
|
|
225
|
-
assertIsPendingJsonRpcResponse,
|
|
226
|
-
assertIsSemVerRange,
|
|
227
|
-
assertIsSemVerVersion,
|
|
228
|
-
assertIsStrictHexString,
|
|
229
|
-
assertStruct,
|
|
230
|
-
base64,
|
|
231
|
-
base64ToBytes,
|
|
232
|
-
bigIntToBytes,
|
|
233
|
-
bigIntToHex,
|
|
234
|
-
bytesToBase64,
|
|
235
|
-
bytesToBigInt,
|
|
236
|
-
bytesToHex,
|
|
237
|
-
bytesToNumber,
|
|
238
|
-
bytesToSignedBigInt,
|
|
239
|
-
bytesToString,
|
|
240
|
-
calculateNumberSize,
|
|
241
|
-
calculateStringSize,
|
|
242
|
-
concatBytes,
|
|
243
|
-
createBigInt,
|
|
244
|
-
createBytes,
|
|
245
|
-
createDataView,
|
|
246
|
-
createDeferredPromise,
|
|
247
|
-
createHex,
|
|
248
|
-
createModuleLogger,
|
|
249
|
-
createNumber,
|
|
250
|
-
createProjectLogger,
|
|
251
|
-
createSandbox,
|
|
252
|
-
directoryExists,
|
|
253
|
-
ensureDirectoryStructureExists,
|
|
254
|
-
exactOptional,
|
|
255
|
-
fileExists,
|
|
256
|
-
forceRemove,
|
|
257
|
-
getChecksumAddress,
|
|
258
|
-
getErrorMessage,
|
|
259
|
-
getJsonRpcIdValidator,
|
|
260
|
-
getJsonSize,
|
|
261
|
-
getKnownPropertyNames,
|
|
262
|
-
getSafeJson,
|
|
263
|
-
gtRange,
|
|
264
|
-
gtVersion,
|
|
265
|
-
hasProperty,
|
|
266
|
-
hexToBigInt,
|
|
267
|
-
hexToBytes,
|
|
268
|
-
hexToNumber,
|
|
269
|
-
inMilliseconds,
|
|
270
|
-
isASCII,
|
|
271
|
-
isBytes,
|
|
272
|
-
isCaipAccountAddress,
|
|
273
|
-
isCaipAccountId,
|
|
274
|
-
isCaipChainId,
|
|
275
|
-
isCaipNamespace,
|
|
276
|
-
isCaipReference,
|
|
277
|
-
isErrorWithCode,
|
|
278
|
-
isErrorWithMessage,
|
|
279
|
-
isErrorWithStack,
|
|
280
|
-
isHexString,
|
|
281
|
-
isJsonRpcError,
|
|
282
|
-
isJsonRpcFailure,
|
|
283
|
-
isJsonRpcNotification,
|
|
284
|
-
isJsonRpcRequest,
|
|
285
|
-
isJsonRpcResponse,
|
|
286
|
-
isJsonRpcSuccess,
|
|
287
|
-
isNonEmptyArray,
|
|
288
|
-
isNullOrUndefined,
|
|
289
|
-
isObject,
|
|
290
|
-
isPendingJsonRpcResponse,
|
|
291
|
-
isPlainObject,
|
|
292
|
-
isStrictHexString,
|
|
293
|
-
isValidChecksumAddress,
|
|
294
|
-
isValidHexAddress,
|
|
295
|
-
isValidJson,
|
|
296
|
-
isValidSemVerRange,
|
|
297
|
-
isValidSemVerVersion,
|
|
298
|
-
jsonrpc2,
|
|
299
|
-
numberToBytes,
|
|
300
|
-
numberToHex,
|
|
301
|
-
object,
|
|
302
|
-
parseCaipAccountId,
|
|
303
|
-
parseCaipChainId,
|
|
304
|
-
readFile,
|
|
305
|
-
readJsonFile,
|
|
306
|
-
remove0x,
|
|
307
|
-
satisfiesVersionRange,
|
|
308
|
-
signedBigIntToBytes,
|
|
309
|
-
stringToBytes,
|
|
310
|
-
timeSince,
|
|
311
|
-
toCaipChainId,
|
|
312
|
-
valueToBytes,
|
|
313
|
-
wrapError,
|
|
314
|
-
writeFile,
|
|
315
|
-
writeJsonFile
|
|
316
|
-
};
|
|
1
|
+
export * from "./index.mjs";
|
|
2
|
+
export * from "./fs.mjs";
|
|
317
3
|
//# sourceMappingURL=node.mjs.map
|
package/dist/node.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"
|
|
1
|
+
{"version":3,"file":"node.mjs","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA,4BAAkB;AAClB,yBAAqB","sourcesContent":["export * from '.';\nexport * from './fs';\n"]}
|