tinybase 8.4.2 → 8.5.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/@types/ui-react-dom/index.d.ts +10 -10
- package/@types/ui-react-dom/with-schemas/index.d.ts +10 -10
- package/@types/ui-react-dom-charts/index.d.ts +242 -0
- package/@types/ui-react-dom-charts/with-schemas/index.d.ts +296 -0
- package/@types/ui-react-inspector/index.d.ts +1 -1
- package/@types/ui-react-inspector/with-schemas/index.d.ts +1 -1
- package/@types/ui-solid-dom/index.d.ts +10 -10
- package/@types/ui-solid-dom/with-schemas/index.d.ts +10 -10
- package/@types/ui-solid-inspector/index.d.ts +1 -1
- package/@types/ui-solid-inspector/with-schemas/index.d.ts +1 -1
- package/@types/ui-svelte-dom/index.d.ts +10 -10
- package/@types/ui-svelte-dom/with-schemas/index.d.ts +10 -10
- package/@types/ui-svelte-inspector/index.d.ts +1 -1
- package/@types/ui-svelte-inspector/with-schemas/index.d.ts +1 -1
- package/common/index.js +3 -2
- package/common/with-schemas/index.js +3 -2
- package/index.js +5 -3
- package/mergeable-store/index.js +5 -3
- package/mergeable-store/with-schemas/index.js +5 -3
- package/metrics/index.js +1 -1
- package/metrics/with-schemas/index.js +1 -1
- package/min/common/index.js +1 -1
- package/min/common/index.js.gz +0 -0
- package/min/common/with-schemas/index.js +1 -1
- package/min/common/with-schemas/index.js.gz +0 -0
- package/min/index.js +1 -1
- package/min/index.js.gz +0 -0
- package/min/mergeable-store/index.js +1 -1
- package/min/mergeable-store/index.js.gz +0 -0
- package/min/mergeable-store/with-schemas/index.js +1 -1
- package/min/mergeable-store/with-schemas/index.js.gz +0 -0
- package/min/omni/index.js +1 -1
- package/min/omni/index.js.gz +0 -0
- package/min/omni/with-schemas/index.js +1 -1
- package/min/omni/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-durable-object-sql-storage/index.js +1 -1
- package/min/persisters/persister-durable-object-sql-storage/index.js.gz +0 -0
- package/min/persisters/persister-durable-object-sql-storage/with-schemas/index.js +1 -1
- package/min/persisters/persister-durable-object-sql-storage/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-partykit-server/index.js +1 -1
- package/min/persisters/persister-partykit-server/index.js.gz +0 -0
- package/min/persisters/persister-partykit-server/with-schemas/index.js +1 -1
- package/min/persisters/persister-partykit-server/with-schemas/index.js.gz +0 -0
- package/min/queries/index.js +1 -1
- package/min/queries/index.js.gz +0 -0
- package/min/queries/with-schemas/index.js +1 -1
- package/min/queries/with-schemas/index.js.gz +0 -0
- package/min/synchronizers/index.js +1 -1
- package/min/synchronizers/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-broadcast-channel/index.js +1 -1
- package/min/synchronizers/synchronizer-broadcast-channel/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-broadcast-channel/with-schemas/index.js +1 -1
- package/min/synchronizers/synchronizer-broadcast-channel/with-schemas/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-local/index.js +1 -1
- package/min/synchronizers/synchronizer-local/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-local/with-schemas/index.js +1 -1
- package/min/synchronizers/synchronizer-local/with-schemas/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-ws-client/index.js +1 -1
- package/min/synchronizers/synchronizer-ws-client/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-ws-client/with-schemas/index.js +1 -1
- package/min/synchronizers/synchronizer-ws-client/with-schemas/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-ws-server/index.js +1 -1
- package/min/synchronizers/synchronizer-ws-server/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-ws-server/with-schemas/index.js +1 -1
- package/min/synchronizers/synchronizer-ws-server/with-schemas/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-ws-server-durable-object/index.js +1 -1
- package/min/synchronizers/synchronizer-ws-server-durable-object/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js +1 -1
- package/min/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js.gz +0 -0
- package/min/synchronizers/with-schemas/index.js +1 -1
- package/min/synchronizers/with-schemas/index.js.gz +0 -0
- package/min/ui-react-dom/index.js +1 -1
- package/min/ui-react-dom/index.js.gz +0 -0
- package/min/ui-react-dom/with-schemas/index.js +1 -1
- package/min/ui-react-dom/with-schemas/index.js.gz +0 -0
- package/min/ui-react-dom-charts/index.js +1 -0
- package/min/ui-react-dom-charts/index.js.gz +0 -0
- package/min/ui-react-dom-charts/with-schemas/index.js +1 -0
- package/min/ui-react-dom-charts/with-schemas/index.js.gz +0 -0
- package/min/ui-react-inspector/index.js +1 -1
- package/min/ui-react-inspector/index.js.gz +0 -0
- package/min/ui-react-inspector/with-schemas/index.js +1 -1
- package/min/ui-react-inspector/with-schemas/index.js.gz +0 -0
- package/min/ui-solid-dom/index.js +1 -1
- package/min/ui-solid-dom/index.js.gz +0 -0
- package/min/ui-solid-dom/with-schemas/index.js +1 -1
- package/min/ui-solid-dom/with-schemas/index.js.gz +0 -0
- package/min/ui-solid-inspector/index.js +1 -1
- package/min/ui-solid-inspector/index.js.gz +0 -0
- package/min/ui-solid-inspector/with-schemas/index.js +1 -1
- package/min/ui-solid-inspector/with-schemas/index.js.gz +0 -0
- package/min/ui-svelte-dom/index.js +1 -1
- package/min/ui-svelte-dom/index.js.gz +0 -0
- package/min/ui-svelte-dom/with-schemas/index.js +1 -1
- package/min/ui-svelte-dom/with-schemas/index.js.gz +0 -0
- package/min/ui-svelte-inspector/index.js +1 -1
- package/min/ui-svelte-inspector/index.js.gz +0 -0
- package/min/ui-svelte-inspector/with-schemas/index.js +1 -1
- package/min/ui-svelte-inspector/with-schemas/index.js.gz +0 -0
- package/min/with-schemas/index.js +1 -1
- package/min/with-schemas/index.js.gz +0 -0
- package/omni/index.js +7 -4
- package/omni/with-schemas/index.js +7 -4
- package/package.json +38 -2
- package/persisters/persister-durable-object-sql-storage/index.js +13 -11
- package/persisters/persister-durable-object-sql-storage/with-schemas/index.js +13 -11
- package/persisters/persister-partykit-client/index.js +2 -1
- package/persisters/persister-partykit-client/with-schemas/index.js +2 -1
- package/persisters/persister-partykit-server/index.js +2 -1
- package/persisters/persister-partykit-server/with-schemas/index.js +2 -1
- package/queries/index.js +1 -1
- package/queries/with-schemas/index.js +1 -1
- package/readme.md +18 -14
- package/releases.md +91 -58
- package/synchronizers/index.js +3 -2
- package/synchronizers/synchronizer-broadcast-channel/index.js +3 -2
- package/synchronizers/synchronizer-broadcast-channel/with-schemas/index.js +3 -2
- package/synchronizers/synchronizer-local/index.js +3 -2
- package/synchronizers/synchronizer-local/with-schemas/index.js +3 -2
- package/synchronizers/synchronizer-ws-client/index.js +3 -2
- package/synchronizers/synchronizer-ws-client/with-schemas/index.js +3 -2
- package/synchronizers/synchronizer-ws-server/index.js +3 -2
- package/synchronizers/synchronizer-ws-server/with-schemas/index.js +3 -2
- package/synchronizers/synchronizer-ws-server-durable-object/index.js +3 -2
- package/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js +3 -2
- package/synchronizers/with-schemas/index.js +3 -2
- package/ui-react-dom/index.js +10 -7
- package/ui-react-dom/with-schemas/index.js +10 -7
- package/ui-react-dom-charts/index.js +1229 -0
- package/ui-react-dom-charts/with-schemas/index.js +1229 -0
- package/ui-react-inspector/index.js +13 -9
- package/ui-react-inspector/with-schemas/index.js +13 -9
- package/ui-solid-dom/index.js +10 -7
- package/ui-solid-dom/with-schemas/index.js +10 -7
- package/ui-solid-inspector/index.js +13 -9
- package/ui-solid-inspector/with-schemas/index.js +13 -9
- package/ui-svelte-dom/index.js +11 -8
- package/ui-svelte-dom/with-schemas/index.js +11 -8
- package/ui-svelte-inspector/index.js +17 -13
- package/ui-svelte-inspector/with-schemas/index.js +17 -13
- package/with-schemas/index.js +5 -3
|
@@ -47,6 +47,7 @@ const UNDEFINED = '\uFFFC';
|
|
|
47
47
|
const JSON_PREFIX = '\uFFFD';
|
|
48
48
|
const id = (key) => EMPTY_STRING + key;
|
|
49
49
|
|
|
50
|
+
const math = Math;
|
|
50
51
|
const getIfNotFunction = (predicate) => (value, then, otherwise) =>
|
|
51
52
|
predicate(value)
|
|
52
53
|
? /* istanbul ignore next */
|
|
@@ -54,7 +55,9 @@ const getIfNotFunction = (predicate) => (value, then, otherwise) =>
|
|
|
54
55
|
: then(value);
|
|
55
56
|
const GLOBAL = globalThis;
|
|
56
57
|
const WINDOW = GLOBAL.window;
|
|
57
|
-
const
|
|
58
|
+
const number = Number;
|
|
59
|
+
const string = String;
|
|
60
|
+
const boolean = Boolean;
|
|
58
61
|
const mathMin = math.min;
|
|
59
62
|
const mathFloor = math.floor;
|
|
60
63
|
const isFiniteNumber = isFinite;
|
|
@@ -97,6 +100,7 @@ const tryCatch = async (action, then1, then2) => {
|
|
|
97
100
|
};
|
|
98
101
|
|
|
99
102
|
const arrayHas = (array, value) => array.includes(value);
|
|
103
|
+
const arrayIndexOf = (array, value) => array.indexOf(value);
|
|
100
104
|
const arrayEvery = (array, cb) => array.every(cb);
|
|
101
105
|
const arrayIsEqual = (array1, array2) =>
|
|
102
106
|
size(array1) === size(array2) &&
|
|
@@ -215,7 +219,7 @@ const NO_PROVIDED_OBJECTS_MESSAGE =
|
|
|
215
219
|
const INSPECTOR_ERROR_MESSAGE =
|
|
216
220
|
'Inspector error: please see console for details.';
|
|
217
221
|
const getInitialPosition = (position) => {
|
|
218
|
-
const index = POSITIONS
|
|
222
|
+
const index = arrayIndexOf(POSITIONS, position);
|
|
219
223
|
return index == -1 ? 1 : index;
|
|
220
224
|
};
|
|
221
225
|
const getUniqueId = (...args) => jsonStringWithMap(args);
|
|
@@ -3489,7 +3493,7 @@ function EditableThing($$anchor, $$props) {
|
|
|
3489
3493
|
let objectClassName = $.state(EMPTY_STRING);
|
|
3490
3494
|
let arrayClassName = $.state(EMPTY_STRING);
|
|
3491
3495
|
const getThingKey = (thing) =>
|
|
3492
|
-
`${getCellOrValueType(thing)}:${isObject(thing) || isArray(thing) ? jsonString
|
|
3496
|
+
`${getCellOrValueType(thing)}:${(isObject(thing) || isArray(thing) ? jsonString : string)(thing)}`;
|
|
3493
3497
|
|
|
3494
3498
|
$.user_effect(() => {
|
|
3495
3499
|
const thingKey = getThingKey($$props.thing);
|
|
@@ -3503,9 +3507,9 @@ function EditableThing($$anchor, $$props) {
|
|
|
3503
3507
|
} else if (isArray($$props.thing)) {
|
|
3504
3508
|
$.set(arrayThing, jsonString($$props.thing), true);
|
|
3505
3509
|
} else {
|
|
3506
|
-
$.set(stringThing,
|
|
3507
|
-
$.set(numberThing,
|
|
3508
|
-
$.set(booleanThing,
|
|
3510
|
+
$.set(stringThing, string($$props.thing), true);
|
|
3511
|
+
$.set(numberThing, number($$props.thing) || 0, true);
|
|
3512
|
+
$.set(booleanThing, boolean($$props.thing), true);
|
|
3509
3513
|
}
|
|
3510
3514
|
}
|
|
3511
3515
|
});
|
|
@@ -3599,7 +3603,7 @@ function EditableThing($$anchor, $$props) {
|
|
|
3599
3603
|
$.remove_input_defaults(input);
|
|
3600
3604
|
$.template_effect(() => $.set_value(input, $.get(stringThing)));
|
|
3601
3605
|
$.delegated('input', input, (event) =>
|
|
3602
|
-
handleThingChange(
|
|
3606
|
+
handleThingChange(string(event.currentTarget.value), (value) =>
|
|
3603
3607
|
$.set(stringThing, value, true),
|
|
3604
3608
|
),
|
|
3605
3609
|
);
|
|
@@ -3612,7 +3616,7 @@ function EditableThing($$anchor, $$props) {
|
|
|
3612
3616
|
$.remove_input_defaults(input_1);
|
|
3613
3617
|
$.template_effect(() => $.set_value(input_1, $.get(numberThing)));
|
|
3614
3618
|
$.delegated('input', input_1, (event) =>
|
|
3615
|
-
handleThingChange(
|
|
3619
|
+
handleThingChange(number(event.currentTarget.value || 0), (value) =>
|
|
3616
3620
|
$.set(numberThing, value, true),
|
|
3617
3621
|
),
|
|
3618
3622
|
);
|
|
@@ -3625,7 +3629,7 @@ function EditableThing($$anchor, $$props) {
|
|
|
3625
3629
|
$.remove_input_defaults(input_2);
|
|
3626
3630
|
$.template_effect(() => $.set_checked(input_2, $.get(booleanThing)));
|
|
3627
3631
|
$.delegated('change', input_2, (event) =>
|
|
3628
|
-
handleThingChange(
|
|
3632
|
+
handleThingChange(boolean(event.currentTarget.checked), (value) =>
|
|
3629
3633
|
$.set(booleanThing, value, true),
|
|
3630
3634
|
),
|
|
3631
3635
|
);
|
|
@@ -7209,11 +7213,11 @@ function Body($$anchor, $$props) {
|
|
|
7209
7213
|
const observer = new MutationObserver(() => {
|
|
7210
7214
|
if (
|
|
7211
7215
|
articleElement.scrollWidth >=
|
|
7212
|
-
mathFloor(
|
|
7216
|
+
mathFloor(number(scrollLeft)) + articleElement.clientWidth &&
|
|
7213
7217
|
articleElement.scrollHeight >=
|
|
7214
|
-
mathFloor(
|
|
7218
|
+
mathFloor(number(scrollTop)) + articleElement.clientHeight
|
|
7215
7219
|
) {
|
|
7216
|
-
articleElement.scrollTo(
|
|
7220
|
+
articleElement.scrollTo(number(scrollLeft), number(scrollTop));
|
|
7217
7221
|
}
|
|
7218
7222
|
});
|
|
7219
7223
|
|
|
@@ -7473,7 +7477,7 @@ function Header($$anchor, $$props) {
|
|
|
7473
7477
|
const handleClick = () => open('https://tinybase.org', '_blank');
|
|
7474
7478
|
const handleClose = () => $$props.s.setValue(OPEN_VALUE, false);
|
|
7475
7479
|
const handleDock = (event) =>
|
|
7476
|
-
$$props.s.setValue(POSITION_VALUE,
|
|
7480
|
+
$$props.s.setValue(POSITION_VALUE, number(event.currentTarget.dataset.id));
|
|
7477
7481
|
|
|
7478
7482
|
const onKeyDown = (event, handle) => {
|
|
7479
7483
|
if (event.key == 'Enter' || event.key == ' ') {
|
|
@@ -47,6 +47,7 @@ const UNDEFINED = '\uFFFC';
|
|
|
47
47
|
const JSON_PREFIX = '\uFFFD';
|
|
48
48
|
const id = (key) => EMPTY_STRING + key;
|
|
49
49
|
|
|
50
|
+
const math = Math;
|
|
50
51
|
const getIfNotFunction = (predicate) => (value, then, otherwise) =>
|
|
51
52
|
predicate(value)
|
|
52
53
|
? /* istanbul ignore next */
|
|
@@ -54,7 +55,9 @@ const getIfNotFunction = (predicate) => (value, then, otherwise) =>
|
|
|
54
55
|
: then(value);
|
|
55
56
|
const GLOBAL = globalThis;
|
|
56
57
|
const WINDOW = GLOBAL.window;
|
|
57
|
-
const
|
|
58
|
+
const number = Number;
|
|
59
|
+
const string = String;
|
|
60
|
+
const boolean = Boolean;
|
|
58
61
|
const mathMin = math.min;
|
|
59
62
|
const mathFloor = math.floor;
|
|
60
63
|
const isFiniteNumber = isFinite;
|
|
@@ -97,6 +100,7 @@ const tryCatch = async (action, then1, then2) => {
|
|
|
97
100
|
};
|
|
98
101
|
|
|
99
102
|
const arrayHas = (array, value) => array.includes(value);
|
|
103
|
+
const arrayIndexOf = (array, value) => array.indexOf(value);
|
|
100
104
|
const arrayEvery = (array, cb) => array.every(cb);
|
|
101
105
|
const arrayIsEqual = (array1, array2) =>
|
|
102
106
|
size(array1) === size(array2) &&
|
|
@@ -215,7 +219,7 @@ const NO_PROVIDED_OBJECTS_MESSAGE =
|
|
|
215
219
|
const INSPECTOR_ERROR_MESSAGE =
|
|
216
220
|
'Inspector error: please see console for details.';
|
|
217
221
|
const getInitialPosition = (position) => {
|
|
218
|
-
const index = POSITIONS
|
|
222
|
+
const index = arrayIndexOf(POSITIONS, position);
|
|
219
223
|
return index == -1 ? 1 : index;
|
|
220
224
|
};
|
|
221
225
|
const getUniqueId = (...args) => jsonStringWithMap(args);
|
|
@@ -3489,7 +3493,7 @@ function EditableThing($$anchor, $$props) {
|
|
|
3489
3493
|
let objectClassName = $.state(EMPTY_STRING);
|
|
3490
3494
|
let arrayClassName = $.state(EMPTY_STRING);
|
|
3491
3495
|
const getThingKey = (thing) =>
|
|
3492
|
-
`${getCellOrValueType(thing)}:${isObject(thing) || isArray(thing) ? jsonString
|
|
3496
|
+
`${getCellOrValueType(thing)}:${(isObject(thing) || isArray(thing) ? jsonString : string)(thing)}`;
|
|
3493
3497
|
|
|
3494
3498
|
$.user_effect(() => {
|
|
3495
3499
|
const thingKey = getThingKey($$props.thing);
|
|
@@ -3503,9 +3507,9 @@ function EditableThing($$anchor, $$props) {
|
|
|
3503
3507
|
} else if (isArray($$props.thing)) {
|
|
3504
3508
|
$.set(arrayThing, jsonString($$props.thing), true);
|
|
3505
3509
|
} else {
|
|
3506
|
-
$.set(stringThing,
|
|
3507
|
-
$.set(numberThing,
|
|
3508
|
-
$.set(booleanThing,
|
|
3510
|
+
$.set(stringThing, string($$props.thing), true);
|
|
3511
|
+
$.set(numberThing, number($$props.thing) || 0, true);
|
|
3512
|
+
$.set(booleanThing, boolean($$props.thing), true);
|
|
3509
3513
|
}
|
|
3510
3514
|
}
|
|
3511
3515
|
});
|
|
@@ -3599,7 +3603,7 @@ function EditableThing($$anchor, $$props) {
|
|
|
3599
3603
|
$.remove_input_defaults(input);
|
|
3600
3604
|
$.template_effect(() => $.set_value(input, $.get(stringThing)));
|
|
3601
3605
|
$.delegated('input', input, (event) =>
|
|
3602
|
-
handleThingChange(
|
|
3606
|
+
handleThingChange(string(event.currentTarget.value), (value) =>
|
|
3603
3607
|
$.set(stringThing, value, true),
|
|
3604
3608
|
),
|
|
3605
3609
|
);
|
|
@@ -3612,7 +3616,7 @@ function EditableThing($$anchor, $$props) {
|
|
|
3612
3616
|
$.remove_input_defaults(input_1);
|
|
3613
3617
|
$.template_effect(() => $.set_value(input_1, $.get(numberThing)));
|
|
3614
3618
|
$.delegated('input', input_1, (event) =>
|
|
3615
|
-
handleThingChange(
|
|
3619
|
+
handleThingChange(number(event.currentTarget.value || 0), (value) =>
|
|
3616
3620
|
$.set(numberThing, value, true),
|
|
3617
3621
|
),
|
|
3618
3622
|
);
|
|
@@ -3625,7 +3629,7 @@ function EditableThing($$anchor, $$props) {
|
|
|
3625
3629
|
$.remove_input_defaults(input_2);
|
|
3626
3630
|
$.template_effect(() => $.set_checked(input_2, $.get(booleanThing)));
|
|
3627
3631
|
$.delegated('change', input_2, (event) =>
|
|
3628
|
-
handleThingChange(
|
|
3632
|
+
handleThingChange(boolean(event.currentTarget.checked), (value) =>
|
|
3629
3633
|
$.set(booleanThing, value, true),
|
|
3630
3634
|
),
|
|
3631
3635
|
);
|
|
@@ -7209,11 +7213,11 @@ function Body($$anchor, $$props) {
|
|
|
7209
7213
|
const observer = new MutationObserver(() => {
|
|
7210
7214
|
if (
|
|
7211
7215
|
articleElement.scrollWidth >=
|
|
7212
|
-
mathFloor(
|
|
7216
|
+
mathFloor(number(scrollLeft)) + articleElement.clientWidth &&
|
|
7213
7217
|
articleElement.scrollHeight >=
|
|
7214
|
-
mathFloor(
|
|
7218
|
+
mathFloor(number(scrollTop)) + articleElement.clientHeight
|
|
7215
7219
|
) {
|
|
7216
|
-
articleElement.scrollTo(
|
|
7220
|
+
articleElement.scrollTo(number(scrollLeft), number(scrollTop));
|
|
7217
7221
|
}
|
|
7218
7222
|
});
|
|
7219
7223
|
|
|
@@ -7473,7 +7477,7 @@ function Header($$anchor, $$props) {
|
|
|
7473
7477
|
const handleClick = () => open('https://tinybase.org', '_blank');
|
|
7474
7478
|
const handleClose = () => $$props.s.setValue(OPEN_VALUE, false);
|
|
7475
7479
|
const handleDock = (event) =>
|
|
7476
|
-
$$props.s.setValue(POSITION_VALUE,
|
|
7480
|
+
$$props.s.setValue(POSITION_VALUE, number(event.currentTarget.dataset.id));
|
|
7477
7481
|
|
|
7478
7482
|
const onKeyDown = (event, handle) => {
|
|
7479
7483
|
if (event.key == 'Enter' || event.key == ' ') {
|
package/with-schemas/index.js
CHANGED
|
@@ -42,16 +42,17 @@ const strEndsWith = (str, suffix) => str.endsWith(suffix);
|
|
|
42
42
|
const strSplit = (str, separator = EMPTY_STRING, limit) =>
|
|
43
43
|
str.split(separator, limit);
|
|
44
44
|
|
|
45
|
+
const math = Math;
|
|
45
46
|
const getIfNotFunction = (predicate) => (value, then, otherwise) =>
|
|
46
47
|
predicate(value)
|
|
47
48
|
? /* istanbul ignore next */
|
|
48
49
|
otherwise?.()
|
|
49
50
|
: then(value);
|
|
50
51
|
const GLOBAL = globalThis;
|
|
51
|
-
const math = Math;
|
|
52
52
|
const mathMax = math.max;
|
|
53
53
|
const mathMin = math.min;
|
|
54
54
|
const mathFloor = math.floor;
|
|
55
|
+
const mathRandom = math.random;
|
|
55
56
|
const isFiniteNumber = isFinite;
|
|
56
57
|
const isInstanceOf = (thing, cls) => thing instanceof cls;
|
|
57
58
|
const isNullish = (thing) => thing == null;
|
|
@@ -63,6 +64,7 @@ const ifNotNullish = getIfNotFunction(isNullish);
|
|
|
63
64
|
const ifNotUndefined = getIfNotFunction(isUndefined);
|
|
64
65
|
const isTypeStringOrBoolean = (type) => type == STRING || type == BOOLEAN;
|
|
65
66
|
const isString = (thing) => getTypeOf(thing) == STRING;
|
|
67
|
+
const isNumber = (thing) => getTypeOf(thing) == NUMBER;
|
|
66
68
|
const isFunction = (thing) => getTypeOf(thing) == FUNCTION;
|
|
67
69
|
const isArray = (thing) => Array.isArray(thing);
|
|
68
70
|
const slice = (arrayOrString, start, end) => arrayOrString.slice(start, end);
|
|
@@ -785,7 +787,7 @@ const decode = (str, pos) => mapGet(DECODE, str[pos]) ?? 0;
|
|
|
785
787
|
const getRandomValues = GLOBAL.crypto
|
|
786
788
|
? (array) => GLOBAL.crypto.getRandomValues(array)
|
|
787
789
|
: /* istanbul ignore next */
|
|
788
|
-
(array) => arrayMap(array, () => mathFloor(
|
|
790
|
+
(array) => arrayMap(array, () => mathFloor(mathRandom() * 256));
|
|
789
791
|
const getUniqueId = (length = 16) =>
|
|
790
792
|
arrayReduce(
|
|
791
793
|
getRandomValues(new Uint8Array(length)),
|
|
@@ -1191,7 +1193,7 @@ const stampValidate = (stamp, validateThing) =>
|
|
|
1191
1193
|
isArray(stamp) &&
|
|
1192
1194
|
size(stamp) == 3 &&
|
|
1193
1195
|
isString(stamp[1]) &&
|
|
1194
|
-
|
|
1196
|
+
isNumber(stamp[2]) &&
|
|
1195
1197
|
isFiniteNumber(stamp[2]) &&
|
|
1196
1198
|
validateThing(stamp[0]);
|
|
1197
1199
|
|