@keeex/utils 7.3.0 → 7.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.
Files changed (56) hide show
  1. package/lib/async/eventqueue.d.ts +60 -0
  2. package/lib/async/eventqueue.js +129 -0
  3. package/lib/async/keycache.d.ts +1 -1
  4. package/lib/async/timecache.d.ts +1 -1
  5. package/lib/benchmark.d.ts +1 -1
  6. package/lib/benchmark.js +2 -2
  7. package/lib/bits/arraybuffer.js +2 -1
  8. package/lib/bits/triggers/base.d.ts +3 -3
  9. package/lib/bits/triggers/base.js +3 -3
  10. package/lib/bits/triggers/debounce.d.ts +1 -1
  11. package/lib/bits/triggers/grenade.d.ts +1 -1
  12. package/lib/bits/triggers/types.d.ts +1 -1
  13. package/lib/cron.d.ts +2 -2
  14. package/lib/cron.js +1 -1
  15. package/lib/dataview.d.ts +22 -0
  16. package/lib/dataview.js +29 -0
  17. package/lib/marshalling/marshaller.d.ts +1 -1
  18. package/lib/promise.d.ts +1 -1
  19. package/lib/promise.js +0 -1
  20. package/lib/triggers.d.ts +4 -4
  21. package/lib/types/array.d.ts +6 -6
  22. package/lib/types/array.js +3 -3
  23. package/lib/types/enum.d.ts +3 -3
  24. package/lib/types/enum.js +2 -2
  25. package/lib/types/record.d.ts +7 -7
  26. package/lib/types/record.js +3 -3
  27. package/lib/types/utils.d.ts +4 -3
  28. package/lib/types/utils.js +13 -6
  29. package/package.json +1 -1
  30. package/web/async/eventqueue.d.ts +60 -0
  31. package/web/async/eventqueue.js +126 -0
  32. package/web/async/keycache.d.ts +1 -1
  33. package/web/async/timecache.d.ts +1 -1
  34. package/web/benchmark.d.ts +1 -1
  35. package/web/benchmark.js +2 -2
  36. package/web/bits/arraybuffer.js +3 -1
  37. package/web/bits/triggers/base.d.ts +3 -3
  38. package/web/bits/triggers/base.js +3 -3
  39. package/web/bits/triggers/debounce.d.ts +1 -1
  40. package/web/bits/triggers/grenade.d.ts +1 -1
  41. package/web/bits/triggers/types.d.ts +1 -1
  42. package/web/cron.d.ts +2 -2
  43. package/web/dataview.d.ts +22 -0
  44. package/web/dataview.js +27 -0
  45. package/web/marshalling/marshaller.d.ts +1 -1
  46. package/web/promise.d.ts +1 -1
  47. package/web/promise.js +0 -1
  48. package/web/triggers.d.ts +4 -4
  49. package/web/types/array.d.ts +6 -6
  50. package/web/types/array.js +3 -3
  51. package/web/types/enum.d.ts +3 -3
  52. package/web/types/enum.js +2 -2
  53. package/web/types/record.d.ts +7 -7
  54. package/web/types/record.js +3 -3
  55. package/web/types/utils.d.ts +4 -3
  56. package/web/types/utils.js +6 -6
package/web/types/enum.js CHANGED
@@ -14,7 +14,7 @@
14
14
  *
15
15
  */
16
16
  import { PredicateError } from "./predicateerror.js";
17
- import { getPredicateOptions } from "./types.js";
17
+ import * as types from "./types.js";
18
18
  /**
19
19
  * Return an enum-type value whose key matches the provided key string.
20
20
  *
@@ -31,7 +31,7 @@ export const keyToEnum = (key, enumType) => {
31
31
  * @public
32
32
  */
33
33
  export const isEnumType = (obj, enumType, options = false) => {
34
- const opt = getPredicateOptions(options);
34
+ const opt = types.getPredicateOptions(options);
35
35
  const res = Object.values(enumType).includes(obj);
36
36
  if (!res) PredicateError.expected(opt.raise, undefined, "value from enum");
37
37
  return res;
@@ -13,7 +13,7 @@
13
13
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
14
14
  *
15
15
  */
16
- import { PredicateOptions, TypePredicate } from "./types.js";
16
+ import * as types from "./types.js";
17
17
  interface ProfileValue<T = unknown> {
18
18
  value: T;
19
19
  optional?: boolean;
@@ -25,12 +25,12 @@ interface InstanceOfValue {
25
25
  shortcut?: boolean;
26
26
  }
27
27
  interface PredicateValue<T = unknown> {
28
- predicate: TypePredicate<T>;
28
+ predicate: types.TypePredicate<T>;
29
29
  optional?: boolean;
30
30
  shortcut?: boolean;
31
31
  }
32
32
  type AdvancedProfileValue = ProfileValue | InstanceOfValue | PredicateValue;
33
- type ProfileEntryType = string | TypePredicate | AdvancedProfileValue;
33
+ type ProfileEntryType = string | types.TypePredicate | AdvancedProfileValue;
34
34
  /**
35
35
  * Simple profile to check.
36
36
  *
@@ -49,19 +49,19 @@ export type Profile<T> = Record<keyof T, ProfileEntryType | Array<ProfileEntryTy
49
49
  *
50
50
  * @public
51
51
  */
52
- export declare const isObjectProfile: <T>(obj: unknown, profile: Profile<T>, options?: PredicateOptions) => obj is T;
52
+ export declare const isObjectProfile: <T>(obj: unknown, profile: Profile<T>, options?: types.PredicateOptions) => obj is T;
53
53
  /**
54
54
  * Create a predicate function based on the given profile.
55
55
  *
56
56
  * @public
57
57
  */
58
- export declare const makeProfilePredicate: <TargetType>(profile: Profile<TargetType>) => TypePredicate<TargetType>;
58
+ export declare const makeProfilePredicate: <TargetType>(profile: Profile<TargetType>) => types.TypePredicate<TargetType>;
59
59
  /**
60
60
  * Check if all of an object properties match a given type.
61
61
  *
62
62
  * @public
63
63
  */
64
- export declare const isKeyValueOfType: <ValueType>(obj: unknown, typePredicate: TypePredicate<ValueType>, options?: PredicateOptions) => obj is Record<string, ValueType>;
64
+ export declare const isKeyValueOfType: <ValueType>(obj: unknown, typePredicate: types.TypePredicate<ValueType>, options?: types.PredicateOptions) => obj is Record<string, ValueType>;
65
65
  /** @public */
66
- export declare const makeKeyValueOfTypePredicate: <ValueType>(typePredicate: TypePredicate<ValueType>) => TypePredicate<Record<string, ValueType>>;
66
+ export declare const makeKeyValueOfTypePredicate: <ValueType>(typePredicate: types.TypePredicate<ValueType>) => types.TypePredicate<Record<string, ValueType>>;
67
67
  export {};
@@ -15,7 +15,7 @@
15
15
  */
16
16
  import { asError } from "../error.js";
17
17
  import { PredicateError } from "./predicateerror.js";
18
- import { getPredicateOptions } from "./types.js";
18
+ import * as types from "./types.js";
19
19
  /**
20
20
  * Extract modifiers from primitive type name
21
21
  *
@@ -163,7 +163,7 @@ const checkArrayTypeDef = (valueType, rec, keyName, options) => {
163
163
  * @public
164
164
  */
165
165
  export const isObjectProfile = (obj, profile, options = false) => {
166
- const opt = getPredicateOptions(options);
166
+ const opt = types.getPredicateOptions(options);
167
167
  if (typeof obj !== "object" || obj === null) {
168
168
  PredicateError.predicateFailed(opt.raise, "root");
169
169
  return false;
@@ -190,7 +190,7 @@ export const makeProfilePredicate = profile => (obj, options = false) => isObjec
190
190
  * @public
191
191
  */
192
192
  export const isKeyValueOfType = (obj, typePredicate, options = false) => {
193
- const opt = getPredicateOptions(options);
193
+ const opt = types.getPredicateOptions(options);
194
194
  if (typeof obj !== "object") {
195
195
  PredicateError.predicateFailed(opt.raise, undefined);
196
196
  return false;
@@ -13,8 +13,9 @@
13
13
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
14
14
  *
15
15
  */
16
- import ms from "ms";
16
+ import * as types from "./types.js";
17
+ import type ms from "ms";
17
18
  /** Check that the argument match the string portion of `ms()` */
18
- export declare const isMsStringValue: import("./types.js").TypePredicate<ms.StringValue>;
19
+ export declare const isMsStringValue: types.TypePredicate<ms.StringValue>;
19
20
  /** Check that a value is suitable for input for `ms()` */
20
- export declare const isMsInput: import("./types.js").TypePredicate<number | ms.StringValue>;
21
+ export declare const isMsInput: types.TypePredicate<number | ms.StringValue>;
@@ -14,19 +14,19 @@
14
14
  *
15
15
  */
16
16
  import { isNumber } from "./primitive.js";
17
- import { makeOrPredicate, makeTemplatePredicate } from "./types.js";
17
+ import * as types from "./types.js";
18
18
  /** All `ms()` units, extracted from type definition */
19
19
  const msBaseUnits = ["Years", "Year", "Yrs", "Yr", "Y", "Weeks", "Week", "W", "Days", "Day", "D", "Hours", "Hour", "Hrs", "Hr", "H", "Minutes", "Minute", "Mins", "Min", "M", "Seconds", "Second", "Secs", "Sec", "s", "Milliseconds", "Millisecond", "Msecs", "Msec", "Ms"];
20
20
  /** All `ms()` units, including lowercase and uppercase */
21
21
  const msUnitAnyCase = Array.from(new Set([...msBaseUnits, ...msBaseUnits.map(c => c.toUpperCase()), ...msBaseUnits.map(c => c.toLowerCase())]));
22
- const isMsStrInput = makeTemplatePredicate("${number}");
23
- const isMsStrUnitPredicate = makeTemplatePredicate("${number}${msUnitAnyCase}", {
22
+ const isMsStrInput = types.makeTemplatePredicate("${number}");
23
+ const isMsStrUnitPredicate = types.makeTemplatePredicate("${number}${msUnitAnyCase}", {
24
24
  msUnitAnyCase
25
25
  });
26
- const isMsSpaceUnitPredicate = makeTemplatePredicate("${number} ${msUnitAnyCase}", {
26
+ const isMsSpaceUnitPredicate = types.makeTemplatePredicate("${number} ${msUnitAnyCase}", {
27
27
  msUnitAnyCase
28
28
  });
29
29
  /** Check that the argument match the string portion of `ms()` */
30
- export const isMsStringValue = makeOrPredicate([isMsStrInput, isMsStrUnitPredicate, isMsSpaceUnitPredicate]);
30
+ export const isMsStringValue = types.makeOrPredicate([isMsStrInput, isMsStrUnitPredicate, isMsSpaceUnitPredicate]);
31
31
  /** Check that a value is suitable for input for `ms()` */
32
- export const isMsInput = makeOrPredicate([isNumber, isMsStringValue]);
32
+ export const isMsInput = types.makeOrPredicate([isNumber, isMsStringValue]);