@oscarpalmer/atoms 0.158.0 → 0.160.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 (120) hide show
  1. package/dist/array/difference.js +2 -0
  2. package/dist/array/exists.js +2 -0
  3. package/dist/array/filter.js +2 -0
  4. package/dist/array/find.js +2 -0
  5. package/dist/array/flatten.js +2 -0
  6. package/dist/array/from.js +2 -0
  7. package/dist/array/get.js +2 -0
  8. package/dist/array/group-by.js +2 -0
  9. package/dist/array/index-of.js +2 -0
  10. package/dist/array/index.js +2 -1
  11. package/dist/array/insert.js +2 -0
  12. package/dist/array/intersection.js +2 -0
  13. package/dist/array/partition.js +2 -0
  14. package/dist/array/position.js +58 -0
  15. package/dist/array/push.js +2 -0
  16. package/dist/array/select.js +2 -0
  17. package/dist/array/slice.js +2 -0
  18. package/dist/array/sort.js +2 -0
  19. package/dist/array/splice.js +2 -0
  20. package/dist/array/to-map.js +2 -0
  21. package/dist/array/to-record.js +2 -0
  22. package/dist/array/to-set.js +2 -0
  23. package/dist/array/toggle.js +2 -0
  24. package/dist/array/union.js +2 -0
  25. package/dist/array/unique.js +2 -0
  26. package/dist/array/update.js +2 -0
  27. package/dist/atoms.full.js +223 -162
  28. package/dist/beacon.js +2 -0
  29. package/dist/color/constants.js +35 -33
  30. package/dist/color/index.js +2 -0
  31. package/dist/color/instance.js +2 -0
  32. package/dist/color/misc/alpha.js +2 -0
  33. package/dist/color/misc/get.js +2 -0
  34. package/dist/color/misc/index.js +2 -0
  35. package/dist/color/misc/is.js +2 -0
  36. package/dist/color/misc/state.js +2 -0
  37. package/dist/color/space/hex.js +2 -0
  38. package/dist/color/space/hsl.js +2 -0
  39. package/dist/color/space/rgb.js +2 -0
  40. package/dist/function/assert.js +2 -0
  41. package/dist/function/index.js +2 -0
  42. package/dist/function/memoize.js +2 -0
  43. package/dist/function/once.js +2 -0
  44. package/dist/function/retry.js +2 -0
  45. package/dist/function/work.js +2 -0
  46. package/dist/index.js +5 -4
  47. package/dist/internal/array/callbacks.js +2 -0
  48. package/dist/internal/array/chunk.js +2 -0
  49. package/dist/internal/array/compact.js +2 -0
  50. package/dist/internal/array/find.js +6 -4
  51. package/dist/internal/array/group.js +2 -0
  52. package/dist/internal/array/insert.js +2 -0
  53. package/dist/internal/array/sets.js +8 -6
  54. package/dist/internal/array/shuffle.js +3 -1
  55. package/dist/internal/array/update.js +2 -0
  56. package/dist/internal/function/misc.js +2 -0
  57. package/dist/internal/function/timer.js +5 -3
  58. package/dist/internal/is.js +2 -0
  59. package/dist/internal/math/aggregate.js +2 -0
  60. package/dist/internal/number.js +2 -0
  61. package/dist/internal/random.js +2 -0
  62. package/dist/internal/result.js +2 -0
  63. package/dist/internal/sized.js +2 -0
  64. package/dist/internal/string.js +2 -0
  65. package/dist/internal/value/compare.js +2 -0
  66. package/dist/internal/value/equal.js +2 -0
  67. package/dist/internal/value/get.js +2 -0
  68. package/dist/internal/value/handlers.js +2 -0
  69. package/dist/internal/value/has.js +2 -0
  70. package/dist/internal/value/misc.js +2 -0
  71. package/dist/internal/value/partial.js +2 -0
  72. package/dist/internal/value/set.js +2 -0
  73. package/dist/is.js +2 -0
  74. package/dist/logger.js +2 -0
  75. package/dist/math.js +2 -0
  76. package/dist/promise/delay.js +3 -1
  77. package/dist/promise/helpers.js +8 -1
  78. package/dist/promise/index.js +9 -3
  79. package/dist/promise/misc.js +3 -1
  80. package/dist/promise/models.js +14 -12
  81. package/dist/promise/timed.js +3 -1
  82. package/dist/query.js +2 -0
  83. package/dist/queue.js +2 -0
  84. package/dist/random.js +2 -0
  85. package/dist/result/index.js +5 -3
  86. package/dist/result/match.js +2 -0
  87. package/dist/result/misc.js +2 -0
  88. package/dist/result/work/flow.js +2 -0
  89. package/dist/result/work/pipe.js +2 -0
  90. package/dist/sized/map.js +2 -0
  91. package/dist/sized/set.js +2 -0
  92. package/dist/string/case.js +2 -0
  93. package/dist/string/index.js +2 -0
  94. package/dist/string/match.js +2 -0
  95. package/dist/string/template.js +2 -0
  96. package/dist/value/clone.js +3 -1
  97. package/dist/value/diff.js +2 -0
  98. package/dist/value/merge.js +2 -0
  99. package/dist/value/omit.js +2 -0
  100. package/dist/value/pick.js +2 -0
  101. package/dist/value/smush.js +3 -1
  102. package/dist/value/unsmush.js +3 -1
  103. package/package.json +3 -3
  104. package/src/array/index.ts +1 -0
  105. package/src/array/position.ts +303 -0
  106. package/src/internal/array/sets.ts +3 -3
  107. package/src/internal/array/shuffle.ts +1 -1
  108. package/src/promise/helpers.ts +13 -3
  109. package/src/promise/index.ts +89 -19
  110. package/src/promise/misc.ts +1 -4
  111. package/src/promise/models.ts +18 -12
  112. package/src/value/clone.ts +1 -1
  113. package/src/value/smush.ts +1 -1
  114. package/src/value/unsmush.ts +1 -1
  115. package/types/array/index.d.ts +1 -0
  116. package/types/array/position.d.ts +117 -0
  117. package/types/promise/helpers.d.ts +3 -1
  118. package/types/promise/index.d.ts +52 -5
  119. package/types/promise/misc.d.ts +1 -1
  120. package/types/promise/models.d.ts +15 -11
@@ -5,6 +5,7 @@ import { getDegrees, getHexValue, getPercentage } from "./get.js";
5
5
  import { getRgbValue, rgbToHex, rgbToHsl } from "../space/rgb.js";
6
6
  import { getNormalizedHex, hexToRgb } from "../space/hex.js";
7
7
  import { getHslValue, hslToRgb } from "../space/hsl.js";
8
+ //#region src/color/misc/state.ts
8
9
  function getState(value) {
9
10
  if (typeof value === "string") {
10
11
  const normalized = getNormalizedHex(value, true);
@@ -80,4 +81,5 @@ function setRGBColor(state, value, alpha) {
80
81
  state.rgb = rgb;
81
82
  if (alpha) state.alpha = getAlpha(value.alpha);
82
83
  }
84
+ //#endregion
83
85
  export { getState, setHSLColor, setHexColor, setRGBColor };
@@ -2,6 +2,7 @@ import { join } from "../../internal/string.js";
2
2
  import { ALPHA_FULL_HEX_LONG, EXPRESSION_HEX_LONG, EXPRESSION_PREFIX, HEX_BLACK } from "../constants.js";
3
3
  import { isHexColor } from "../misc/is.js";
4
4
  import { convertRgbToHsla } from "./rgb.js";
5
+ //#region src/color/space/hex.ts
5
6
  function convertHexToRgba(value) {
6
7
  const normalized = getNormalizedHex(value, true);
7
8
  const pairs = EXPRESSION_HEX_LONG.exec(normalized);
@@ -60,4 +61,5 @@ function hexToRgb(value) {
60
61
  function hexToRgba(value) {
61
62
  return convertHexToRgba(value);
62
63
  }
64
+ //#endregion
63
65
  export { getNormalizedHex, hexToHsl, hexToHsla, hexToRgb, hexToRgba };
@@ -3,6 +3,7 @@ import { getAlphaValue } from "../misc/alpha.js";
3
3
  import { isHslLike } from "../misc/is.js";
4
4
  import { getDegrees, getHexValue, getPercentage } from "../misc/get.js";
5
5
  import { convertRgbToHex } from "./rgb.js";
6
+ //#region src/color/space/hsl.ts
6
7
  function convertHslToRgba(value) {
7
8
  const hsl = isHslLike(value) ? getHslValue(value) : { ...DEFAULT_HSL };
8
9
  const hue = hsl.hue % 360;
@@ -54,4 +55,5 @@ function hslToRgb(hsl) {
54
55
  function hslToRgba(hsl) {
55
56
  return convertHslToRgba(hsl);
56
57
  }
58
+ //#endregion
57
59
  export { getHslValue, hslToHex, hslToRgb, hslToRgba };
@@ -3,6 +3,7 @@ import { DEFAULT_RGB } from "../constants.js";
3
3
  import { getAlpha, getAlphaValue } from "../misc/alpha.js";
4
4
  import { isRgbLike } from "../misc/is.js";
5
5
  import { getHexValue } from "../misc/get.js";
6
+ //#region src/color/space/rgb.ts
6
7
  function convertRgbToHex(rgb, alpha) {
7
8
  const hex = `${join([
8
9
  rgb.red,
@@ -90,4 +91,5 @@ function rgbToHsl(rgb) {
90
91
  function rgbToHsla(rgb) {
91
92
  return convertRgbToHsla(rgb);
92
93
  }
94
+ //#endregion
93
95
  export { convertRgbToHex, convertRgbToHsla, getRgbValue, rgbToHex, rgbToHsl, rgbToHsla };
@@ -1,3 +1,4 @@
1
+ //#region src/function/assert.ts
1
2
  /**
2
3
  * Asserts that a condition is true, throwing an error if it is not
3
4
  * @param condition Condition to assert
@@ -56,4 +57,5 @@ function assertIs(condition, message, error) {
56
57
  };
57
58
  }
58
59
  var MESSAGE_VALUE_DEFINED = "Expected value to be defined";
60
+ //#endregion
59
61
  export { assert };
@@ -2,6 +2,7 @@ import { noop } from "../internal/function/misc.js";
2
2
  import { TIMER_DEBOUNCE, TIMER_THROTTLE, getTimer } from "../internal/function/timer.js";
3
3
  import { memoize } from "./memoize.js";
4
4
  import { once } from "./once.js";
5
+ //#region src/function/index.ts
5
6
  /**
6
7
  * Debounce a function, ensuring it is only called after `time` milliseconds have passed
7
8
  *
@@ -22,4 +23,5 @@ function debounce(callback, time) {
22
23
  function throttle(callback, time) {
23
24
  return getTimer(TIMER_THROTTLE, callback, time);
24
25
  }
26
+ //#endregion
25
27
  export { debounce, memoize, noop, once, throttle };
@@ -1,6 +1,7 @@
1
1
  import { isPlainObject } from "../internal/is.js";
2
2
  import { getString, join } from "../internal/string.js";
3
3
  import { SizedMap } from "../sized/map.js";
4
+ //#region src/function/memoize.ts
4
5
  var Memoized = class {
5
6
  #state;
6
7
  /**
@@ -94,4 +95,5 @@ function memoize(callback, options) {
94
95
  return new Memoized(callback, getMemoizationOptions(options));
95
96
  }
96
97
  var DEFAULT_CACHE_SIZE = 1024;
98
+ //#endregion
97
99
  export { memoize };
@@ -1,4 +1,5 @@
1
1
  import { assert } from "./assert.js";
2
+ //#region src/function/once.ts
2
3
  /**
3
4
  * Create an asynchronous function that can only be called once, rejecting or resolving the same result on subsequent calls
4
5
  * @param callback Callback to use once
@@ -94,4 +95,5 @@ function once(callback) {
94
95
  once.async = asyncOnce;
95
96
  var MESSAGE_CLEARED = "Once has been cleared";
96
97
  var MESSAGE_EXPECTATION = "Once expected a function";
98
+ //#endregion
97
99
  export { once };
@@ -1,5 +1,6 @@
1
1
  import { isPlainObject } from "../internal/is.js";
2
2
  import { TIMER_WAIT, getTimer } from "../internal/function/timer.js";
3
+ //#region src/function/retry.ts
3
4
  var RetryError = class extends Error {
4
5
  constructor(message, original) {
5
6
  super(message);
@@ -76,4 +77,5 @@ function shouldRetry() {
76
77
  var ERROR_NAME = "RetryError";
77
78
  var MESSAGE_EXPECTATION = "Retry expected a function";
78
79
  var MESSAGE_FAILED = "Retry failed";
80
+ //#endregion
79
81
  export { RetryError, retry };
@@ -1,5 +1,6 @@
1
1
  import { assert } from "./assert.js";
2
2
  import { isError, isOk } from "../internal/result.js";
3
+ //#region src/function/work.ts
3
4
  function asyncFlow(...fns) {
4
5
  assertFlowFunctions(fns);
5
6
  return (...args) => asyncWork(args.map((value) => {
@@ -58,4 +59,5 @@ var MESSAGE_PIPE_ARRAY = "Pipe expected to receive an array of functions";
58
59
  var MESSAGE_PIPE_PROMISE = "Synchronous Pipe received a promise. Use `pipe.async` instead.";
59
60
  var assertFlowFunctions = assert.condition((value) => Array.isArray(value) && value.every((item) => typeof item === "function"), MESSAGE_FLOW_ARRAY, TypeError);
60
61
  var assertPipeFunctions = assert.condition((value) => Array.isArray(value) && value.every((item) => typeof item === "function"), MESSAGE_PIPE_ARRAY, TypeError);
62
+ //#endregion
61
63
  export { flow, pipe };
package/dist/index.js CHANGED
@@ -15,6 +15,7 @@ import { shuffle } from "./internal/array/shuffle.js";
15
15
  import { insert } from "./array/insert.js";
16
16
  import { intersection } from "./array/intersection.js";
17
17
  import { partition } from "./array/partition.js";
18
+ import { endsWithArray, getArrayPosition, includesArray, indexOfArray, startsWithArray } from "./array/position.js";
18
19
  import { push } from "./array/push.js";
19
20
  import { select } from "./array/select.js";
20
21
  import { drop, slice, take } from "./array/slice.js";
@@ -65,16 +66,16 @@ import { merge } from "./value/merge.js";
65
66
  import { isEmpty, isNonNullable, isNullable, isNullableOrEmpty, isNullableOrWhitespace, isNumerical, isObject, isPrimitive } from "./is.js";
66
67
  import { logger } from "./logger.js";
67
68
  import { average, ceil, count, floor, median, min, round, sum } from "./math.js";
68
- import { CancelablePromise, PromiseTimeoutError } from "./promise/models.js";
69
- import { isFulfilled, isRejected } from "./promise/helpers.js";
70
69
  import { error, ok, toPromise, unwrap } from "./result/misc.js";
70
+ import { CancelablePromise, PromiseTimeoutError } from "./promise/models.js";
71
71
  import { cancelable, toResult } from "./promise/misc.js";
72
+ import { attempt } from "./result/index.js";
73
+ import { isFulfilled, isRejected } from "./promise/helpers.js";
72
74
  import { timed } from "./promise/timed.js";
73
75
  import { delay } from "./promise/delay.js";
74
76
  import { attemptPromise, promises } from "./promise/index.js";
75
77
  import { fromQuery, toQuery } from "./query.js";
76
78
  import { QueueError, queue } from "./queue.js";
77
79
  import { getRandomBoolean, getRandomCharacters, getRandomColor, getRandomHex, getRandomItem, getRandomItems } from "./random.js";
78
- import { attempt } from "./result/index.js";
79
80
  import { SizedSet } from "./sized/set.js";
80
- export { CancelablePromise, PromiseTimeoutError, QueueError, RetryError, SizedMap, SizedSet, attempt, attemptPromise, average, beacon, between, camelCase, cancelable, capitalize, ceil, chunk, clamp, clone, compact, compare, count, debounce, delay, diff, difference, drop, endsWith, equal, error, exists, filter, find, flatten, floor, flow, toResult as fromPromise, fromQuery, toPromise as fromResult, getArray, getColor, getForegroundColor, getHexColor, getHexaColor, getHslColor, getHslaColor, getNormalizedHex, getNumber, getRandomBoolean, getRandomCharacters, getRandomColor, getRandomFloat, getRandomHex, getRandomInteger, getRandomItem, getRandomItems, getRgbColor, getRgbaColor, getString, getUuid, getValue, groupBy, hasValue, hexToHsl, hexToHsla, hexToRgb, hexToRgba, hslToHex, hslToRgb, hslToRgba, ignoreKey, includes, indexOf, insert, intersection, isArrayOrPlainObject, isColor, isConstructor, isEmpty, isError, isFulfilled, isHexColor, isHslColor, isHslLike, isHslaColor, isInstanceOf, isKey, isNonNullable, isNullable, isNullableOrEmpty, isNullableOrWhitespace, isNumber, isNumerical, isObject, isOk, isPlainObject, isPrimitive, isRejected, isResult, isRgbColor, isRgbLike, isRgbaColor, isTypedArray, join, kebabCase, logger, lowerCase, max, median, memoize, merge, min, noop, ok, omit, once, parse, partition, pascalCase, pick, pipe, promises, push, queue, range, retry, rgbToHex, rgbToHsl, rgbToHsla, round, select, setValue, shuffle, slice, smush, snakeCase, sort, splice, startsWith, sum, take, template, throttle, timed, times, titleCase, toMap, toPromise, toQuery, toRecord, toResult, toSet, toggle, trim, truncate, tryDecode, tryEncode, union, unique, unsmush, unwrap, update, upperCase, words };
81
+ export { CancelablePromise, PromiseTimeoutError, QueueError, RetryError, SizedMap, SizedSet, attempt, attemptPromise, average, beacon, between, camelCase, cancelable, capitalize, ceil, chunk, clamp, clone, compact, compare, count, debounce, delay, diff, difference, drop, endsWith, endsWithArray, equal, error, exists, filter, find, flatten, floor, flow, toResult as fromPromise, fromQuery, toPromise as fromResult, getArray, getArrayPosition, getColor, getForegroundColor, getHexColor, getHexaColor, getHslColor, getHslaColor, getNormalizedHex, getNumber, getRandomBoolean, getRandomCharacters, getRandomColor, getRandomFloat, getRandomHex, getRandomInteger, getRandomItem, getRandomItems, getRgbColor, getRgbaColor, getString, getUuid, getValue, groupBy, hasValue, hexToHsl, hexToHsla, hexToRgb, hexToRgba, hslToHex, hslToRgb, hslToRgba, ignoreKey, includes, includesArray, indexOf, indexOfArray, insert, intersection, isArrayOrPlainObject, isColor, isConstructor, isEmpty, isError, isFulfilled, isHexColor, isHslColor, isHslLike, isHslaColor, isInstanceOf, isKey, isNonNullable, isNullable, isNullableOrEmpty, isNullableOrWhitespace, isNumber, isNumerical, isObject, isOk, isPlainObject, isPrimitive, isRejected, isResult, isRgbColor, isRgbLike, isRgbaColor, isTypedArray, join, kebabCase, logger, lowerCase, max, median, memoize, merge, min, noop, ok, omit, once, parse, partition, pascalCase, pick, pipe, promises, push, queue, range, retry, rgbToHex, rgbToHsl, rgbToHsla, round, select, setValue, shuffle, slice, smush, snakeCase, sort, splice, startsWith, startsWithArray, sum, take, template, throttle, timed, times, titleCase, toMap, toPromise, toQuery, toRecord, toResult, toSet, toggle, trim, truncate, tryDecode, tryEncode, union, unique, unsmush, unwrap, update, upperCase, words };
@@ -1,3 +1,4 @@
1
+ //#region src/internal/array/callbacks.ts
1
2
  function getArrayCallback(value) {
2
3
  switch (typeof value) {
3
4
  case "function": return value;
@@ -13,4 +14,5 @@ function getArrayCallbacks(bool, key, value) {
13
14
  value: getArrayCallback(value)
14
15
  };
15
16
  }
17
+ //#endregion
16
18
  export { getArrayCallback, getArrayCallbacks };
@@ -1,3 +1,4 @@
1
+ //#region src/internal/array/chunk.ts
1
2
  /**
2
3
  * Chunk an array into smaller arrays
3
4
  * @param array Array to chunk
@@ -19,4 +20,5 @@ function chunk(array, size) {
19
20
  return chunks;
20
21
  }
21
22
  var MAX_SIZE = 5e3;
23
+ //#endregion
22
24
  export { chunk };
@@ -1,3 +1,4 @@
1
+ //#region src/internal/array/compact.ts
1
2
  function compact(array, strict) {
2
3
  if (!Array.isArray(array)) return [];
3
4
  if (strict === true) return array.filter(Boolean);
@@ -9,4 +10,5 @@ function compact(array, strict) {
9
10
  }
10
11
  return compacted;
11
12
  }
13
+ //#endregion
12
14
  export { compact };
@@ -1,4 +1,5 @@
1
1
  import { getArrayCallbacks } from "./callbacks.js";
2
+ //#region src/internal/array/find.ts
2
3
  function findValue(type, array, parameters) {
3
4
  const findIndex = type === "index";
4
5
  if (!Array.isArray(array) || array.length === 0) return findIndex ? -1 : void 0;
@@ -61,9 +62,10 @@ function getParameters(original) {
61
62
  value: length === 1 && typeof original[0] !== "function" ? original[0] : original[1]
62
63
  };
63
64
  }
64
- const FIND_VALUE_INDEX = "index";
65
- const FIND_VALUE_VALUE = "value";
66
- const FIND_VALUES_ALL = "all";
67
- const FIND_VALUES_UNIQUE = "unique";
65
+ var FIND_VALUE_INDEX = "index";
66
+ var FIND_VALUE_VALUE = "value";
67
+ var FIND_VALUES_ALL = "all";
68
+ var FIND_VALUES_UNIQUE = "unique";
68
69
  var UNIQUE_THRESHOLD = 100;
70
+ //#endregion
69
71
  export { FIND_VALUES_ALL, FIND_VALUES_UNIQUE, FIND_VALUE_INDEX, FIND_VALUE_VALUE, findValue, findValues };
@@ -1,4 +1,5 @@
1
1
  import { getArrayCallbacks } from "./callbacks.js";
2
+ //#region src/internal/array/group.ts
2
3
  function groupValues(array, key, value, arrays) {
3
4
  if (!Array.isArray(array) || array.length === 0) return {};
4
5
  const { length } = array;
@@ -16,4 +17,5 @@ function groupValues(array, key, value, arrays) {
16
17
  }
17
18
  return record;
18
19
  }
20
+ //#endregion
19
21
  export { groupValues };
@@ -1,4 +1,5 @@
1
1
  import { chunk } from "./chunk.js";
2
+ //#region src/internal/array/insert.ts
2
3
  function insertChunkedValues(type, array, items, start, deleteCount) {
3
4
  const actualDeleteCount = deleteCount < 0 ? 0 : deleteCount;
4
5
  const actualStart = Math.min(Math.max(0, start), array.length);
@@ -20,4 +21,5 @@ function insertValues(type, array, items, start, deleteCount) {
20
21
  if (!Array.isArray(array) || typeof start !== "number" || !Array.isArray(items) || items.length === 0) return spliceArray ? [] : 0;
21
22
  return insertChunkedValues(type, array, items, start, spliceArray ? deleteCount : 0);
22
23
  }
24
+ //#endregion
23
25
  export { insertValues };
@@ -1,11 +1,12 @@
1
1
  import { getArrayCallback } from "./callbacks.js";
2
+ //#region src/internal/array/sets.ts
2
3
  function compareSets(type, first, second, key) {
3
4
  if (!Array.isArray(first)) return [];
4
5
  const isDifference = type === COMPARE_SETS_DIFFERENCE;
5
6
  const isIntersection = type === COMPARE_SETS_INTERSECTION;
6
7
  const isUnion = type === COMPARE_SETS_UNION;
7
- if (first.length === 0) return isDifference ? [...first] : isIntersection ? [] : [...second];
8
- if (!Array.isArray(second) || second.length === 0) return isIntersection ? [] : [...first];
8
+ if (first.length === 0) return isDifference ? first.slice() : isIntersection ? [] : second.slice();
9
+ if (!Array.isArray(second) || second.length === 0) return isIntersection ? [] : first.slice();
9
10
  const callback = getArrayCallback(key);
10
11
  const values = isUnion ? first : second;
11
12
  let { length } = values;
@@ -16,7 +17,7 @@ function compareSets(type, first, second, key) {
16
17
  }
17
18
  const source = isUnion ? second : first;
18
19
  length = source.length;
19
- const result = isUnion ? [...first] : [];
20
+ const result = isUnion ? first.slice() : [];
20
21
  for (let index = 0; index < length; index += 1) {
21
22
  const item = source[index];
22
23
  const value = callback?.(item, index, source) ?? item;
@@ -24,7 +25,8 @@ function compareSets(type, first, second, key) {
24
25
  }
25
26
  return result;
26
27
  }
27
- const COMPARE_SETS_DIFFERENCE = "difference";
28
- const COMPARE_SETS_INTERSECTION = "intersection";
29
- const COMPARE_SETS_UNION = "union";
28
+ var COMPARE_SETS_DIFFERENCE = "difference";
29
+ var COMPARE_SETS_INTERSECTION = "intersection";
30
+ var COMPARE_SETS_UNION = "union";
31
+ //#endregion
30
32
  export { COMPARE_SETS_DIFFERENCE, COMPARE_SETS_INTERSECTION, COMPARE_SETS_UNION, compareSets };
@@ -1,4 +1,5 @@
1
1
  import { getRandomInteger } from "../random.js";
2
+ //#region src/internal/array/shuffle.ts
2
3
  /**
3
4
  * Shuffle items in array
4
5
  * @param array Original array
@@ -6,7 +7,7 @@ import { getRandomInteger } from "../random.js";
6
7
  */
7
8
  function shuffle(array) {
8
9
  if (!Array.isArray(array)) return [];
9
- const shuffled = [...array];
10
+ const shuffled = array.slice();
10
11
  if (shuffled.length < 2) return shuffled;
11
12
  let index = Number(shuffled.length);
12
13
  while (--index >= 0) {
@@ -15,4 +16,5 @@ function shuffle(array) {
15
16
  }
16
17
  return shuffled;
17
18
  }
19
+ //#endregion
18
20
  export { shuffle };
@@ -1,4 +1,5 @@
1
1
  import { getArrayCallback } from "./callbacks.js";
2
+ //#region src/internal/array/update.ts
2
3
  function updateInArray(array, items, key, replace) {
3
4
  if (!Array.isArray(array)) return [];
4
5
  const itemsIsArray = Array.isArray(items);
@@ -19,4 +20,5 @@ function updateInArray(array, items, key, replace) {
19
20
  }
20
21
  return array;
21
22
  }
23
+ //#endregion
22
24
  export { updateInArray };
@@ -1,5 +1,7 @@
1
+ //#region src/internal/function/misc.ts
1
2
  /**
2
3
  * A function that does nothing, which can be useful, I guess…
3
4
  */
4
5
  function noop() {}
6
+ //#endregion
5
7
  export { noop };
@@ -1,3 +1,4 @@
1
+ //#region src/internal/function/timer.ts
1
2
  function getInterval(value) {
2
3
  return typeof value === "number" && value > 0 ? value : 0;
3
4
  }
@@ -25,7 +26,8 @@ function getTimer(type, callback, time) {
25
26
  return timer;
26
27
  }
27
28
  var OFFSET = 5;
28
- const TIMER_DEBOUNCE = "debounce";
29
- const TIMER_THROTTLE = "throttle";
30
- const TIMER_WAIT = "wait";
29
+ var TIMER_DEBOUNCE = "debounce";
30
+ var TIMER_THROTTLE = "throttle";
31
+ var TIMER_WAIT = "wait";
32
+ //#endregion
31
33
  export { TIMER_DEBOUNCE, TIMER_THROTTLE, TIMER_WAIT, getTimer };
@@ -1,3 +1,4 @@
1
+ //#region src/internal/is.ts
1
2
  /**
2
3
  * Is the value an array or a record?
3
4
  * @param value Value to check
@@ -72,4 +73,5 @@ function isTypedArray(value) {
72
73
  return TYPED_ARRAYS.has(value?.constructor);
73
74
  }
74
75
  var TYPED_ARRAYS;
76
+ //#endregion
75
77
  export { isArrayOrPlainObject, isConstructor, isInstanceOf, isKey, isNumber, isPlainObject, isTypedArray };
@@ -1,4 +1,5 @@
1
1
  import { isNumber } from "../is.js";
2
+ //#region src/internal/math/aggregate.ts
2
3
  function aggregate(type, array, key) {
3
4
  const length = Array.isArray(array) ? array.length : 0;
4
5
  if (length === 0) return {
@@ -43,4 +44,5 @@ var aggregators = {
43
44
  min: (current, value, notNumber) => notNumber || value < current ? value : current,
44
45
  sum: calculateSum
45
46
  };
47
+ //#endregion
46
48
  export { aggregate, getAggregateCallback, getAggregated, max };
@@ -1,4 +1,5 @@
1
1
  import { isNumber } from "./is.js";
2
+ //#region src/internal/number.ts
2
3
  /**
3
4
  * Is the number between a minimum and maximum value?
4
5
  * @param value Value to check
@@ -58,4 +59,5 @@ var EXPRESSION_OCTAL = /^0o[0-7]+$/i;
58
59
  var EXPRESSION_UNDERSCORE = /_/g;
59
60
  var EXPRESSION_ZEROISH = /^\s*0+\s*$/;
60
61
  var OCTAL_VALUE = 8;
62
+ //#endregion
61
63
  export { between, clamp, getNumber };
@@ -1,4 +1,5 @@
1
1
  import { isNumber } from "./is.js";
2
+ //#region src/internal/random.ts
2
3
  function _getRandomFloat(inclusive, minimum, maximum) {
3
4
  let maxFloat = isNumber(maximum) && maximum <= Number.MAX_SAFE_INTEGER ? maximum : Number.MAX_SAFE_INTEGER;
4
5
  let minFloat = isNumber(minimum) && minimum >= Number.MIN_SAFE_INTEGER ? minimum : Number.MIN_SAFE_INTEGER;
@@ -24,4 +25,5 @@ function getRandomFloat(minimum, maximum) {
24
25
  function getRandomInteger(minimum, maximum) {
25
26
  return Math.floor(_getRandomFloat(true, minimum, maximum));
26
27
  }
28
+ //#endregion
27
29
  export { getRandomFloat, getRandomInteger };
@@ -1,4 +1,5 @@
1
1
  import { isPlainObject } from "./is.js";
2
+ //#region src/internal/result.ts
2
3
  function _isResult(value, okValue) {
3
4
  if (!isPlainObject(value)) return false;
4
5
  return value.ok === okValue && (okValue ? "value" : "error") in value;
@@ -22,4 +23,5 @@ function isOk(value) {
22
23
  function isResult(value) {
23
24
  return _isResult(value, true) || _isResult(value, false);
24
25
  }
26
+ //#endregion
25
27
  export { isError, isOk, isResult };
@@ -1,4 +1,5 @@
1
1
  import { clamp } from "./number.js";
2
+ //#region src/internal/sized.ts
2
3
  function getSizedMaximum(first, second) {
3
4
  let actual;
4
5
  if (typeof first === "number") actual = first;
@@ -7,4 +8,5 @@ function getSizedMaximum(first, second) {
7
8
  }
8
9
  var MAXIMUM_ABSOLUTE = 16777216;
9
10
  var MAXIMUM_DEFAULT = 1048576;
11
+ //#endregion
10
12
  export { getSizedMaximum };
@@ -1,4 +1,5 @@
1
1
  import { compact } from "./array/compact.js";
2
+ //#region src/internal/string.ts
2
3
  /**
3
4
  * Get the string value from any value
4
5
  * @param value Original value
@@ -47,4 +48,5 @@ function words(value) {
47
48
  }
48
49
  var EXPRESSION_IGNORED = /(^|\.)(__proto__|constructor|prototype)(\.|$)/i;
49
50
  var EXPRESSION_WORDS = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
51
+ //#endregion
50
52
  export { getString, ignoreKey, join, tryDecode, tryEncode, words };
@@ -1,6 +1,7 @@
1
1
  import { max } from "../math/aggregate.js";
2
2
  import { getString, words } from "../string.js";
3
3
  import { getCompareHandlers } from "./handlers.js";
4
+ //#region src/internal/value/compare.ts
4
5
  /**
5
6
  * Compare two values _(for sorting purposes)_
6
7
  * @param first First value
@@ -77,4 +78,5 @@ var comparators = {
77
78
  number: compareNumbers,
78
79
  symbol: compareSymbols
79
80
  };
81
+ //#endregion
80
82
  export { compare };
@@ -1,6 +1,7 @@
1
1
  import { isPlainObject, isTypedArray } from "../is.js";
2
2
  import { chunk } from "../array/chunk.js";
3
3
  import { getCompareHandlers } from "./handlers.js";
4
+ //#region src/internal/value/equal.ts
4
5
  function equal(first, second, options) {
5
6
  return equalValue(first, second, getEqualOptions(options));
6
7
  }
@@ -168,4 +169,5 @@ function getEqualOptions(input) {
168
169
  }
169
170
  var ARRAY_PEEK_PERCENTAGE = 10;
170
171
  var ARRAY_THRESHOLD = 100;
172
+ //#endregion
171
173
  export { equal };
@@ -1,5 +1,7 @@
1
1
  import { getNestedValue } from "./misc.js";
2
+ //#region src/internal/value/get.ts
2
3
  function getValue(data, path, ignoreCase) {
3
4
  return getNestedValue(data, path, ignoreCase === true).value;
4
5
  }
6
+ //#endregion
5
7
  export { getValue };
@@ -1,4 +1,5 @@
1
1
  import { isConstructor } from "../is.js";
2
+ //#region src/internal/value/handlers.ts
2
3
  function getCompareHandlers(owner, options) {
3
4
  const { get, register, unregister } = getHandlers(owner, options);
4
5
  return {
@@ -44,4 +45,5 @@ function getSelfHandlers(owner, options) {
44
45
  function isConstructable(value) {
45
46
  return typeof value === "object" && value !== null;
46
47
  }
48
+ //#endregion
47
49
  export { getCompareHandlers, getSelfHandlers };
@@ -1,4 +1,5 @@
1
1
  import { getNestedValue } from "./misc.js";
2
+ //#region src/internal/value/has.ts
2
3
  function hasValue(data, path, ignoreCase) {
3
4
  return getNestedValue(data, path, ignoreCase === true).exists;
4
5
  }
@@ -6,4 +7,5 @@ hasValue.get = getWithHasValue;
6
7
  function getWithHasValue(data, path, ignoreCase) {
7
8
  return getNestedValue(data, path, ignoreCase === true);
8
9
  }
10
+ //#endregion
9
11
  export { hasValue };
@@ -1,4 +1,5 @@
1
1
  import { ignoreKey } from "../string.js";
2
+ //#region src/internal/value/misc.ts
2
3
  function findKey(needle, haystack) {
3
4
  const keys = Object.keys(haystack);
4
5
  const index = keys.map((key) => key.toLowerCase()).indexOf(needle.toLowerCase());
@@ -47,4 +48,5 @@ function handleValue(data, path, value, get, ignoreCase) {
47
48
  var EXPRESSION_BRACKET = /\[(\w+)\]/g;
48
49
  var EXPRESSION_DOTS = /^\.|\.$/g;
49
50
  var EXPRESSION_NESTED = /\.|\[\w+\]/;
51
+ //#endregion
50
52
  export { findKey, getNestedValue, getPaths, handleValue };
@@ -1,3 +1,4 @@
1
+ //#region src/internal/value/partial.ts
1
2
  function partial(value, providedKeys, omit) {
2
3
  if (typeof value !== "object" || value === null) return {};
3
4
  const keys = omit ? Object.keys(value) : Array.isArray(providedKeys) ? providedKeys : [];
@@ -11,4 +12,5 @@ function partial(value, providedKeys, omit) {
11
12
  }
12
13
  return partials;
13
14
  }
15
+ //#endregion
14
16
  export { partial };
@@ -1,4 +1,5 @@
1
1
  import { getPaths, handleValue } from "./misc.js";
2
+ //#region src/internal/value/set.ts
2
3
  function setValue(data, path, value, ignoreCase) {
3
4
  if (typeof data !== "object" || data === null || typeof path !== "string" || path.trim().length === 0) return data;
4
5
  const shouldIgnoreCase = ignoreCase === true;
@@ -28,4 +29,5 @@ function setValue(data, path, value, ignoreCase) {
28
29
  return data;
29
30
  }
30
31
  var EXPRESSION_INDEX = /^\d+$/;
32
+ //#endregion
31
33
  export { setValue };
package/dist/is.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { isArrayOrPlainObject, isConstructor, isInstanceOf, isKey, isNumber, isPlainObject, isTypedArray } from "./internal/is.js";
2
2
  import { getArray } from "./array/get.js";
3
3
  import { getString } from "./internal/string.js";
4
+ //#region src/is.ts
4
5
  /**
5
6
  * Is the value empty, or only containing `null` or `undefined` values?
6
7
  * @param value Value to check
@@ -72,4 +73,5 @@ function isPrimitive(value) {
72
73
  }
73
74
  var EXPRESSION_PRIMITIVE = /^(bigint|boolean|number|string|symbol)$/;
74
75
  var EXPRESSION_WHITESPACE = /^\s*$/;
76
+ //#endregion
75
77
  export { isArrayOrPlainObject, isConstructor, isEmpty, isInstanceOf, isKey, isNonNullable, isNullable, isNullableOrEmpty, isNullableOrWhitespace, isNumber, isNumerical, isObject, isPlainObject, isPrimitive, isTypedArray };
package/dist/logger.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { noop } from "./internal/function/misc.js";
2
+ //#region src/logger.ts
2
3
  var Logger = class {
3
4
  /**
4
5
  * Log any number of values at the "debug" log level
@@ -110,4 +111,5 @@ var Time = class {
110
111
  };
111
112
  var logger = new Logger();
112
113
  var enabled = true;
114
+ //#endregion
113
115
  export { logger };
package/dist/math.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { isNumber } from "./internal/is.js";
2
2
  import { aggregate, getAggregateCallback, getAggregated, max } from "./internal/math/aggregate.js";
3
+ //#region src/math.ts
3
4
  function average(array, key) {
4
5
  const aggregated = aggregate("average", array, key);
5
6
  return aggregated.count > 0 ? aggregated.value / aggregated.count : NaN;
@@ -71,4 +72,5 @@ function roundNumber(callback, value, decimals) {
71
72
  function sum(array, key) {
72
73
  return getAggregated("sum", array, key);
73
74
  }
75
+ //#endregion
74
76
  export { average, ceil, count, floor, max, median, min, round, sum };
@@ -1,7 +1,8 @@
1
1
  import { TIMER_WAIT, getTimer } from "../internal/function/timer.js";
2
2
  import { PROMISE_ABORT_OPTIONS } from "./models.js";
3
- import { getPromiseOptions } from "./helpers.js";
4
3
  import { settlePromise } from "./misc.js";
4
+ import { getPromiseOptions } from "./helpers.js";
5
+ //#region src/promise/delay.ts
5
6
  function delay(options) {
6
7
  const { signal, time } = getPromiseOptions(options);
7
8
  if (signal?.aborted ?? false) return Promise.reject(signal.reason);
@@ -22,4 +23,5 @@ function delay(options) {
22
23
  else timer();
23
24
  });
24
25
  }
26
+ //#endregion
25
27
  export { delay };
@@ -1,4 +1,7 @@
1
+ import { error, ok } from "../result/misc.js";
1
2
  import { PROMISE_STRATEGY_ALL, PROMISE_STRATEGY_DEFAULT, PROMISE_TYPE_FULFILLED, PROMISE_TYPE_REJECTED } from "./models.js";
3
+ import "../result/index.js";
4
+ //#region src/promise/helpers.ts
2
5
  function getNumberOrDefault(value) {
3
6
  return typeof value === "number" && value > 0 ? value : 0;
4
7
  }
@@ -26,6 +29,9 @@ function getPromisesOptions(input) {
26
29
  strategy: getStrategyOrDefault(options.strategy)
27
30
  };
28
31
  }
32
+ function getResultsFromPromises(promised) {
33
+ return promised.map((result) => isFulfilled(result) ? ok(result.value) : error(result.reason));
34
+ }
29
35
  function getStrategyOrDefault(value) {
30
36
  return PROMISE_STRATEGY_ALL.has(value) ? value : PROMISE_STRATEGY_DEFAULT;
31
37
  }
@@ -48,4 +54,5 @@ function isRejected(value) {
48
54
  function isType(value, type) {
49
55
  return typeof value === "object" && value !== null && value.status === type;
50
56
  }
51
- export { getPromiseOptions, getPromisesOptions, getStrategyOrDefault, isFulfilled, isRejected };
57
+ //#endregion
58
+ export { getPromiseOptions, getPromisesOptions, getResultsFromPromises, getStrategyOrDefault, isFulfilled, isRejected };