es-toolkit 1.13.1-dev.318 → 1.13.1-dev.321

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 (210) hide show
  1. package/dist/array/chunk.mjs +1 -1
  2. package/dist/array/compact.mjs +1 -1
  3. package/dist/array/countBy.js +1 -2
  4. package/dist/array/countBy.js.map +1 -1
  5. package/dist/array/countBy.mjs +2 -2
  6. package/dist/array/difference.mjs +1 -1
  7. package/dist/array/differenceBy.mjs +1 -1
  8. package/dist/array/differenceWith.mjs +1 -1
  9. package/dist/array/drop.mjs +1 -1
  10. package/dist/array/dropRight.mjs +1 -1
  11. package/dist/array/dropRightWhile.mjs +1 -1
  12. package/dist/array/dropWhile.mjs +1 -1
  13. package/dist/array/fill.mjs +1 -1
  14. package/dist/array/flatMap.mjs +1 -1
  15. package/dist/array/flatten.mjs +1 -1
  16. package/dist/array/flattenDeep.mjs +1 -1
  17. package/dist/array/forEachRight.mjs +1 -1
  18. package/dist/array/groupBy.mjs +1 -1
  19. package/dist/array/head.mjs +1 -1
  20. package/dist/array/index.js +1 -2
  21. package/dist/array/index.js.map +1 -1
  22. package/dist/array/index.mjs +2 -2
  23. package/dist/array/initial.mjs +1 -1
  24. package/dist/array/intersection.mjs +1 -1
  25. package/dist/array/intersectionBy.mjs +1 -1
  26. package/dist/array/intersectionWith.mjs +1 -1
  27. package/dist/array/keyBy.mjs +1 -1
  28. package/dist/array/last.mjs +1 -1
  29. package/dist/array/maxBy.mjs +1 -1
  30. package/dist/array/minBy.mjs +1 -1
  31. package/dist/array/orderBy.mjs +1 -1
  32. package/dist/array/partition.mjs +1 -1
  33. package/dist/array/sample.mjs +1 -1
  34. package/dist/array/sampleSize.mjs +1 -1
  35. package/dist/array/shuffle.mjs +1 -1
  36. package/dist/array/tail.mjs +1 -1
  37. package/dist/array/take.mjs +1 -1
  38. package/dist/array/takeRight.mjs +1 -1
  39. package/dist/array/takeRightWhile.mjs +1 -1
  40. package/dist/array/takeWhile.mjs +1 -1
  41. package/dist/array/toFilled.mjs +1 -1
  42. package/dist/array/union.mjs +1 -1
  43. package/dist/array/unionBy.mjs +1 -1
  44. package/dist/array/unionWith.mjs +1 -1
  45. package/dist/array/uniq.mjs +1 -1
  46. package/dist/array/uniqBy.mjs +1 -1
  47. package/dist/array/uniqWith.mjs +1 -1
  48. package/dist/array/unzip.mjs +1 -1
  49. package/dist/array/unzipWith.mjs +1 -1
  50. package/dist/array/without.mjs +1 -1
  51. package/dist/array/xor.mjs +1 -1
  52. package/dist/array/xorBy.mjs +1 -1
  53. package/dist/array/xorWith.mjs +1 -1
  54. package/dist/array/zip.mjs +1 -1
  55. package/dist/array/zipObject.mjs +1 -1
  56. package/dist/array/zipWith.mjs +1 -1
  57. package/dist/browser.js +33 -58
  58. package/dist/browser.js.map +1 -1
  59. package/dist/browser.mjs +19 -17
  60. package/dist/browser.mjs.map +1 -1
  61. package/dist/{chunk-QXTNZR7B.mjs → chunk-3SBT6WDU.mjs} +2 -2
  62. package/dist/{chunk-O64NE2P4.mjs → chunk-4DFAGGIM.mjs} +3 -3
  63. package/dist/{chunk-O64NE2P4.mjs.map → chunk-4DFAGGIM.mjs.map} +1 -1
  64. package/dist/{chunk-Y5V7UAZZ.mjs → chunk-4ZES5T6V.mjs} +4 -4
  65. package/dist/{chunk-EYYZQFOP.mjs → chunk-ET33L3MQ.mjs} +2 -2
  66. package/dist/chunk-EZYYB34V.mjs +17 -0
  67. package/dist/{chunk-CVVZHOJX.mjs.map → chunk-EZYYB34V.mjs.map} +1 -1
  68. package/dist/{chunk-36ZJSTNA.mjs → chunk-IGM5IABU.mjs} +37 -24
  69. package/dist/chunk-IGM5IABU.mjs.map +1 -0
  70. package/dist/{chunk-F3WCQQET.mjs → chunk-IWXZI3QT.mjs} +2 -2
  71. package/dist/chunk-J5LGTIGS.mjs +10 -0
  72. package/dist/{chunk-5CPXZFCB.mjs → chunk-K5WL54BY.mjs} +2 -2
  73. package/dist/{chunk-5CPXZFCB.mjs.map → chunk-K5WL54BY.mjs.map} +1 -1
  74. package/dist/{chunk-3IP4JVLL.mjs → chunk-MSHSKENG.mjs} +3 -3
  75. package/dist/{chunk-3IP4JVLL.mjs.map → chunk-MSHSKENG.mjs.map} +1 -1
  76. package/dist/{chunk-WVQ7YVRK.mjs → chunk-OG2RLT5U.mjs} +2 -3
  77. package/dist/{chunk-WVQ7YVRK.mjs.map → chunk-OG2RLT5U.mjs.map} +1 -1
  78. package/dist/chunk-R6GLTTAB.mjs +9 -0
  79. package/dist/chunk-R6GLTTAB.mjs.map +1 -0
  80. package/dist/{chunk-5IKVJGHO.mjs → chunk-RTFTLCF3.mjs} +2 -2
  81. package/dist/chunk-SXFMQQ6F.mjs +9 -0
  82. package/dist/chunk-SXFMQQ6F.mjs.map +1 -0
  83. package/dist/{chunk-WFZXCGEG.mjs → chunk-YOPFSFTD.mjs} +2 -6
  84. package/dist/{chunk-WFZXCGEG.mjs.map → chunk-YOPFSFTD.mjs.map} +1 -1
  85. package/dist/chunk-YXD3AQAK.mjs +1 -0
  86. package/dist/{chunk-CRSKT4WW.mjs → chunk-Z7HWEOQX.mjs} +2 -3
  87. package/dist/{chunk-CRSKT4WW.mjs.map → chunk-Z7HWEOQX.mjs.map} +1 -1
  88. package/dist/chunk-ZPNX2QDE.mjs +13 -0
  89. package/dist/{chunk-IIDZ3KAJ.mjs.map → chunk-ZPNX2QDE.mjs.map} +1 -1
  90. package/dist/compat/index.d.mts +20 -1
  91. package/dist/compat/index.d.ts +20 -1
  92. package/dist/compat/index.js +35 -57
  93. package/dist/compat/index.js.map +1 -1
  94. package/dist/compat/index.mjs +30 -23
  95. package/dist/error/AbortError.mjs +1 -1
  96. package/dist/error/TimeoutError.mjs +1 -1
  97. package/dist/error/index.mjs +1 -1
  98. package/dist/function/after.mjs +1 -1
  99. package/dist/function/debounce.js +2 -2
  100. package/dist/function/debounce.js.map +1 -1
  101. package/dist/function/debounce.mjs +2 -2
  102. package/dist/function/index.js +2 -2
  103. package/dist/function/index.js.map +1 -1
  104. package/dist/function/index.mjs +2 -2
  105. package/dist/function/negate.mjs +1 -1
  106. package/dist/function/noop.mjs +1 -1
  107. package/dist/function/once.mjs +1 -1
  108. package/dist/function/throttle.mjs +1 -1
  109. package/dist/index.d.mts +2 -0
  110. package/dist/index.d.ts +2 -0
  111. package/dist/index.js +27 -53
  112. package/dist/index.js.map +1 -1
  113. package/dist/index.mjs +30 -22
  114. package/dist/math/clamp.mjs +1 -1
  115. package/dist/math/inRange.mjs +1 -1
  116. package/dist/math/index.mjs +1 -1
  117. package/dist/math/mean.mjs +1 -1
  118. package/dist/math/meanBy.mjs +1 -1
  119. package/dist/math/random.mjs +1 -1
  120. package/dist/math/randomInt.mjs +1 -1
  121. package/dist/math/range.mjs +1 -1
  122. package/dist/math/round.mjs +1 -1
  123. package/dist/math/sum.mjs +1 -1
  124. package/dist/math/sumBy.mjs +1 -1
  125. package/dist/object/clone.mjs +1 -1
  126. package/dist/object/cloneDeep.js +1 -1
  127. package/dist/object/cloneDeep.js.map +1 -1
  128. package/dist/object/cloneDeep.mjs +2 -2
  129. package/dist/object/flattenObject.mjs +1 -1
  130. package/dist/object/index.js +2 -16
  131. package/dist/object/index.js.map +1 -1
  132. package/dist/object/index.mjs +3 -3
  133. package/dist/object/invert.mjs +1 -1
  134. package/dist/object/omit.js +1 -15
  135. package/dist/object/omit.js.map +1 -1
  136. package/dist/object/omit.mjs +2 -2
  137. package/dist/object/omitBy.mjs +1 -1
  138. package/dist/object/pick.mjs +1 -1
  139. package/dist/object/pickBy.mjs +1 -1
  140. package/dist/predicate/index.d.mts +2 -0
  141. package/dist/predicate/index.d.ts +2 -0
  142. package/dist/predicate/index.js +14 -0
  143. package/dist/predicate/index.js.map +1 -1
  144. package/dist/predicate/index.mjs +12 -4
  145. package/dist/predicate/isArrayLike.mjs +1 -1
  146. package/dist/predicate/isEqual.mjs +1 -1
  147. package/dist/predicate/isFunction.mjs +1 -1
  148. package/dist/predicate/isLength.mjs +1 -1
  149. package/dist/predicate/isNil.mjs +1 -1
  150. package/dist/predicate/isNotNil.mjs +1 -1
  151. package/dist/predicate/isNull.mjs +1 -1
  152. package/dist/predicate/isPlainObject.mjs +1 -1
  153. package/dist/predicate/isPrimitive.d.mts +17 -0
  154. package/dist/predicate/isPrimitive.d.ts +17 -0
  155. package/dist/predicate/isPrimitive.js +33 -0
  156. package/dist/predicate/isPrimitive.js.map +1 -0
  157. package/dist/predicate/isPrimitive.mjs +8 -0
  158. package/dist/predicate/isPrimitive.mjs.map +1 -0
  159. package/dist/predicate/isTypedArray.d.mts +19 -0
  160. package/dist/predicate/isTypedArray.d.ts +19 -0
  161. package/dist/predicate/isTypedArray.js +33 -0
  162. package/dist/predicate/isTypedArray.js.map +1 -0
  163. package/dist/predicate/isTypedArray.mjs +8 -0
  164. package/dist/predicate/isTypedArray.mjs.map +1 -0
  165. package/dist/predicate/isUndefined.mjs +1 -1
  166. package/dist/promise/delay.js +2 -2
  167. package/dist/promise/delay.js.map +1 -1
  168. package/dist/promise/delay.mjs +2 -2
  169. package/dist/promise/index.js +7 -31
  170. package/dist/promise/index.js.map +1 -1
  171. package/dist/promise/index.mjs +4 -4
  172. package/dist/promise/timeout.js +5 -27
  173. package/dist/promise/timeout.js.map +1 -1
  174. package/dist/promise/timeout.mjs +3 -3
  175. package/dist/promise/withTimeout.js +7 -31
  176. package/dist/promise/withTimeout.js.map +1 -1
  177. package/dist/promise/withTimeout.mjs +4 -4
  178. package/dist/string/camelCase.js +1 -2
  179. package/dist/string/camelCase.js.map +1 -1
  180. package/dist/string/camelCase.mjs +3 -3
  181. package/dist/string/capitalize.mjs +1 -1
  182. package/dist/string/index.js +1 -2
  183. package/dist/string/index.js.map +1 -1
  184. package/dist/string/index.mjs +11 -11
  185. package/dist/string/kebabCase.js +1 -2
  186. package/dist/string/kebabCase.js.map +1 -1
  187. package/dist/string/kebabCase.mjs +3 -3
  188. package/dist/string/lowerCase.js +1 -2
  189. package/dist/string/lowerCase.js.map +1 -1
  190. package/dist/string/lowerCase.mjs +3 -3
  191. package/dist/string/snakeCase.js +1 -2
  192. package/dist/string/snakeCase.js.map +1 -1
  193. package/dist/string/snakeCase.mjs +3 -3
  194. package/dist/string/startCase.js +1 -2
  195. package/dist/string/startCase.js.map +1 -1
  196. package/dist/string/startCase.mjs +3 -3
  197. package/package.json +1 -1
  198. package/umd/browser.global.js +1 -1
  199. package/dist/chunk-24FKGR6U.mjs +0 -47
  200. package/dist/chunk-36ZJSTNA.mjs.map +0 -1
  201. package/dist/chunk-CVVZHOJX.mjs +0 -22
  202. package/dist/chunk-IIDZ3KAJ.mjs +0 -18
  203. package/dist/chunk-U4JWMVQK.mjs +0 -1
  204. /package/dist/{chunk-QXTNZR7B.mjs.map → chunk-3SBT6WDU.mjs.map} +0 -0
  205. /package/dist/{chunk-Y5V7UAZZ.mjs.map → chunk-4ZES5T6V.mjs.map} +0 -0
  206. /package/dist/{chunk-EYYZQFOP.mjs.map → chunk-ET33L3MQ.mjs.map} +0 -0
  207. /package/dist/{chunk-F3WCQQET.mjs.map → chunk-IWXZI3QT.mjs.map} +0 -0
  208. /package/dist/{chunk-24FKGR6U.mjs.map → chunk-J5LGTIGS.mjs.map} +0 -0
  209. /package/dist/{chunk-5IKVJGHO.mjs.map → chunk-RTFTLCF3.mjs.map} +0 -0
  210. /package/dist/{chunk-U4JWMVQK.mjs.map → chunk-YXD3AQAK.mjs.map} +0 -0
@@ -28,6 +28,8 @@ __export(predicate_exports, {
28
28
  isNotNil: () => isNotNil,
29
29
  isNull: () => isNull,
30
30
  isPlainObject: () => isPlainObject,
31
+ isPrimitive: () => isPrimitive,
32
+ isTypedArray: () => isTypedArray,
31
33
  isUndefined: () => isUndefined
32
34
  });
33
35
  module.exports = __toCommonJS(predicate_exports);
@@ -130,6 +132,16 @@ function isFunction(value) {
130
132
  function isArrayLike(value) {
131
133
  return value != null && typeof value !== "function" && isLength(value.length);
132
134
  }
135
+
136
+ // src/predicate/isTypedArray.ts
137
+ function isTypedArray(x) {
138
+ return x instanceof Uint8Array || x instanceof Uint8ClampedArray || x instanceof Uint16Array || x instanceof Uint32Array || x instanceof BigUint64Array || x instanceof Int8Array || x instanceof Int16Array || x instanceof Int32Array || x instanceof BigInt64Array || x instanceof Float32Array || x instanceof Float64Array;
139
+ }
140
+
141
+ // src/predicate/isPrimitive.ts
142
+ function isPrimitive(value) {
143
+ return value == null || typeof value !== "object" && typeof value !== "function";
144
+ }
133
145
  // Annotate the CommonJS export names for ESM import in node:
134
146
  0 && (module.exports = {
135
147
  isArrayLike,
@@ -140,6 +152,8 @@ function isArrayLike(value) {
140
152
  isNotNil,
141
153
  isNull,
142
154
  isPlainObject,
155
+ isPrimitive,
156
+ isTypedArray,
143
157
  isUndefined
144
158
  });
145
159
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/predicate/index.ts","../../src/array/uniq.ts","../../src/array/union.ts","../../src/predicate/isEqual.ts","../../src/predicate/isNil.ts","../../src/predicate/isNotNil.ts","../../src/predicate/isNull.ts","../../src/predicate/isUndefined.ts","../../src/predicate/isLength.ts","../../src/predicate/isPlainObject.ts","../../src/predicate/isFunction.ts","../../src/predicate/isArrayLike.ts"],"sourcesContent":["export { isEqual } from './isEqual.ts';\nexport { isNil } from './isNil.ts';\nexport { isNotNil } from './isNotNil.ts';\nexport { isNull } from './isNull.ts';\nexport { isUndefined } from './isUndefined.ts';\nexport { isLength } from './isLength.ts';\nexport { isPlainObject } from './isPlainObject.ts';\nexport { isFunction } from './isFunction.ts';\nexport { isArrayLike } from './isArrayLike.ts';\n","/**\n * Creates a duplicate-free version of an array.\n *\n * This function takes an array and returns a new array containing only the unique values\n * from the original array, preserving the order of first occurrence.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr - The array to process.\n * @returns {T[]} A new array with only unique values from the original array.\n *\n * @example\n * const array = [1, 2, 2, 3, 4, 4, 5];\n * const result = uniq(array);\n * // result will be [1, 2, 3, 4, 5]\n */\nexport function uniq<T>(arr: readonly T[]): T[] {\n return Array.from(new Set(arr));\n}\n","import { uniq } from './uniq.ts';\n\n/**\n * Creates an array of unique values from all given arrays.\n *\n * This function takes two arrays, merges them into a single array, and returns a new array\n * containing only the unique values from the merged array.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr1 - The first array to merge and filter for unique values.\n * @param {T[]} arr2 - The second array to merge and filter for unique values.\n * @returns {T[]} A new array of unique values.\n *\n * @example\n * const array1 = [1, 2, 3];\n * const array2 = [3, 4, 5];\n * const result = union(array1, array2);\n * // result will be [1, 2, 3, 4, 5]\n */\nexport function union<T>(arr1: readonly T[], arr2: readonly T[]): T[] {\n return uniq(arr1.concat(arr2));\n}\n","import { union } from \"../array/union.ts\";\n\n/**\n * Checks if two values are equal, including support for `Date`, `RegExp`, and deep object comparison.\n *\n * @param {unknown} a - The first value to compare.\n * @param {unknown} b - The second value to compare.\n * @returns {boolean} `true` if the values are equal, otherwise `false`.\n *\n * @example\n * isEqual(1, 1); // true\n * isEqual({ a: 1 }, { a: 1 }); // true\n * isEqual(/abc/g, /abc/g); // true\n * isEqual(new Date('2020-01-01'), new Date('2020-01-01')); // true\n * isEqual([1, 2, 3], [1, 2, 3]); // true\n */\nexport function isEqual(a: unknown, b: unknown): boolean {\n if (Object.is(a, b)) {\n return true;\n }\n\n if (a instanceof Date && b instanceof Date) {\n return a.getTime() === b.getTime();\n }\n\n if (a instanceof RegExp && b instanceof RegExp) {\n return a.source === b.source && a.flags === b.flags;\n }\n\n if (typeof a !== 'object' || typeof b !== 'object' || a === null || b === null) {\n return false;\n }\n\n const aKeys = Object.keys(a as object);\n const bKeys = Object.keys(b as object);\n\n if (aKeys.length !== bKeys.length) {\n return false;\n }\n\n // check if all keys in both arrays match\n if (union(aKeys, bKeys).length !== aKeys.length) {\n return false;\n }\n\n for (let i = 0; i < aKeys.length; i++) {\n const propKey = aKeys[i];\n const aProp = (a as any)[propKey];\n const bProp = (b as any)[propKey];\n \n if (!isEqual(aProp, bProp)) {\n return false;\n }\n }\n\n return true;\n}\n","/**\n * Checks if a given value is null or undefined.\n *\n * This function tests whether the provided value is either `null` or `undefined`.\n * It returns `true` if the value is `null` or `undefined`, and `false` otherwise.\n *\n * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `null` or `undefined`.\n *\n * @param {unknown} x - The value to test for null or undefined.\n * @returns {boolean} `true` if the value is null or undefined, `false` otherwise.\n *\n * @example\n * const value1 = null;\n * const value2 = undefined;\n * const value3 = 42;\n * const result1 = isNil(value1); // true\n * const result2 = isNil(value2); // true\n * const result3 = isNil(value3); // false\n */\nexport function isNil(x: unknown): x is null | undefined {\n return x == null;\n}\n","/**\n * Checks if the given value is not null nor undefined.\n *\n * The main use of this function is to be used with TypeScript as a type predicate.\n *\n * @template T - The type of value.\n * @param {T | null | undefined} x - The value to test if it is not null nor undefined.\n * @returns {x is T} True if the value is not null nor undefined, false otherwise.\n *\n * @example\n * // Here the type of `arr` is (number | undefined)[]\n * const arr = [1, undefined, 3];\n * // Here the type of `result` is number[]\n * const result = arr.filter(isNotNil);\n * // result will be [1, 3]\n */\nexport function isNotNil<T>(x: T | null | undefined): x is T {\n return x !== null && x !== undefined;\n}\n","/**\n * Checks if the given value is null.\n *\n * This function tests whether the provided value is strictly equal to `null`.\n * It returns `true` if the value is `null`, and `false` otherwise.\n *\n * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `null`.\n *\n * @param {unknown} x - The value to test if it is null.\n * @returns {x is null} True if the value is null, false otherwise.\n *\n * @example\n * const value1 = null;\n * const value2 = undefined;\n * const value3 = 42;\n *\n * console.log(isNull(value1)); // true\n * console.log(isNull(value2)); // false\n * console.log(isNull(value3)); // false\n */\nexport function isNull(x: unknown): x is null {\n return x === null;\n}\n","/**\n * Checks if the given value is undefined.\n *\n * This function tests whether the provided value is strictly equal to `undefined`.\n * It returns `true` if the value is `undefined`, and `false` otherwise.\n *\n * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `undefined`.\n *\n * @param {unknown} x - The value to test if it is undefined.\n * @returns {x is undefined} true if the value is undefined, false otherwise.\n *\n * @example\n * const value1 = undefined;\n * const value2 = null;\n * const value3 = 42;\n *\n * console.log(isUndefined(value1)); // true\n * console.log(isUndefined(value2)); // false\n * console.log(isUndefined(value3)); // false\n */\nexport function isUndefined(x: unknown): x is undefined {\n return x === undefined;\n}\n","export function isLength(value: unknown): value is number {\n return typeof value === 'number' && value > -1 && value % 1 === 0 && value <= Number.MAX_SAFE_INTEGER;\n}\n","/**\n * Checks if a given value is a plain object.\n * \n * @param {object} object - The value to check.\n * @returns {boolean} - True if the value is a plain object, otherwise false.\n * \n * @example\n * console.log(isPlainObject({})); // true\n * console.log(isPlainObject([])); // false\n * console.log(isPlainObject(null)); // false\n * console.log(isPlainObject(Object.create(null))); // true\n * console.log(Buffer.from('hello, world')); // false\n */\nexport function isPlainObject(object: object): boolean {\n if (typeof object !== 'object') {\n return false;\n }\n\n if (object == null) {\n return false;\n }\n\n if (Object.getPrototypeOf(object) === null) {\n return true;\n }\n\n if (object.toString() !== '[object Object]') {\n return false;\n }\n\n let proto = object;\n\n while (Object.getPrototypeOf(proto) !== null) {\n proto = Object.getPrototypeOf(proto);\n }\n\n return Object.getPrototypeOf(object) === proto;\n}","/**\n * Checks if `value` is a function.\n *\n * @param {unknown} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a function, else `false`.\n *\n * @example\n * isFunction(Array.prototype.slice); // true\n * isFunction(async function () {}); // true\n * isFunction(function* () {}); // true\n * isFunction(Proxy); // true\n * isFunction(Int8Array); // true\n */\nexport function isFunction(value: unknown): value is (...args: unknown[]) => unknown {\n return typeof value === 'function';\n}\n","import { isLength } from \"./isLength.ts\";\n\n/**\n * Checks if `value` is array-like.\n *\n * @param {unknown} value The value to check.\n * @returns {value is ArrayLike<unknown>} Returns `true` if `value` is array-like, else `false`.\n *\n * @example\n * isArrayLike([1, 2, 3]); // true\n * isArrayLike('abc'); // true\n * isArrayLike({ 0: 'a', length: 1 }); // true\n * isArrayLike({}); // false\n * isArrayLike(null); // false\n * isArrayLike(undefined); // false\n */\nexport function isArrayLike(value: unknown): value is ArrayLike<unknown> {\n return value != null && typeof value !== \"function\" &&\n isLength((value as ArrayLike<unknown>).length);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACeO,SAAS,KAAQ,KAAwB;AAC9C,SAAO,MAAM,KAAK,IAAI,IAAI,GAAG,CAAC;AAChC;;;ACEO,SAAS,MAAS,MAAoB,MAAyB;AACpE,SAAO,KAAK,KAAK,OAAO,IAAI,CAAC;AAC/B;;;ACLO,SAAS,QAAQ,GAAY,GAAqB;AACvD,MAAI,OAAO,GAAG,GAAG,CAAC,GAAG;AACnB,WAAO;AAAA,EACT;AAEA,MAAI,aAAa,QAAQ,aAAa,MAAM;AAC1C,WAAO,EAAE,QAAQ,MAAM,EAAE,QAAQ;AAAA,EACnC;AAEA,MAAI,aAAa,UAAU,aAAa,QAAQ;AAC9C,WAAO,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE;AAAA,EAChD;AAEA,MAAI,OAAO,MAAM,YAAY,OAAO,MAAM,YAAY,MAAM,QAAQ,MAAM,MAAM;AAC9E,WAAO;AAAA,EACT;AAEA,QAAM,QAAQ,OAAO,KAAK,CAAW;AACrC,QAAM,QAAQ,OAAO,KAAK,CAAW;AAErC,MAAI,MAAM,WAAW,MAAM,QAAQ;AACjC,WAAO;AAAA,EACT;AAGA,MAAI,MAAM,OAAO,KAAK,EAAE,WAAW,MAAM,QAAQ;AAC/C,WAAO;AAAA,EACT;AAEA,WAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AACrC,UAAM,UAAU,MAAM,CAAC;AACvB,UAAM,QAAS,EAAU,OAAO;AAChC,UAAM,QAAS,EAAU,OAAO;AAEhC,QAAI,CAAC,QAAQ,OAAO,KAAK,GAAG;AAC1B,aAAO;AAAA,IACT;AAAA,EACF;AAEA,SAAO;AACT;;;ACrCO,SAAS,MAAM,GAAmC;AACvD,SAAO,KAAK;AACd;;;ACLO,SAAS,SAAY,GAAiC;AAC3D,SAAO,MAAM,QAAQ,MAAM;AAC7B;;;ACEO,SAAS,OAAO,GAAuB;AAC5C,SAAO,MAAM;AACf;;;ACFO,SAAS,YAAY,GAA4B;AACtD,SAAO,MAAM;AACf;;;ACtBO,SAAS,SAAS,OAAiC;AACxD,SAAO,OAAO,UAAU,YAAY,QAAQ,MAAM,QAAQ,MAAM,KAAK,SAAS,OAAO;AACvF;;;ACWO,SAAS,cAAc,QAAyB;AACrD,MAAI,OAAO,WAAW,UAAU;AAC9B,WAAO;AAAA,EACT;AAEA,MAAI,UAAU,MAAM;AAClB,WAAO;AAAA,EACT;AAEA,MAAI,OAAO,eAAe,MAAM,MAAM,MAAM;AAC1C,WAAO;AAAA,EACT;AAEA,MAAI,OAAO,SAAS,MAAM,mBAAmB;AAC3C,WAAO;AAAA,EACT;AAEA,MAAI,QAAQ;AAEZ,SAAO,OAAO,eAAe,KAAK,MAAM,MAAM;AAC5C,YAAQ,OAAO,eAAe,KAAK;AAAA,EACrC;AAEA,SAAO,OAAO,eAAe,MAAM,MAAM;AAC3C;;;ACxBO,SAAS,WAAW,OAA0D;AACnF,SAAO,OAAO,UAAU;AAC1B;;;ACCO,SAAS,YAAY,OAA6C;AACvE,SAAO,SAAS,QAAQ,OAAO,UAAU,cACvC,SAAU,MAA6B,MAAM;AACjD;","names":[]}
1
+ {"version":3,"sources":["../../src/predicate/index.ts","../../src/array/uniq.ts","../../src/array/union.ts","../../src/predicate/isEqual.ts","../../src/predicate/isNil.ts","../../src/predicate/isNotNil.ts","../../src/predicate/isNull.ts","../../src/predicate/isUndefined.ts","../../src/predicate/isLength.ts","../../src/predicate/isPlainObject.ts","../../src/predicate/isFunction.ts","../../src/predicate/isArrayLike.ts","../../src/predicate/isTypedArray.ts","../../src/predicate/isPrimitive.ts"],"sourcesContent":["export { isEqual } from './isEqual.ts';\nexport { isNil } from './isNil.ts';\nexport { isNotNil } from './isNotNil.ts';\nexport { isNull } from './isNull.ts';\nexport { isUndefined } from './isUndefined.ts';\nexport { isLength } from './isLength.ts';\nexport { isPlainObject } from './isPlainObject.ts';\nexport { isFunction } from './isFunction.ts';\nexport { isArrayLike } from './isArrayLike.ts';\nexport { isTypedArray } from './isTypedArray.ts';\nexport { isPrimitive } from './isPrimitive.ts';\n","/**\n * Creates a duplicate-free version of an array.\n *\n * This function takes an array and returns a new array containing only the unique values\n * from the original array, preserving the order of first occurrence.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr - The array to process.\n * @returns {T[]} A new array with only unique values from the original array.\n *\n * @example\n * const array = [1, 2, 2, 3, 4, 4, 5];\n * const result = uniq(array);\n * // result will be [1, 2, 3, 4, 5]\n */\nexport function uniq<T>(arr: readonly T[]): T[] {\n return Array.from(new Set(arr));\n}\n","import { uniq } from './uniq.ts';\n\n/**\n * Creates an array of unique values from all given arrays.\n *\n * This function takes two arrays, merges them into a single array, and returns a new array\n * containing only the unique values from the merged array.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr1 - The first array to merge and filter for unique values.\n * @param {T[]} arr2 - The second array to merge and filter for unique values.\n * @returns {T[]} A new array of unique values.\n *\n * @example\n * const array1 = [1, 2, 3];\n * const array2 = [3, 4, 5];\n * const result = union(array1, array2);\n * // result will be [1, 2, 3, 4, 5]\n */\nexport function union<T>(arr1: readonly T[], arr2: readonly T[]): T[] {\n return uniq(arr1.concat(arr2));\n}\n","import { union } from \"../array/union.ts\";\n\n/**\n * Checks if two values are equal, including support for `Date`, `RegExp`, and deep object comparison.\n *\n * @param {unknown} a - The first value to compare.\n * @param {unknown} b - The second value to compare.\n * @returns {boolean} `true` if the values are equal, otherwise `false`.\n *\n * @example\n * isEqual(1, 1); // true\n * isEqual({ a: 1 }, { a: 1 }); // true\n * isEqual(/abc/g, /abc/g); // true\n * isEqual(new Date('2020-01-01'), new Date('2020-01-01')); // true\n * isEqual([1, 2, 3], [1, 2, 3]); // true\n */\nexport function isEqual(a: unknown, b: unknown): boolean {\n if (Object.is(a, b)) {\n return true;\n }\n\n if (a instanceof Date && b instanceof Date) {\n return a.getTime() === b.getTime();\n }\n\n if (a instanceof RegExp && b instanceof RegExp) {\n return a.source === b.source && a.flags === b.flags;\n }\n\n if (typeof a !== 'object' || typeof b !== 'object' || a === null || b === null) {\n return false;\n }\n\n const aKeys = Object.keys(a as object);\n const bKeys = Object.keys(b as object);\n\n if (aKeys.length !== bKeys.length) {\n return false;\n }\n\n // check if all keys in both arrays match\n if (union(aKeys, bKeys).length !== aKeys.length) {\n return false;\n }\n\n for (let i = 0; i < aKeys.length; i++) {\n const propKey = aKeys[i];\n const aProp = (a as any)[propKey];\n const bProp = (b as any)[propKey];\n \n if (!isEqual(aProp, bProp)) {\n return false;\n }\n }\n\n return true;\n}\n","/**\n * Checks if a given value is null or undefined.\n *\n * This function tests whether the provided value is either `null` or `undefined`.\n * It returns `true` if the value is `null` or `undefined`, and `false` otherwise.\n *\n * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `null` or `undefined`.\n *\n * @param {unknown} x - The value to test for null or undefined.\n * @returns {boolean} `true` if the value is null or undefined, `false` otherwise.\n *\n * @example\n * const value1 = null;\n * const value2 = undefined;\n * const value3 = 42;\n * const result1 = isNil(value1); // true\n * const result2 = isNil(value2); // true\n * const result3 = isNil(value3); // false\n */\nexport function isNil(x: unknown): x is null | undefined {\n return x == null;\n}\n","/**\n * Checks if the given value is not null nor undefined.\n *\n * The main use of this function is to be used with TypeScript as a type predicate.\n *\n * @template T - The type of value.\n * @param {T | null | undefined} x - The value to test if it is not null nor undefined.\n * @returns {x is T} True if the value is not null nor undefined, false otherwise.\n *\n * @example\n * // Here the type of `arr` is (number | undefined)[]\n * const arr = [1, undefined, 3];\n * // Here the type of `result` is number[]\n * const result = arr.filter(isNotNil);\n * // result will be [1, 3]\n */\nexport function isNotNil<T>(x: T | null | undefined): x is T {\n return x !== null && x !== undefined;\n}\n","/**\n * Checks if the given value is null.\n *\n * This function tests whether the provided value is strictly equal to `null`.\n * It returns `true` if the value is `null`, and `false` otherwise.\n *\n * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `null`.\n *\n * @param {unknown} x - The value to test if it is null.\n * @returns {x is null} True if the value is null, false otherwise.\n *\n * @example\n * const value1 = null;\n * const value2 = undefined;\n * const value3 = 42;\n *\n * console.log(isNull(value1)); // true\n * console.log(isNull(value2)); // false\n * console.log(isNull(value3)); // false\n */\nexport function isNull(x: unknown): x is null {\n return x === null;\n}\n","/**\n * Checks if the given value is undefined.\n *\n * This function tests whether the provided value is strictly equal to `undefined`.\n * It returns `true` if the value is `undefined`, and `false` otherwise.\n *\n * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `undefined`.\n *\n * @param {unknown} x - The value to test if it is undefined.\n * @returns {x is undefined} true if the value is undefined, false otherwise.\n *\n * @example\n * const value1 = undefined;\n * const value2 = null;\n * const value3 = 42;\n *\n * console.log(isUndefined(value1)); // true\n * console.log(isUndefined(value2)); // false\n * console.log(isUndefined(value3)); // false\n */\nexport function isUndefined(x: unknown): x is undefined {\n return x === undefined;\n}\n","export function isLength(value: unknown): value is number {\n return typeof value === 'number' && value > -1 && value % 1 === 0 && value <= Number.MAX_SAFE_INTEGER;\n}\n","/**\n * Checks if a given value is a plain object.\n * \n * @param {object} object - The value to check.\n * @returns {boolean} - True if the value is a plain object, otherwise false.\n * \n * @example\n * console.log(isPlainObject({})); // true\n * console.log(isPlainObject([])); // false\n * console.log(isPlainObject(null)); // false\n * console.log(isPlainObject(Object.create(null))); // true\n * console.log(Buffer.from('hello, world')); // false\n */\nexport function isPlainObject(object: object): boolean {\n if (typeof object !== 'object') {\n return false;\n }\n\n if (object == null) {\n return false;\n }\n\n if (Object.getPrototypeOf(object) === null) {\n return true;\n }\n\n if (object.toString() !== '[object Object]') {\n return false;\n }\n\n let proto = object;\n\n while (Object.getPrototypeOf(proto) !== null) {\n proto = Object.getPrototypeOf(proto);\n }\n\n return Object.getPrototypeOf(object) === proto;\n}","/**\n * Checks if `value` is a function.\n *\n * @param {unknown} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a function, else `false`.\n *\n * @example\n * isFunction(Array.prototype.slice); // true\n * isFunction(async function () {}); // true\n * isFunction(function* () {}); // true\n * isFunction(Proxy); // true\n * isFunction(Int8Array); // true\n */\nexport function isFunction(value: unknown): value is (...args: unknown[]) => unknown {\n return typeof value === 'function';\n}\n","import { isLength } from \"./isLength.ts\";\n\n/**\n * Checks if `value` is array-like.\n *\n * @param {unknown} value The value to check.\n * @returns {value is ArrayLike<unknown>} Returns `true` if `value` is array-like, else `false`.\n *\n * @example\n * isArrayLike([1, 2, 3]); // true\n * isArrayLike('abc'); // true\n * isArrayLike({ 0: 'a', length: 1 }); // true\n * isArrayLike({}); // false\n * isArrayLike(null); // false\n * isArrayLike(undefined); // false\n */\nexport function isArrayLike(value: unknown): value is ArrayLike<unknown> {\n return value != null && typeof value !== \"function\" &&\n isLength((value as ArrayLike<unknown>).length);\n}\n","/**\n * Checks if a value is a TypedArray.\n * @param {unknown} x The value to check.\n * @returns {x is\n * | Uint8Array\n * | Uint8ClampedArray\n * | Uint16Array\n * | Uint32Array\n * | BigUint64Array\n * | Int8Array\n * | Int16Array\n * | Int32Array\n * | BigInt64Array\n * | Float32Array\n * | Float64Array} Returns true if `x` is a TypedArray, false otherwise.\n */\nexport function isTypedArray(\n x: unknown\n): x is\n | Uint8Array\n | Uint8ClampedArray\n | Uint16Array\n | Uint32Array\n | BigUint64Array\n | Int8Array\n | Int16Array\n | Int32Array\n | BigInt64Array\n | Float32Array\n | Float64Array {\n return (\n x instanceof Uint8Array ||\n x instanceof Uint8ClampedArray ||\n x instanceof Uint16Array ||\n x instanceof Uint32Array ||\n x instanceof BigUint64Array ||\n x instanceof Int8Array ||\n x instanceof Int16Array ||\n x instanceof Int32Array ||\n x instanceof BigInt64Array ||\n x instanceof Float32Array ||\n x instanceof Float64Array\n );\n}\n","/**\n * Checks whether a value is a JavaScript primitive.\n * JavaScript primitives include null, undefined, strings, numbers, booleans, symbols, and bigints.\n *\n * @param {unknown} x The value to check.\n * @returns {x is\n * | null\n * | undefined\n * | string\n * | number\n * | boolean\n * | symbol\n * | bigint} Returns true if `x` is a primitive, false otherwise.\n */\nexport function isPrimitive(value: unknown): value is null | undefined | string | number | boolean | symbol | bigint {\n return value == null || (typeof value !== 'object' && typeof value !== 'function');\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACeO,SAAS,KAAQ,KAAwB;AAC9C,SAAO,MAAM,KAAK,IAAI,IAAI,GAAG,CAAC;AAChC;;;ACEO,SAAS,MAAS,MAAoB,MAAyB;AACpE,SAAO,KAAK,KAAK,OAAO,IAAI,CAAC;AAC/B;;;ACLO,SAAS,QAAQ,GAAY,GAAqB;AACvD,MAAI,OAAO,GAAG,GAAG,CAAC,GAAG;AACnB,WAAO;AAAA,EACT;AAEA,MAAI,aAAa,QAAQ,aAAa,MAAM;AAC1C,WAAO,EAAE,QAAQ,MAAM,EAAE,QAAQ;AAAA,EACnC;AAEA,MAAI,aAAa,UAAU,aAAa,QAAQ;AAC9C,WAAO,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE;AAAA,EAChD;AAEA,MAAI,OAAO,MAAM,YAAY,OAAO,MAAM,YAAY,MAAM,QAAQ,MAAM,MAAM;AAC9E,WAAO;AAAA,EACT;AAEA,QAAM,QAAQ,OAAO,KAAK,CAAW;AACrC,QAAM,QAAQ,OAAO,KAAK,CAAW;AAErC,MAAI,MAAM,WAAW,MAAM,QAAQ;AACjC,WAAO;AAAA,EACT;AAGA,MAAI,MAAM,OAAO,KAAK,EAAE,WAAW,MAAM,QAAQ;AAC/C,WAAO;AAAA,EACT;AAEA,WAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AACrC,UAAM,UAAU,MAAM,CAAC;AACvB,UAAM,QAAS,EAAU,OAAO;AAChC,UAAM,QAAS,EAAU,OAAO;AAEhC,QAAI,CAAC,QAAQ,OAAO,KAAK,GAAG;AAC1B,aAAO;AAAA,IACT;AAAA,EACF;AAEA,SAAO;AACT;;;ACrCO,SAAS,MAAM,GAAmC;AACvD,SAAO,KAAK;AACd;;;ACLO,SAAS,SAAY,GAAiC;AAC3D,SAAO,MAAM,QAAQ,MAAM;AAC7B;;;ACEO,SAAS,OAAO,GAAuB;AAC5C,SAAO,MAAM;AACf;;;ACFO,SAAS,YAAY,GAA4B;AACtD,SAAO,MAAM;AACf;;;ACtBO,SAAS,SAAS,OAAiC;AACxD,SAAO,OAAO,UAAU,YAAY,QAAQ,MAAM,QAAQ,MAAM,KAAK,SAAS,OAAO;AACvF;;;ACWO,SAAS,cAAc,QAAyB;AACrD,MAAI,OAAO,WAAW,UAAU;AAC9B,WAAO;AAAA,EACT;AAEA,MAAI,UAAU,MAAM;AAClB,WAAO;AAAA,EACT;AAEA,MAAI,OAAO,eAAe,MAAM,MAAM,MAAM;AAC1C,WAAO;AAAA,EACT;AAEA,MAAI,OAAO,SAAS,MAAM,mBAAmB;AAC3C,WAAO;AAAA,EACT;AAEA,MAAI,QAAQ;AAEZ,SAAO,OAAO,eAAe,KAAK,MAAM,MAAM;AAC5C,YAAQ,OAAO,eAAe,KAAK;AAAA,EACrC;AAEA,SAAO,OAAO,eAAe,MAAM,MAAM;AAC3C;;;ACxBO,SAAS,WAAW,OAA0D;AACnF,SAAO,OAAO,UAAU;AAC1B;;;ACCO,SAAS,YAAY,OAA6C;AACvE,SAAO,SAAS,QAAQ,OAAO,UAAU,cACvC,SAAU,MAA6B,MAAM;AACjD;;;ACHO,SAAS,aACd,GAYe;AACf,SACE,aAAa,cACb,aAAa,qBACb,aAAa,eACb,aAAa,eACb,aAAa,kBACb,aAAa,aACb,aAAa,cACb,aAAa,cACb,aAAa,iBACb,aAAa,gBACb,aAAa;AAEjB;;;AC7BO,SAAS,YAAY,OAAyF;AACnH,SAAO,SAAS,QAAS,OAAO,UAAU,YAAY,OAAO,UAAU;AACzE;","names":[]}
@@ -1,4 +1,7 @@
1
- import "../chunk-U4JWMVQK.mjs";
1
+ import "../chunk-YXD3AQAK.mjs";
2
+ import {
3
+ isUndefined
4
+ } from "../chunk-VH2PV426.mjs";
2
5
  import {
3
6
  isFunction
4
7
  } from "../chunk-74CREQXW.mjs";
@@ -12,8 +15,11 @@ import {
12
15
  isNull
13
16
  } from "../chunk-AIRSKN47.mjs";
14
17
  import {
15
- isUndefined
16
- } from "../chunk-VH2PV426.mjs";
18
+ isPrimitive
19
+ } from "../chunk-R6GLTTAB.mjs";
20
+ import {
21
+ isTypedArray
22
+ } from "../chunk-SXFMQQ6F.mjs";
17
23
  import {
18
24
  isArrayLike
19
25
  } from "../chunk-LPZZIY5Z.mjs";
@@ -28,7 +34,7 @@ import {
28
34
  } from "../chunk-MIGAC7F4.mjs";
29
35
  import "../chunk-R6QA7PLZ.mjs";
30
36
  import "../chunk-DVK2N4KC.mjs";
31
- import "../chunk-24FKGR6U.mjs";
37
+ import "../chunk-J5LGTIGS.mjs";
32
38
  export {
33
39
  isArrayLike,
34
40
  isEqual,
@@ -38,6 +44,8 @@ export {
38
44
  isNotNil,
39
45
  isNull,
40
46
  isPlainObject,
47
+ isPrimitive,
48
+ isTypedArray,
41
49
  isUndefined
42
50
  };
43
51
  //# sourceMappingURL=index.mjs.map
@@ -2,7 +2,7 @@ import {
2
2
  isArrayLike
3
3
  } from "../chunk-LPZZIY5Z.mjs";
4
4
  import "../chunk-27QMXBLJ.mjs";
5
- import "../chunk-24FKGR6U.mjs";
5
+ import "../chunk-J5LGTIGS.mjs";
6
6
  export {
7
7
  isArrayLike
8
8
  };
@@ -3,7 +3,7 @@ import {
3
3
  } from "../chunk-JYSV56US.mjs";
4
4
  import "../chunk-R6QA7PLZ.mjs";
5
5
  import "../chunk-DVK2N4KC.mjs";
6
- import "../chunk-24FKGR6U.mjs";
6
+ import "../chunk-J5LGTIGS.mjs";
7
7
  export {
8
8
  isEqual
9
9
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  isFunction
3
3
  } from "../chunk-74CREQXW.mjs";
4
- import "../chunk-24FKGR6U.mjs";
4
+ import "../chunk-J5LGTIGS.mjs";
5
5
  export {
6
6
  isFunction
7
7
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  isLength
3
3
  } from "../chunk-27QMXBLJ.mjs";
4
- import "../chunk-24FKGR6U.mjs";
4
+ import "../chunk-J5LGTIGS.mjs";
5
5
  export {
6
6
  isLength
7
7
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  isNil
3
3
  } from "../chunk-WMM7TZLG.mjs";
4
- import "../chunk-24FKGR6U.mjs";
4
+ import "../chunk-J5LGTIGS.mjs";
5
5
  export {
6
6
  isNil
7
7
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  isNotNil
3
3
  } from "../chunk-BMRTZMRE.mjs";
4
- import "../chunk-24FKGR6U.mjs";
4
+ import "../chunk-J5LGTIGS.mjs";
5
5
  export {
6
6
  isNotNil
7
7
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  isNull
3
3
  } from "../chunk-AIRSKN47.mjs";
4
- import "../chunk-24FKGR6U.mjs";
4
+ import "../chunk-J5LGTIGS.mjs";
5
5
  export {
6
6
  isNull
7
7
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  isPlainObject
3
3
  } from "../chunk-MIGAC7F4.mjs";
4
- import "../chunk-24FKGR6U.mjs";
4
+ import "../chunk-J5LGTIGS.mjs";
5
5
  export {
6
6
  isPlainObject
7
7
  };
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Checks whether a value is a JavaScript primitive.
3
+ * JavaScript primitives include null, undefined, strings, numbers, booleans, symbols, and bigints.
4
+ *
5
+ * @param {unknown} x The value to check.
6
+ * @returns {x is
7
+ * | null
8
+ * | undefined
9
+ * | string
10
+ * | number
11
+ * | boolean
12
+ * | symbol
13
+ * | bigint} Returns true if `x` is a primitive, false otherwise.
14
+ */
15
+ declare function isPrimitive(value: unknown): value is null | undefined | string | number | boolean | symbol | bigint;
16
+
17
+ export { isPrimitive };
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Checks whether a value is a JavaScript primitive.
3
+ * JavaScript primitives include null, undefined, strings, numbers, booleans, symbols, and bigints.
4
+ *
5
+ * @param {unknown} x The value to check.
6
+ * @returns {x is
7
+ * | null
8
+ * | undefined
9
+ * | string
10
+ * | number
11
+ * | boolean
12
+ * | symbol
13
+ * | bigint} Returns true if `x` is a primitive, false otherwise.
14
+ */
15
+ declare function isPrimitive(value: unknown): value is null | undefined | string | number | boolean | symbol | bigint;
16
+
17
+ export { isPrimitive };
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/predicate/isPrimitive.ts
21
+ var isPrimitive_exports = {};
22
+ __export(isPrimitive_exports, {
23
+ isPrimitive: () => isPrimitive
24
+ });
25
+ module.exports = __toCommonJS(isPrimitive_exports);
26
+ function isPrimitive(value) {
27
+ return value == null || typeof value !== "object" && typeof value !== "function";
28
+ }
29
+ // Annotate the CommonJS export names for ESM import in node:
30
+ 0 && (module.exports = {
31
+ isPrimitive
32
+ });
33
+ //# sourceMappingURL=isPrimitive.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/predicate/isPrimitive.ts"],"sourcesContent":["/**\n * Checks whether a value is a JavaScript primitive.\n * JavaScript primitives include null, undefined, strings, numbers, booleans, symbols, and bigints.\n *\n * @param {unknown} x The value to check.\n * @returns {x is\n * | null\n * | undefined\n * | string\n * | number\n * | boolean\n * | symbol\n * | bigint} Returns true if `x` is a primitive, false otherwise.\n */\nexport function isPrimitive(value: unknown): value is null | undefined | string | number | boolean | symbol | bigint {\n return value == null || (typeof value !== 'object' && typeof value !== 'function');\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAcO,SAAS,YAAY,OAAyF;AACnH,SAAO,SAAS,QAAS,OAAO,UAAU,YAAY,OAAO,UAAU;AACzE;","names":[]}
@@ -0,0 +1,8 @@
1
+ import {
2
+ isPrimitive
3
+ } from "../chunk-R6GLTTAB.mjs";
4
+ import "../chunk-J5LGTIGS.mjs";
5
+ export {
6
+ isPrimitive
7
+ };
8
+ //# sourceMappingURL=isPrimitive.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Checks if a value is a TypedArray.
3
+ * @param {unknown} x The value to check.
4
+ * @returns {x is
5
+ * | Uint8Array
6
+ * | Uint8ClampedArray
7
+ * | Uint16Array
8
+ * | Uint32Array
9
+ * | BigUint64Array
10
+ * | Int8Array
11
+ * | Int16Array
12
+ * | Int32Array
13
+ * | BigInt64Array
14
+ * | Float32Array
15
+ * | Float64Array} Returns true if `x` is a TypedArray, false otherwise.
16
+ */
17
+ declare function isTypedArray(x: unknown): x is Uint8Array | Uint8ClampedArray | Uint16Array | Uint32Array | BigUint64Array | Int8Array | Int16Array | Int32Array | BigInt64Array | Float32Array | Float64Array;
18
+
19
+ export { isTypedArray };
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Checks if a value is a TypedArray.
3
+ * @param {unknown} x The value to check.
4
+ * @returns {x is
5
+ * | Uint8Array
6
+ * | Uint8ClampedArray
7
+ * | Uint16Array
8
+ * | Uint32Array
9
+ * | BigUint64Array
10
+ * | Int8Array
11
+ * | Int16Array
12
+ * | Int32Array
13
+ * | BigInt64Array
14
+ * | Float32Array
15
+ * | Float64Array} Returns true if `x` is a TypedArray, false otherwise.
16
+ */
17
+ declare function isTypedArray(x: unknown): x is Uint8Array | Uint8ClampedArray | Uint16Array | Uint32Array | BigUint64Array | Int8Array | Int16Array | Int32Array | BigInt64Array | Float32Array | Float64Array;
18
+
19
+ export { isTypedArray };
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/predicate/isTypedArray.ts
21
+ var isTypedArray_exports = {};
22
+ __export(isTypedArray_exports, {
23
+ isTypedArray: () => isTypedArray
24
+ });
25
+ module.exports = __toCommonJS(isTypedArray_exports);
26
+ function isTypedArray(x) {
27
+ return x instanceof Uint8Array || x instanceof Uint8ClampedArray || x instanceof Uint16Array || x instanceof Uint32Array || x instanceof BigUint64Array || x instanceof Int8Array || x instanceof Int16Array || x instanceof Int32Array || x instanceof BigInt64Array || x instanceof Float32Array || x instanceof Float64Array;
28
+ }
29
+ // Annotate the CommonJS export names for ESM import in node:
30
+ 0 && (module.exports = {
31
+ isTypedArray
32
+ });
33
+ //# sourceMappingURL=isTypedArray.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/predicate/isTypedArray.ts"],"sourcesContent":["/**\n * Checks if a value is a TypedArray.\n * @param {unknown} x The value to check.\n * @returns {x is\n * | Uint8Array\n * | Uint8ClampedArray\n * | Uint16Array\n * | Uint32Array\n * | BigUint64Array\n * | Int8Array\n * | Int16Array\n * | Int32Array\n * | BigInt64Array\n * | Float32Array\n * | Float64Array} Returns true if `x` is a TypedArray, false otherwise.\n */\nexport function isTypedArray(\n x: unknown\n): x is\n | Uint8Array\n | Uint8ClampedArray\n | Uint16Array\n | Uint32Array\n | BigUint64Array\n | Int8Array\n | Int16Array\n | Int32Array\n | BigInt64Array\n | Float32Array\n | Float64Array {\n return (\n x instanceof Uint8Array ||\n x instanceof Uint8ClampedArray ||\n x instanceof Uint16Array ||\n x instanceof Uint32Array ||\n x instanceof BigUint64Array ||\n x instanceof Int8Array ||\n x instanceof Int16Array ||\n x instanceof Int32Array ||\n x instanceof BigInt64Array ||\n x instanceof Float32Array ||\n x instanceof Float64Array\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBO,SAAS,aACd,GAYe;AACf,SACE,aAAa,cACb,aAAa,qBACb,aAAa,eACb,aAAa,eACb,aAAa,kBACb,aAAa,aACb,aAAa,cACb,aAAa,cACb,aAAa,iBACb,aAAa,gBACb,aAAa;AAEjB;","names":[]}
@@ -0,0 +1,8 @@
1
+ import {
2
+ isTypedArray
3
+ } from "../chunk-SXFMQQ6F.mjs";
4
+ import "../chunk-J5LGTIGS.mjs";
5
+ export {
6
+ isTypedArray
7
+ };
8
+ //# sourceMappingURL=isTypedArray.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  isUndefined
3
3
  } from "../chunk-VH2PV426.mjs";
4
- import "../chunk-24FKGR6U.mjs";
4
+ import "../chunk-J5LGTIGS.mjs";
5
5
  export {
6
6
  isUndefined
7
7
  };
@@ -42,11 +42,11 @@ function delay(ms, { signal } = {}) {
42
42
  clearTimeout(timeoutId);
43
43
  abortError();
44
44
  };
45
- if (signal == null ? void 0 : signal.aborted) {
45
+ if (signal?.aborted) {
46
46
  return abortError();
47
47
  }
48
48
  const timeoutId = setTimeout(resolve, ms);
49
- signal == null ? void 0 : signal.addEventListener("abort", abortHandler, { once: true });
49
+ signal?.addEventListener("abort", abortHandler, { once: true });
50
50
  });
51
51
  }
52
52
  // Annotate the CommonJS export names for ESM import in node:
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/promise/delay.ts","../../src/error/AbortError.ts"],"sourcesContent":["import { AbortError } from '../error/AbortError.ts';\n\ninterface DelayOptions {\n signal?: AbortSignal;\n}\n\n/**\n * Delays the execution of code for a specified number of milliseconds.\n *\n * This function returns a Promise that resolves after the specified delay, allowing you to use it\n * with async/await to pause execution.\n *\n * @param {number} ms - The number of milliseconds to delay.\n * @param {DelayOptions} options - The options object.\n * @param {AbortSignal} options.signal - An optional AbortSignal to cancel the delay.\n * @returns {Promise<void>} A Promise that resolves after the specified delay.\n *\n * @example\n * async function foo() {\n * console.log('Start');\n * await delay(1000); // Delays execution for 1 second\n * console.log('End');\n * }\n *\n * foo();\n *\n * // With AbortSignal\n * const controller = new AbortController();\n * const { signal } = controller;\n *\n * setTimeout(() => controller.abort(), 50); // Will cancel the delay after 50ms\n * try {\n * await delay(100, { signal });\n * } catch (error) {\n * console.error(error); // Will log 'AbortError'\n * }\n * }\n */\nexport function delay(ms: number, { signal }: DelayOptions = {}): Promise<void> {\n return new Promise((resolve, reject) => {\n const abortError = () => {\n reject(new AbortError());\n };\n\n const abortHandler = () => {\n clearTimeout(timeoutId);\n abortError();\n };\n\n if (signal?.aborted) {\n return abortError();\n }\n\n const timeoutId = setTimeout(resolve, ms);\n\n signal?.addEventListener('abort', abortHandler, { once: true });\n });\n}\n","/**\n * An error class representing an aborted operation.\n * @augments Error\n */\nexport class AbortError extends Error {\n constructor(message = 'The operation was aborted') {\n super(message);\n this.name = 'AbortError';\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACIO,IAAM,aAAN,cAAyB,MAAM;AAAA,EACpC,YAAY,UAAU,6BAA6B;AACjD,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;;;AD6BO,SAAS,MAAM,IAAY,EAAE,OAAO,IAAkB,CAAC,GAAkB;AAC9E,SAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtC,UAAM,aAAa,MAAM;AACvB,aAAO,IAAI,WAAW,CAAC;AAAA,IACzB;AAEA,UAAM,eAAe,MAAM;AACzB,mBAAa,SAAS;AACtB,iBAAW;AAAA,IACb;AAEA,QAAI,iCAAQ,SAAS;AACnB,aAAO,WAAW;AAAA,IACpB;AAEA,UAAM,YAAY,WAAW,SAAS,EAAE;AAExC,qCAAQ,iBAAiB,SAAS,cAAc,EAAE,MAAM,KAAK;AAAA,EAC/D,CAAC;AACH;","names":[]}
1
+ {"version":3,"sources":["../../src/promise/delay.ts","../../src/error/AbortError.ts"],"sourcesContent":["import { AbortError } from '../error/AbortError.ts';\n\ninterface DelayOptions {\n signal?: AbortSignal;\n}\n\n/**\n * Delays the execution of code for a specified number of milliseconds.\n *\n * This function returns a Promise that resolves after the specified delay, allowing you to use it\n * with async/await to pause execution.\n *\n * @param {number} ms - The number of milliseconds to delay.\n * @param {DelayOptions} options - The options object.\n * @param {AbortSignal} options.signal - An optional AbortSignal to cancel the delay.\n * @returns {Promise<void>} A Promise that resolves after the specified delay.\n *\n * @example\n * async function foo() {\n * console.log('Start');\n * await delay(1000); // Delays execution for 1 second\n * console.log('End');\n * }\n *\n * foo();\n *\n * // With AbortSignal\n * const controller = new AbortController();\n * const { signal } = controller;\n *\n * setTimeout(() => controller.abort(), 50); // Will cancel the delay after 50ms\n * try {\n * await delay(100, { signal });\n * } catch (error) {\n * console.error(error); // Will log 'AbortError'\n * }\n * }\n */\nexport function delay(ms: number, { signal }: DelayOptions = {}): Promise<void> {\n return new Promise((resolve, reject) => {\n const abortError = () => {\n reject(new AbortError());\n };\n\n const abortHandler = () => {\n clearTimeout(timeoutId);\n abortError();\n };\n\n if (signal?.aborted) {\n return abortError();\n }\n\n const timeoutId = setTimeout(resolve, ms);\n\n signal?.addEventListener('abort', abortHandler, { once: true });\n });\n}\n","/**\n * An error class representing an aborted operation.\n * @augments Error\n */\nexport class AbortError extends Error {\n constructor(message = 'The operation was aborted') {\n super(message);\n this.name = 'AbortError';\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACIO,IAAM,aAAN,cAAyB,MAAM;AAAA,EACpC,YAAY,UAAU,6BAA6B;AACjD,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;;;AD6BO,SAAS,MAAM,IAAY,EAAE,OAAO,IAAkB,CAAC,GAAkB;AAC9E,SAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtC,UAAM,aAAa,MAAM;AACvB,aAAO,IAAI,WAAW,CAAC;AAAA,IACzB;AAEA,UAAM,eAAe,MAAM;AACzB,mBAAa,SAAS;AACtB,iBAAW;AAAA,IACb;AAEA,QAAI,QAAQ,SAAS;AACnB,aAAO,WAAW;AAAA,IACpB;AAEA,UAAM,YAAY,WAAW,SAAS,EAAE;AAExC,YAAQ,iBAAiB,SAAS,cAAc,EAAE,MAAM,KAAK,CAAC;AAAA,EAChE,CAAC;AACH;","names":[]}
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  delay
3
- } from "../chunk-O64NE2P4.mjs";
3
+ } from "../chunk-4DFAGGIM.mjs";
4
4
  import "../chunk-DXB7EZUQ.mjs";
5
- import "../chunk-24FKGR6U.mjs";
5
+ import "../chunk-J5LGTIGS.mjs";
6
6
  export {
7
7
  delay
8
8
  };
@@ -16,26 +16,6 @@ var __copyProps = (to, from, except, desc) => {
16
16
  return to;
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var __async = (__this, __arguments, generator) => {
20
- return new Promise((resolve, reject) => {
21
- var fulfilled = (value) => {
22
- try {
23
- step(generator.next(value));
24
- } catch (e) {
25
- reject(e);
26
- }
27
- };
28
- var rejected = (value) => {
29
- try {
30
- step(generator.throw(value));
31
- } catch (e) {
32
- reject(e);
33
- }
34
- };
35
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
36
- step((generator = generator.apply(__this, __arguments)).next());
37
- });
38
- };
39
19
 
40
20
  // src/promise/index.ts
41
21
  var promise_exports = {};
@@ -63,11 +43,11 @@ function delay(ms, { signal } = {}) {
63
43
  clearTimeout(timeoutId);
64
44
  abortError();
65
45
  };
66
- if (signal == null ? void 0 : signal.aborted) {
46
+ if (signal?.aborted) {
67
47
  return abortError();
68
48
  }
69
49
  const timeoutId = setTimeout(resolve, ms);
70
- signal == null ? void 0 : signal.addEventListener("abort", abortHandler, { once: true });
50
+ signal?.addEventListener("abort", abortHandler, { once: true });
71
51
  });
72
52
  }
73
53
 
@@ -80,18 +60,14 @@ var TimeoutError = class extends Error {
80
60
  };
81
61
 
82
62
  // src/promise/timeout.ts
83
- function timeout(ms) {
84
- return __async(this, null, function* () {
85
- yield delay(ms);
86
- throw new TimeoutError();
87
- });
63
+ async function timeout(ms) {
64
+ await delay(ms);
65
+ throw new TimeoutError();
88
66
  }
89
67
 
90
68
  // src/promise/withTimeout.ts
91
- function withTimeout(run, ms) {
92
- return __async(this, null, function* () {
93
- return Promise.race([run(), timeout(ms)]);
94
- });
69
+ async function withTimeout(run, ms) {
70
+ return Promise.race([run(), timeout(ms)]);
95
71
  }
96
72
  // Annotate the CommonJS export names for ESM import in node:
97
73
  0 && (module.exports = {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/promise/index.ts","../../src/error/AbortError.ts","../../src/promise/delay.ts","../../src/error/TimeoutError.ts","../../src/promise/timeout.ts","../../src/promise/withTimeout.ts"],"sourcesContent":["export { delay } from './delay.ts';\nexport { withTimeout } from './withTimeout.ts';\n","/**\n * An error class representing an aborted operation.\n * @augments Error\n */\nexport class AbortError extends Error {\n constructor(message = 'The operation was aborted') {\n super(message);\n this.name = 'AbortError';\n }\n}\n","import { AbortError } from '../error/AbortError.ts';\n\ninterface DelayOptions {\n signal?: AbortSignal;\n}\n\n/**\n * Delays the execution of code for a specified number of milliseconds.\n *\n * This function returns a Promise that resolves after the specified delay, allowing you to use it\n * with async/await to pause execution.\n *\n * @param {number} ms - The number of milliseconds to delay.\n * @param {DelayOptions} options - The options object.\n * @param {AbortSignal} options.signal - An optional AbortSignal to cancel the delay.\n * @returns {Promise<void>} A Promise that resolves after the specified delay.\n *\n * @example\n * async function foo() {\n * console.log('Start');\n * await delay(1000); // Delays execution for 1 second\n * console.log('End');\n * }\n *\n * foo();\n *\n * // With AbortSignal\n * const controller = new AbortController();\n * const { signal } = controller;\n *\n * setTimeout(() => controller.abort(), 50); // Will cancel the delay after 50ms\n * try {\n * await delay(100, { signal });\n * } catch (error) {\n * console.error(error); // Will log 'AbortError'\n * }\n * }\n */\nexport function delay(ms: number, { signal }: DelayOptions = {}): Promise<void> {\n return new Promise((resolve, reject) => {\n const abortError = () => {\n reject(new AbortError());\n };\n\n const abortHandler = () => {\n clearTimeout(timeoutId);\n abortError();\n };\n\n if (signal?.aborted) {\n return abortError();\n }\n\n const timeoutId = setTimeout(resolve, ms);\n\n signal?.addEventListener('abort', abortHandler, { once: true });\n });\n}\n","/**\n * An error class representing an timeout operation.\n * @augments Error\n */\nexport class TimeoutError extends Error {\n constructor(message = 'The operation was timed out') {\n super(message);\n this.name = 'TimeoutError';\n }\n}\n","import { delay } from './delay.ts';\nimport { TimeoutError } from '../error/TimeoutError.ts';\n\n/**\n * Returns a promise that rejects with a `TimeoutError` after a specified delay.\n *\n * @param {number} ms - The delay duration in milliseconds.\n * @returns {Promise<void>} A promise that rejects with a `TimeoutError` after the specified delay.\n * @throws {TimeoutError} Throws a `TimeoutError` after the specified delay.\n */\nexport async function timeout(ms: number): Promise<never> {\n await delay(ms);\n throw new TimeoutError();\n}\n","import { timeout } from './timeout.ts';\n\n/**\n * Executes an async function and enforces a timeout. \n * \n * If the promise does not resolve within the specified time,\n * the timeout will trigger and the returned promise will be rejected.\n *\n *\n * @template T \n * @param {() => Promise<T>} run - A function that returns a promise to be executed.\n * @param {number} ms - The timeout duration in milliseconds.\n * @returns {Promise<T>} A promise that resolves with the result of the `run` function or rejects if the timeout is reached.\n *\n * @example\n * try {\n * await withTimeout(() => {}, 1000); // Timeout exception after 1 second\n * } catch (error) {\n * console.error(error); // Will log 'TimeoutError'\n * }\n */\nexport async function withTimeout<T>(run: () => Promise<T>, ms: number): Promise<T> {\n return Promise.race([run(), timeout(ms) as T]);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACIO,IAAM,aAAN,cAAyB,MAAM;AAAA,EACpC,YAAY,UAAU,6BAA6B;AACjD,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;;;AC6BO,SAAS,MAAM,IAAY,EAAE,OAAO,IAAkB,CAAC,GAAkB;AAC9E,SAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtC,UAAM,aAAa,MAAM;AACvB,aAAO,IAAI,WAAW,CAAC;AAAA,IACzB;AAEA,UAAM,eAAe,MAAM;AACzB,mBAAa,SAAS;AACtB,iBAAW;AAAA,IACb;AAEA,QAAI,iCAAQ,SAAS;AACnB,aAAO,WAAW;AAAA,IACpB;AAEA,UAAM,YAAY,WAAW,SAAS,EAAE;AAExC,qCAAQ,iBAAiB,SAAS,cAAc,EAAE,MAAM,KAAK;AAAA,EAC/D,CAAC;AACH;;;ACrDO,IAAM,eAAN,cAA2B,MAAM;AAAA,EACtC,YAAY,UAAU,+BAA+B;AACnD,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;;;ACCA,SAAsB,QAAQ,IAA4B;AAAA;AACxD,UAAM,MAAM,EAAE;AACd,UAAM,IAAI,aAAa;AAAA,EACzB;AAAA;;;ACQA,SAAsB,YAAe,KAAuB,IAAwB;AAAA;AAClF,WAAO,QAAQ,KAAK,CAAC,IAAI,GAAG,QAAQ,EAAE,CAAM,CAAC;AAAA,EAC/C;AAAA;","names":[]}
1
+ {"version":3,"sources":["../../src/promise/index.ts","../../src/error/AbortError.ts","../../src/promise/delay.ts","../../src/error/TimeoutError.ts","../../src/promise/timeout.ts","../../src/promise/withTimeout.ts"],"sourcesContent":["export { delay } from './delay.ts';\nexport { withTimeout } from './withTimeout.ts';\n","/**\n * An error class representing an aborted operation.\n * @augments Error\n */\nexport class AbortError extends Error {\n constructor(message = 'The operation was aborted') {\n super(message);\n this.name = 'AbortError';\n }\n}\n","import { AbortError } from '../error/AbortError.ts';\n\ninterface DelayOptions {\n signal?: AbortSignal;\n}\n\n/**\n * Delays the execution of code for a specified number of milliseconds.\n *\n * This function returns a Promise that resolves after the specified delay, allowing you to use it\n * with async/await to pause execution.\n *\n * @param {number} ms - The number of milliseconds to delay.\n * @param {DelayOptions} options - The options object.\n * @param {AbortSignal} options.signal - An optional AbortSignal to cancel the delay.\n * @returns {Promise<void>} A Promise that resolves after the specified delay.\n *\n * @example\n * async function foo() {\n * console.log('Start');\n * await delay(1000); // Delays execution for 1 second\n * console.log('End');\n * }\n *\n * foo();\n *\n * // With AbortSignal\n * const controller = new AbortController();\n * const { signal } = controller;\n *\n * setTimeout(() => controller.abort(), 50); // Will cancel the delay after 50ms\n * try {\n * await delay(100, { signal });\n * } catch (error) {\n * console.error(error); // Will log 'AbortError'\n * }\n * }\n */\nexport function delay(ms: number, { signal }: DelayOptions = {}): Promise<void> {\n return new Promise((resolve, reject) => {\n const abortError = () => {\n reject(new AbortError());\n };\n\n const abortHandler = () => {\n clearTimeout(timeoutId);\n abortError();\n };\n\n if (signal?.aborted) {\n return abortError();\n }\n\n const timeoutId = setTimeout(resolve, ms);\n\n signal?.addEventListener('abort', abortHandler, { once: true });\n });\n}\n","/**\n * An error class representing an timeout operation.\n * @augments Error\n */\nexport class TimeoutError extends Error {\n constructor(message = 'The operation was timed out') {\n super(message);\n this.name = 'TimeoutError';\n }\n}\n","import { delay } from './delay.ts';\nimport { TimeoutError } from '../error/TimeoutError.ts';\n\n/**\n * Returns a promise that rejects with a `TimeoutError` after a specified delay.\n *\n * @param {number} ms - The delay duration in milliseconds.\n * @returns {Promise<void>} A promise that rejects with a `TimeoutError` after the specified delay.\n * @throws {TimeoutError} Throws a `TimeoutError` after the specified delay.\n */\nexport async function timeout(ms: number): Promise<never> {\n await delay(ms);\n throw new TimeoutError();\n}\n","import { timeout } from './timeout.ts';\n\n/**\n * Executes an async function and enforces a timeout. \n * \n * If the promise does not resolve within the specified time,\n * the timeout will trigger and the returned promise will be rejected.\n *\n *\n * @template T \n * @param {() => Promise<T>} run - A function that returns a promise to be executed.\n * @param {number} ms - The timeout duration in milliseconds.\n * @returns {Promise<T>} A promise that resolves with the result of the `run` function or rejects if the timeout is reached.\n *\n * @example\n * try {\n * await withTimeout(() => {}, 1000); // Timeout exception after 1 second\n * } catch (error) {\n * console.error(error); // Will log 'TimeoutError'\n * }\n */\nexport async function withTimeout<T>(run: () => Promise<T>, ms: number): Promise<T> {\n return Promise.race([run(), timeout(ms) as T]);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACIO,IAAM,aAAN,cAAyB,MAAM;AAAA,EACpC,YAAY,UAAU,6BAA6B;AACjD,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;;;AC6BO,SAAS,MAAM,IAAY,EAAE,OAAO,IAAkB,CAAC,GAAkB;AAC9E,SAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtC,UAAM,aAAa,MAAM;AACvB,aAAO,IAAI,WAAW,CAAC;AAAA,IACzB;AAEA,UAAM,eAAe,MAAM;AACzB,mBAAa,SAAS;AACtB,iBAAW;AAAA,IACb;AAEA,QAAI,QAAQ,SAAS;AACnB,aAAO,WAAW;AAAA,IACpB;AAEA,UAAM,YAAY,WAAW,SAAS,EAAE;AAExC,YAAQ,iBAAiB,SAAS,cAAc,EAAE,MAAM,KAAK,CAAC;AAAA,EAChE,CAAC;AACH;;;ACrDO,IAAM,eAAN,cAA2B,MAAM;AAAA,EACtC,YAAY,UAAU,+BAA+B;AACnD,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;;;ACCA,eAAsB,QAAQ,IAA4B;AACxD,QAAM,MAAM,EAAE;AACd,QAAM,IAAI,aAAa;AACzB;;;ACQA,eAAsB,YAAe,KAAuB,IAAwB;AAClF,SAAO,QAAQ,KAAK,CAAC,IAAI,GAAG,QAAQ,EAAE,CAAM,CAAC;AAC/C;","names":[]}
@@ -1,14 +1,14 @@
1
1
  import "../chunk-4OIZM4HS.mjs";
2
2
  import {
3
3
  withTimeout
4
- } from "../chunk-IIDZ3KAJ.mjs";
5
- import "../chunk-CVVZHOJX.mjs";
4
+ } from "../chunk-ZPNX2QDE.mjs";
5
+ import "../chunk-EZYYB34V.mjs";
6
6
  import {
7
7
  delay
8
- } from "../chunk-O64NE2P4.mjs";
8
+ } from "../chunk-4DFAGGIM.mjs";
9
9
  import "../chunk-DXB7EZUQ.mjs";
10
10
  import "../chunk-KIOYQRMQ.mjs";
11
- import "../chunk-24FKGR6U.mjs";
11
+ import "../chunk-J5LGTIGS.mjs";
12
12
  export {
13
13
  delay,
14
14
  withTimeout
@@ -16,26 +16,6 @@ var __copyProps = (to, from, except, desc) => {
16
16
  return to;
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var __async = (__this, __arguments, generator) => {
20
- return new Promise((resolve, reject) => {
21
- var fulfilled = (value) => {
22
- try {
23
- step(generator.next(value));
24
- } catch (e) {
25
- reject(e);
26
- }
27
- };
28
- var rejected = (value) => {
29
- try {
30
- step(generator.throw(value));
31
- } catch (e) {
32
- reject(e);
33
- }
34
- };
35
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
36
- step((generator = generator.apply(__this, __arguments)).next());
37
- });
38
- };
39
19
 
40
20
  // src/promise/timeout.ts
41
21
  var timeout_exports = {};
@@ -62,11 +42,11 @@ function delay(ms, { signal } = {}) {
62
42
  clearTimeout(timeoutId);
63
43
  abortError();
64
44
  };
65
- if (signal == null ? void 0 : signal.aborted) {
45
+ if (signal?.aborted) {
66
46
  return abortError();
67
47
  }
68
48
  const timeoutId = setTimeout(resolve, ms);
69
- signal == null ? void 0 : signal.addEventListener("abort", abortHandler, { once: true });
49
+ signal?.addEventListener("abort", abortHandler, { once: true });
70
50
  });
71
51
  }
72
52
 
@@ -79,11 +59,9 @@ var TimeoutError = class extends Error {
79
59
  };
80
60
 
81
61
  // src/promise/timeout.ts
82
- function timeout(ms) {
83
- return __async(this, null, function* () {
84
- yield delay(ms);
85
- throw new TimeoutError();
86
- });
62
+ async function timeout(ms) {
63
+ await delay(ms);
64
+ throw new TimeoutError();
87
65
  }
88
66
  // Annotate the CommonJS export names for ESM import in node:
89
67
  0 && (module.exports = {