@oscarpalmer/atoms 0.198.0 → 0.200.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 (48) hide show
  1. package/dist/array/flatten.d.mts +1 -1
  2. package/dist/array/from.d.mts +1 -1
  3. package/dist/array/group-by.d.mts +2 -2
  4. package/dist/array/sort.d.mts +4 -0
  5. package/dist/array/to-map.d.mts +2 -2
  6. package/dist/array/to-record.d.mts +2 -2
  7. package/dist/beacon.mjs +46 -43
  8. package/dist/color/instance.mjs +14 -10
  9. package/dist/function/retry.mjs +6 -8
  10. package/dist/index.d.mts +153 -53
  11. package/dist/index.mjs +347 -259
  12. package/dist/internal/array/compact.d.mts +2 -2
  13. package/dist/internal/array/find.d.mts +2 -2
  14. package/dist/internal/array/find.mjs +11 -11
  15. package/dist/internal/function/memoize.mjs +4 -3
  16. package/dist/internal/function/timer.mjs +3 -5
  17. package/dist/internal/herald.mjs +26 -23
  18. package/dist/internal/subscription.d.mts +72 -16
  19. package/dist/internal/subscription.mjs +94 -29
  20. package/dist/internal/value/compare.mjs +2 -2
  21. package/dist/internal/value/equal.mjs +30 -30
  22. package/dist/internal/value/handlers.d.mts +3 -3
  23. package/dist/internal/value/handlers.mjs +6 -6
  24. package/dist/promise/constants.d.mts +3 -1
  25. package/dist/promise/constants.mjs +3 -1
  26. package/dist/promise/delay.mjs +2 -2
  27. package/dist/promise/helpers.d.mts +4 -5
  28. package/dist/promise/helpers.mjs +13 -5
  29. package/dist/promise/index.d.mts +34 -36
  30. package/dist/promise/index.mjs +28 -23
  31. package/dist/promise/misc.mjs +2 -2
  32. package/dist/promise/models.d.mts +7 -6
  33. package/dist/promise/timed.mjs +2 -2
  34. package/dist/queue.d.mts +4 -0
  35. package/dist/queue.mjs +3 -3
  36. package/dist/string/fuzzy.d.mts +2 -0
  37. package/dist/string/fuzzy.mjs +20 -18
  38. package/dist/string/normalize.mjs +12 -12
  39. package/dist/string/template.mjs +8 -8
  40. package/dist/subscription.d.mts +2 -2
  41. package/dist/subscription.mjs +2 -2
  42. package/dist/value/clone.mjs +13 -13
  43. package/dist/value/freeze.d.mts +2 -0
  44. package/dist/value/freeze.mjs +2 -0
  45. package/dist/value/merge.d.mts +1 -1
  46. package/dist/value/merge.mjs +7 -6
  47. package/package.json +4 -4
  48. package/plugin/index.js +1 -1
@@ -2,6 +2,16 @@ import { isPlainObject } from "../internal/is.mjs";
2
2
  import { memoize } from "../internal/function/memoize.mjs";
3
3
  import { lowerCase } from "../internal/string/case.mjs";
4
4
  //#region src/string/normalize.ts
5
+ function createNormalizeOptions(input) {
6
+ const options = isPlainObject(input) ? input : {};
7
+ return {
8
+ deburr: options.deburr !== false,
9
+ lowerCase: options.lowerCase !== false,
10
+ special: options.special === true,
11
+ trim: options.trim !== false,
12
+ whitespace: options.whitespace !== false
13
+ };
14
+ }
5
15
  /**
6
16
  * Deburr a string, removing diacritical marks
7
17
  *
@@ -17,16 +27,6 @@ function deburr(value) {
17
27
  });
18
28
  return deburrMemoizer.run(value);
19
29
  }
20
- function getNormalizeOptions(input) {
21
- const options = isPlainObject(input) ? input : {};
22
- return {
23
- deburr: options.deburr !== false,
24
- lowerCase: options.lowerCase !== false,
25
- special: options.special === true,
26
- trim: options.trim !== false,
27
- whitespace: options.whitespace !== false
28
- };
29
- }
30
30
  /**
31
31
  * Initialize a string normalizer
32
32
  *
@@ -36,7 +36,7 @@ function getNormalizeOptions(input) {
36
36
  * @returns Normalizer function
37
37
  */
38
38
  function initializeNormalizer(options) {
39
- const normalization = getNormalizeOptions(options);
39
+ const normalization = createNormalizeOptions(options);
40
40
  return (value) => normalizeString(value, normalization);
41
41
  }
42
42
  /**
@@ -49,7 +49,7 @@ function initializeNormalizer(options) {
49
49
  * @returns Normalized string
50
50
  */
51
51
  function normalize(value, options) {
52
- return normalizeString(value, getNormalizeOptions(options));
52
+ return normalizeString(value, createNormalizeOptions(options));
53
53
  }
54
54
  function normalizeString(value, options) {
55
55
  if (typeof value !== "string") return "";
@@ -2,18 +2,18 @@ import { isPlainObject, isTemplateStringsArray } from "../internal/is.mjs";
2
2
  import { getString, interpolate } from "../internal/string/misc.mjs";
3
3
  import { getValue } from "../internal/value/get.mjs";
4
4
  //#region src/string/template.ts
5
- function getRenderer(strings, values) {
6
- return (variables, options) => {
7
- return template(interpolate(strings, values), variables, options);
8
- };
9
- }
10
- function getTemplateOptions(input) {
5
+ function createTemplateOptions(input) {
11
6
  const options = isPlainObject(input) ? input : {};
12
7
  return {
13
8
  ignoreCase: options.ignoreCase === true,
14
9
  pattern: options.pattern instanceof RegExp ? options.pattern : TEMPLATE_EXPRESSION_VARIABLE
15
10
  };
16
11
  }
12
+ function getRenderer(strings, values) {
13
+ return (variables, options) => {
14
+ return template(interpolate(strings, values), variables, options);
15
+ };
16
+ }
17
17
  function handleTemplate(value, pattern, ignoreCase, variables) {
18
18
  if (typeof value !== "string") return "";
19
19
  if (typeof variables !== "object" || variables === null || Object.keys(variables).length === 0) return value;
@@ -35,14 +35,14 @@ function handleTemplate(value, pattern, ignoreCase, variables) {
35
35
  * @returns _Templater_ function
36
36
  */
37
37
  function initializeTemplater(options) {
38
- const { ignoreCase, pattern } = getTemplateOptions(options);
38
+ const { ignoreCase, pattern } = createTemplateOptions(options);
39
39
  return ((value, ...parameters) => {
40
40
  return isTemplateStringsArray(value) ? (variables) => handleTemplate(interpolate(value, parameters), pattern, ignoreCase, variables) : handleTemplate(value, pattern, ignoreCase, parameters[0]);
41
41
  });
42
42
  }
43
43
  function template(value, ...parameters) {
44
44
  if (isTemplateStringsArray(value)) return getRenderer(value, parameters);
45
- const { ignoreCase, pattern } = getTemplateOptions(parameters[1]);
45
+ const { ignoreCase, pattern } = createTemplateOptions(parameters[1]);
46
46
  return handleTemplate(value, pattern, ignoreCase, parameters[0]);
47
47
  }
48
48
  const TEMPLATE_EXPRESSION_VARIABLE = /{{([\s\S]+?)}}/g;
@@ -1,2 +1,2 @@
1
- import { Subscription, isSubscription } from "./internal/subscription.mjs";
2
- export { type Subscription, isSubscription };
1
+ import { Subscription, SubscriptionParameters, SubscriptionProperty, Subscriptions, SubscriptionsParameters, isSubscription, isSubscriptions, subscriptions } from "./internal/subscription.mjs";
2
+ export { type Subscription, type SubscriptionParameters, type SubscriptionProperty, type Subscriptions, type SubscriptionsParameters, isSubscription, isSubscriptions, subscriptions };
@@ -1,2 +1,2 @@
1
- import { isSubscription } from "./internal/subscription.mjs";
2
- export { isSubscription };
1
+ import { isSubscription, isSubscriptions, subscriptions } from "./internal/subscription.mjs";
2
+ export { isSubscription, isSubscriptions, subscriptions };
@@ -1,5 +1,5 @@
1
1
  import { isArrayOrPlainObject, isTypedArray } from "../internal/is.mjs";
2
- import { getSelfHandlers } from "../internal/value/handlers.mjs";
2
+ import { createSelfHandlers } from "../internal/value/handlers.mjs";
3
3
  //#region src/value/clone.ts
4
4
  const CLONE_NAME = "clone";
5
5
  function clone(value, options) {
@@ -10,13 +10,13 @@ function cloneAny(value, parameters, depth, options) {
10
10
  case value === null || CLONE_PRIMITIVES[typeof value]: return value;
11
11
  case value instanceof Date: return new Date(value.getTime());
12
12
  case typeof value === "function":
13
- parameters.options ??= getCloneOptions(options);
13
+ parameters.options ??= createCloneOptions(options);
14
14
  return parameters.options.copyFunctions ? value : void 0;
15
15
  case typeof value === "symbol":
16
- parameters.options ??= getCloneOptions(options);
16
+ parameters.options ??= createCloneOptions(options);
17
17
  return parameters.options.copySymbols ? value : Symbol(value.description);
18
18
  }
19
- parameters.options ??= getCloneOptions(options);
19
+ parameters.options ??= createCloneOptions(options);
20
20
  parameters.references ??= /* @__PURE__ */ new WeakMap();
21
21
  switch (true) {
22
22
  case parameters.references.has(value): return parameters.references.get(value);
@@ -101,6 +101,13 @@ function copy(value) {
101
101
  references: void 0
102
102
  }, 0);
103
103
  }
104
+ function createCloneOptions(input) {
105
+ if (typeof input !== "object" || input === null) return CLONE_DEFAULT_OPTIONS;
106
+ return {
107
+ copyFunctions: input.copyFunctions === true,
108
+ copySymbols: input.copySymbols === true
109
+ };
110
+ }
104
111
  /**
105
112
  * Deregister a clone handler for a specific class
106
113
  *
@@ -111,13 +118,6 @@ function copy(value) {
111
118
  function deregisterCloner(constructor) {
112
119
  clone.handlers.deregister(constructor);
113
120
  }
114
- function getCloneOptions(input) {
115
- if (typeof input !== "object" || input === null) return CLONE_DEFAULT_OPTIONS;
116
- return {
117
- copyFunctions: input.copyFunctions === true,
118
- copySymbols: input.copySymbols === true
119
- };
120
- }
121
121
  /**
122
122
  * Create a cloner with predefined options
123
123
  *
@@ -127,7 +127,7 @@ function getCloneOptions(input) {
127
127
  * @returns Cloner function
128
128
  */
129
129
  function initializeCloner(options) {
130
- const opts = getCloneOptions(options);
130
+ const opts = createCloneOptions(options);
131
131
  function cloner(value) {
132
132
  return cloneAny(value, {
133
133
  copy: false,
@@ -173,7 +173,7 @@ const CLONE_DEFAULT_OPTIONS = {
173
173
  copySymbols: false
174
174
  };
175
175
  const CLONE_MAX_DEPTH = 100;
176
- const cloneHandlers = getSelfHandlers(clone, {
176
+ const cloneHandlers = createSelfHandlers(clone, {
177
177
  callback: tryStructuredClone,
178
178
  method: CLONE_NAME
179
179
  });
@@ -135,6 +135,8 @@ declare namespace freeze {
135
135
  /**
136
136
  * Is the value frozen?
137
137
  *
138
+ * _Available as `isFrozen` and `freeze.is`_
139
+ *
138
140
  * @param value Value to check
139
141
  * @returns `true` if the value is frozen, otherwise `false`
140
142
  */
@@ -65,6 +65,8 @@ function freezeValue(value, references, flat) {
65
65
  }
66
66
  /**
67
67
  * Is the value frozen?
68
+ *
69
+ * _Available as `isFrozen` and `freeze.is`_
68
70
  *
69
71
  * @param value Value to check
70
72
  * @returns `true` if the value is frozen, otherwise `false`
@@ -60,7 +60,7 @@ type Merger = {
60
60
  * @param values Values to merge
61
61
  * @returns Merged value
62
62
  */
63
- <Values extends ArrayOrPlainObject[]>(values: NestedPartial<Values[number]>[]): UnionToIntersection<Values[number]>;
63
+ <Values extends ArrayOrPlainObject[]>(values: Array<NestedPartial<Values[number]>>): UnionToIntersection<Values[number]>;
64
64
  };
65
65
  /**
66
66
  * Assign values from one or more objects to the first one
@@ -9,11 +9,11 @@ import { isArrayOrPlainObject } from "../internal/is.mjs";
9
9
  * @returns Assigned value
10
10
  */
11
11
  function assign(to, from, options) {
12
- const actual = getMergeOptions(options);
12
+ const actual = createMergeOptions(options);
13
13
  actual.assignValues = true;
14
14
  return mergeValues([to, ...from], actual);
15
15
  }
16
- function getMergeOptions(options) {
16
+ function createMergeOptions(options) {
17
17
  const actual = {
18
18
  assignValues: false,
19
19
  replaceableObjects: void 0,
@@ -29,7 +29,8 @@ function getMergeOptions(options) {
29
29
  }
30
30
  function getReplaceableObjects(value) {
31
31
  const items = (Array.isArray(value) ? value : [value]).filter((item) => typeof item === "string" || item instanceof RegExp);
32
- if (items.length > 0) return (name) => items.some((item) => typeof item === "string" ? item === name : item.test(name));
32
+ if (items.length === 0) return;
33
+ return (name) => items.some((item) => typeof item === "string" ? item === name : item.test(name));
33
34
  }
34
35
  /**
35
36
  * Create an assigner with predefined options
@@ -40,7 +41,7 @@ function getReplaceableObjects(value) {
40
41
  * @returns Assigner function
41
42
  */
42
43
  function initializeAssigner(options) {
43
- const actual = getMergeOptions(options);
44
+ const actual = createMergeOptions(options);
44
45
  actual.assignValues = true;
45
46
  return ((to, from) => mergeValues([to, ...from], actual));
46
47
  }
@@ -53,7 +54,7 @@ function initializeAssigner(options) {
53
54
  * @returns Merger function
54
55
  */
55
56
  function initializeMerger(options) {
56
- const actual = getMergeOptions(options);
57
+ const actual = createMergeOptions(options);
57
58
  return ((values) => mergeValues(values, actual));
58
59
  }
59
60
  /**
@@ -64,7 +65,7 @@ function initializeMerger(options) {
64
65
  * @returns Merged value
65
66
  */
66
67
  function merge(values, options) {
67
- return mergeValues(values, getMergeOptions(options));
68
+ return mergeValues(values, createMergeOptions(options));
68
69
  }
69
70
  function mergeObjects(values, options, destination, prefix) {
70
71
  const { length } = values;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oscarpalmer/atoms",
3
- "version": "0.198.0",
3
+ "version": "0.200.0",
4
4
  "description": "Atomic utilities for making your JavaScript better.",
5
5
  "keywords": [
6
6
  "array",
@@ -278,10 +278,10 @@
278
278
  "watch": "npx vite build --watch"
279
279
  },
280
280
  "devDependencies": {
281
- "@oxlint/plugins": "^1.81",
282
- "@types/node": "^26.4",
281
+ "@oxlint/plugins": "^1.82",
282
+ "@types/node": "^26.5",
283
283
  "@vitest/coverage-istanbul": "^4.1",
284
- "eslint": "^10.9",
284
+ "eslint": "^10.10",
285
285
  "jsdom": "^30",
286
286
  "tsdown": "^0.23",
287
287
  "typescript": "^6",
package/plugin/index.js CHANGED
@@ -29,7 +29,7 @@ export const mathPlugins = [
29
29
  export const miscPlugins = [
30
30
  tryCatchPlugin,
31
31
  getPlugin('number', 'getNumber', new Set(['Number']), true, true),
32
- getPlugin('promise', 'promises', new Set(['all', 'allSettled']), true),
32
+ getPlugin('promise', 'promises', new Set(['all', 'allKeyed', 'allSettled']), true),
33
33
  getPlugin('value', 'assign', new Set(['assign']), true),
34
34
  getPlugin('value', 'clone', new Set(['structuredClone']), true, true),
35
35
  getPlugin('value', 'equal', new Set(['is']), true),