@koine/utils 2.0.0-beta.80 → 2.0.0-beta.83

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 (354) hide show
  1. package/Defer.cjs.js +20 -10
  2. package/Defer.esm.js +20 -10
  3. package/Emitter.cjs.js +18 -19
  4. package/Emitter.d.ts +1 -1
  5. package/Emitter.esm.js +18 -19
  6. package/accentsSets.cjs.d.ts +2 -0
  7. package/accentsSets.cjs.default.js +1 -0
  8. package/accentsSets.cjs.js +20 -0
  9. package/accentsSets.cjs.mjs +2 -0
  10. package/accentsSets.esm.js +15 -0
  11. package/addOrReplaceAtIdx.cjs.js +7 -14
  12. package/addOrReplaceAtIdx.esm.js +7 -14
  13. package/areEqual.cjs.js +28 -43
  14. package/areEqual.esm.js +28 -43
  15. package/arrayFilterFalsy.cjs.js +6 -1
  16. package/arrayFilterFalsy.d.ts +1 -1
  17. package/arrayFilterFalsy.esm.js +6 -1
  18. package/arrayFindLastIndex.cjs.js +13 -8
  19. package/arrayFindLastIndex.d.ts +1 -1
  20. package/arrayFindLastIndex.esm.js +13 -8
  21. package/arrayOfAll.cjs.js +16 -1
  22. package/arrayOfAll.esm.js +16 -1
  23. package/arraySum.cjs.js +6 -1
  24. package/arraySum.esm.js +6 -1
  25. package/arrayToLookup.cjs.js +5 -4
  26. package/arrayToLookup.esm.js +5 -4
  27. package/arrayUniqueByProperties.cjs.js +8 -1
  28. package/arrayUniqueByProperties.esm.js +8 -1
  29. package/buildUrlQueryString.cjs.js +10 -17
  30. package/buildUrlQueryString.esm.js +10 -17
  31. package/capitalize.cjs.js +7 -2
  32. package/capitalize.d.ts +1 -1
  33. package/capitalize.esm.js +7 -2
  34. package/changeCaseCamel.cjs.js +7 -17
  35. package/changeCaseCamel.esm.js +7 -17
  36. package/changeCaseCapital.cjs.js +7 -10
  37. package/changeCaseCapital.esm.js +7 -10
  38. package/changeCaseConstant.cjs.js +7 -6
  39. package/changeCaseConstant.esm.js +7 -6
  40. package/changeCaseDot.cjs.js +7 -1
  41. package/changeCaseDot.esm.js +7 -1
  42. package/changeCaseHelpers.cjs.js +32 -71
  43. package/changeCaseHelpers.esm.js +32 -71
  44. package/changeCaseKebab.cjs.js +7 -1
  45. package/changeCaseKebab.esm.js +7 -1
  46. package/changeCaseNone.cjs.js +7 -6
  47. package/changeCaseNone.esm.js +7 -6
  48. package/changeCasePascal.cjs.js +7 -9
  49. package/changeCasePascal.esm.js +7 -9
  50. package/changeCasePascalSnake.cjs.js +7 -1
  51. package/changeCasePascalSnake.esm.js +7 -1
  52. package/changeCasePath.cjs.js +7 -1
  53. package/changeCasePath.esm.js +7 -1
  54. package/changeCaseSentence.cjs.js +7 -15
  55. package/changeCaseSentence.esm.js +8 -16
  56. package/changeCaseSnake.cjs.js +7 -1
  57. package/changeCaseSnake.esm.js +7 -1
  58. package/changeCaseTrain.cjs.js +7 -1
  59. package/changeCaseTrain.esm.js +7 -1
  60. package/chunkByChunks.cjs.js +5 -31
  61. package/chunkByChunks.esm.js +5 -31
  62. package/chunkBySize.cjs.js +4 -7
  63. package/chunkBySize.esm.js +4 -7
  64. package/clamp.cjs.js +6 -1
  65. package/clamp.esm.js +6 -1
  66. package/clsx.cjs.js +8 -39
  67. package/clsx.esm.js +8 -39
  68. package/convertRange.cjs.js +14 -1
  69. package/convertRange.esm.js +14 -1
  70. package/cookie.cjs.js +44 -1
  71. package/cookie.esm.js +44 -1
  72. package/createPalette.cjs.js +17 -11
  73. package/createPalette.esm.js +17 -11
  74. package/debounce.cjs.js +7 -17
  75. package/debounce.esm.js +7 -17
  76. package/debouncePromise.cjs.js +16 -51
  77. package/debouncePromise.esm.js +16 -51
  78. package/debounceRaf.cjs.js +10 -12
  79. package/debounceRaf.esm.js +10 -12
  80. package/decode.cjs.js +4 -1
  81. package/decode.esm.js +4 -1
  82. package/encode.cjs.js +4 -1
  83. package/encode.esm.js +4 -1
  84. package/ensureInt.cjs.js +5 -1
  85. package/ensureInt.esm.js +5 -1
  86. package/errorToString.cjs.js +6 -1
  87. package/errorToString.esm.js +6 -1
  88. package/escapeRegExp.cjs.js +7 -1
  89. package/escapeRegExp.esm.js +7 -1
  90. package/findDuplicatedIndexes.cjs.js +3 -10
  91. package/findDuplicatedIndexes.esm.js +3 -10
  92. package/forin.cjs.js +6 -5
  93. package/forin.esm.js +6 -5
  94. package/gbToBytes.cjs.js +5 -1
  95. package/gbToBytes.esm.js +5 -1
  96. package/getEmptyArray.cjs.js +6 -3
  97. package/getEmptyArray.esm.js +6 -3
  98. package/getKeys.cjs.js +8 -1
  99. package/getKeys.d.ts +1 -1
  100. package/getKeys.esm.js +8 -1
  101. package/getMediaQueryWidthResolvers.cjs.js +27 -41
  102. package/getMediaQueryWidthResolvers.esm.js +27 -41
  103. package/getMediaQueryWidthTailwindScreens.cjs.js +6 -25
  104. package/getMediaQueryWidthTailwindScreens.esm.js +6 -25
  105. package/getNonce.cjs.js +4 -1
  106. package/getNonce.esm.js +4 -1
  107. package/getParamAmong.cjs.js +11 -4
  108. package/getParamAmong.esm.js +11 -4
  109. package/getParamAsInt.cjs.js +10 -7
  110. package/getParamAsInt.esm.js +10 -7
  111. package/getParamAsString.cjs.js +9 -1
  112. package/getParamAsString.esm.js +9 -1
  113. package/getType.cjs.js +13 -1
  114. package/getType.esm.js +13 -1
  115. package/getUrlHashParams.cjs.js +6 -8
  116. package/getUrlHashParams.esm.js +6 -8
  117. package/getUrlHashPathname.cjs.js +7 -1
  118. package/getUrlHashPathname.esm.js +7 -1
  119. package/getUrlPathnameParts.cjs.js +10 -4
  120. package/getUrlPathnameParts.esm.js +10 -4
  121. package/getUrlQueryParams.cjs.js +12 -20
  122. package/getUrlQueryParams.esm.js +12 -20
  123. package/hashAny.cjs.d.ts +2 -0
  124. package/hashAny.cjs.default.js +1 -0
  125. package/hashAny.cjs.js +40 -0
  126. package/hashAny.cjs.mjs +2 -0
  127. package/hashAny.d.ts +2 -0
  128. package/hashAny.esm.js +35 -0
  129. package/imgEmptyPixel.cjs.js +5 -1
  130. package/imgEmptyPixel.esm.js +5 -1
  131. package/index.cjs.js +5 -3
  132. package/index.d.ts +2 -1
  133. package/index.esm.js +3 -2
  134. package/invariant.cjs.js +17 -16
  135. package/invariant.esm.js +17 -16
  136. package/isAbsoluteUrl.cjs.js +5 -2
  137. package/isAbsoluteUrl.esm.js +5 -2
  138. package/isAnyObject.cjs.js +5 -1
  139. package/isAnyObject.esm.js +5 -1
  140. package/isArray.cjs.js +5 -1
  141. package/isArray.esm.js +5 -1
  142. package/isBlob.cjs.js +5 -1
  143. package/isBlob.esm.js +5 -1
  144. package/isBoolean.cjs.js +5 -1
  145. package/isBoolean.esm.js +5 -1
  146. package/isBrowser.cjs.js +4 -1
  147. package/isBrowser.esm.js +4 -1
  148. package/isBrowserNow.cjs.js +4 -1
  149. package/isBrowserNow.esm.js +4 -1
  150. package/isDate.cjs.js +5 -1
  151. package/isDate.esm.js +5 -1
  152. package/isEmptyArray.cjs.js +5 -1
  153. package/isEmptyArray.esm.js +5 -1
  154. package/isEmptyObject.cjs.js +5 -1
  155. package/isEmptyObject.esm.js +5 -1
  156. package/isEmptyString.cjs.js +5 -1
  157. package/isEmptyString.esm.js +5 -1
  158. package/isError.cjs.js +5 -1
  159. package/isError.esm.js +5 -1
  160. package/isExternalUrl.cjs.js +9 -9
  161. package/isExternalUrl.esm.js +9 -9
  162. package/isFile.cjs.js +5 -1
  163. package/isFile.esm.js +5 -1
  164. package/isFloat.cjs.js +5 -1
  165. package/isFloat.esm.js +5 -1
  166. package/isFormData.cjs.js +5 -1
  167. package/isFormData.esm.js +5 -1
  168. package/isFullArray.cjs.js +5 -1
  169. package/isFullArray.esm.js +5 -1
  170. package/isFullObject.cjs.js +5 -1
  171. package/isFullObject.esm.js +5 -1
  172. package/isFullString.cjs.js +5 -1
  173. package/isFullString.esm.js +5 -1
  174. package/isFunction.cjs.js +5 -1
  175. package/isFunction.esm.js +5 -1
  176. package/isInt.cjs.js +5 -1
  177. package/isInt.esm.js +5 -1
  178. package/isMap.cjs.js +5 -1
  179. package/isMap.esm.js +5 -1
  180. package/isNaNValue.cjs.js +5 -1
  181. package/isNaNValue.esm.js +5 -1
  182. package/isNegativeNumber.cjs.js +5 -1
  183. package/isNegativeNumber.esm.js +5 -1
  184. package/isNull.cjs.js +5 -1
  185. package/isNull.esm.js +5 -1
  186. package/isNullOrUndefined.cjs.js +5 -1
  187. package/isNullOrUndefined.esm.js +5 -1
  188. package/isNumber.cjs.js +7 -1
  189. package/isNumber.esm.js +7 -1
  190. package/isNumericLiteral.cjs.js +8 -1
  191. package/isNumericLiteral.esm.js +8 -1
  192. package/isObject.cjs.js +5 -1
  193. package/isObject.esm.js +5 -1
  194. package/isObjectLike.cjs.js +7 -1
  195. package/isObjectLike.esm.js +7 -1
  196. package/isObjectStringKeyed.cjs.js +9 -1
  197. package/isObjectStringKeyed.esm.js +9 -1
  198. package/isOneOf.cjs.js +3 -7
  199. package/isOneOf.esm.js +3 -7
  200. package/isPlainObject.cjs.js +5 -4
  201. package/isPlainObject.esm.js +5 -4
  202. package/isPositiveNumber.cjs.js +5 -1
  203. package/isPositiveNumber.esm.js +5 -1
  204. package/isPrimitive.cjs.js +5 -6
  205. package/isPrimitive.esm.js +5 -6
  206. package/isPromise.cjs.js +5 -1
  207. package/isPromise.esm.js +5 -1
  208. package/isRegExp.cjs.js +5 -1
  209. package/isRegExp.esm.js +5 -1
  210. package/isServer.cjs.js +4 -1
  211. package/isServer.esm.js +4 -1
  212. package/isServerNow.cjs.js +4 -1
  213. package/isServerNow.esm.js +4 -1
  214. package/isSet.cjs.js +5 -1
  215. package/isSet.esm.js +5 -1
  216. package/isString.cjs.js +5 -1
  217. package/isString.esm.js +5 -1
  218. package/isSymbol.cjs.js +5 -1
  219. package/isSymbol.esm.js +5 -1
  220. package/isType.cjs.js +9 -11
  221. package/isType.esm.js +9 -11
  222. package/isUndefined.cjs.js +5 -1
  223. package/isUndefined.esm.js +5 -1
  224. package/isWeakMap.cjs.js +5 -1
  225. package/isWeakMap.esm.js +5 -1
  226. package/isWeakSet.cjs.js +5 -1
  227. package/isWeakSet.esm.js +5 -1
  228. package/kbToBytes.cjs.js +5 -1
  229. package/kbToBytes.esm.js +5 -1
  230. package/lowercase.cjs.js +5 -1
  231. package/lowercase.d.ts +1 -1
  232. package/lowercase.esm.js +5 -1
  233. package/mapListBy.cjs.js +5 -4
  234. package/mapListBy.esm.js +5 -4
  235. package/matchSorter.cjs.js +94 -239
  236. package/matchSorter.d.ts +1 -1
  237. package/matchSorter.esm.js +92 -237
  238. package/mbToBytes.cjs.js +5 -1
  239. package/mbToBytes.esm.js +5 -1
  240. package/mergeObjects.cjs.js +8 -26
  241. package/mergeObjects.esm.js +8 -26
  242. package/mergeUrlQueryParams.cjs.js +5 -12
  243. package/mergeUrlQueryParams.esm.js +5 -12
  244. package/moveSortableArrayItemByKey.cjs.js +7 -8
  245. package/moveSortableArrayItemByKey.esm.js +7 -8
  246. package/noop.cjs.js +5 -1
  247. package/noop.esm.js +5 -1
  248. package/normaliseUrl.cjs.js +9 -1
  249. package/normaliseUrl.esm.js +9 -1
  250. package/normaliseUrlPathname.cjs.js +8 -1
  251. package/normaliseUrlPathname.esm.js +8 -1
  252. package/objectFlat.cjs.js +8 -16
  253. package/objectFlat.esm.js +8 -16
  254. package/objectFlip.cjs.js +4 -4
  255. package/objectFlip.esm.js +4 -4
  256. package/objectMergeWithDefaults.cjs.js +29 -19
  257. package/objectMergeWithDefaults.d.ts +1 -1
  258. package/objectMergeWithDefaults.esm.js +29 -19
  259. package/objectOmit.cjs.js +9 -7
  260. package/objectOmit.esm.js +9 -7
  261. package/objectPick.cjs.js +6 -8
  262. package/objectPick.esm.js +6 -8
  263. package/objectSort.cjs.js +8 -1
  264. package/objectSort.esm.js +8 -1
  265. package/objectSortByKeysMatching.cjs.js +9 -1
  266. package/objectSortByKeysMatching.esm.js +9 -1
  267. package/objectToArray.cjs.js +6 -1
  268. package/objectToArray.esm.js +6 -1
  269. package/package.json +10 -5
  270. package/parseCookie.cjs.js +13 -32
  271. package/parseCookie.esm.js +13 -32
  272. package/parseURL.cjs.js +6 -13
  273. package/parseURL.esm.js +6 -13
  274. package/quaranteneProps.cjs.js +17 -15
  275. package/quaranteneProps.esm.js +17 -15
  276. package/randomInt.cjs.js +5 -1
  277. package/randomInt.esm.js +5 -1
  278. package/randomKey.cjs.js +6 -4
  279. package/randomKey.esm.js +6 -4
  280. package/readCookie.cjs.js +5 -33
  281. package/readCookie.esm.js +5 -33
  282. package/removeAccents.cjs.js +4 -9
  283. package/removeAccents.d.ts +1 -1
  284. package/removeAccents.esm.js +4 -9
  285. package/removeCookie.cjs.js +3 -7
  286. package/removeCookie.esm.js +3 -7
  287. package/removeDuplicates.cjs.js +8 -1
  288. package/removeDuplicates.esm.js +8 -1
  289. package/removeDuplicatesByKey.cjs.js +6 -12
  290. package/removeDuplicatesByKey.esm.js +6 -12
  291. package/removeDuplicatesComparing.cjs.js +3 -4
  292. package/removeDuplicatesComparing.esm.js +3 -4
  293. package/removeIndexesFromArray.cjs.js +4 -9
  294. package/removeIndexesFromArray.esm.js +4 -9
  295. package/removeTrailingSlash.cjs.js +5 -1
  296. package/removeTrailingSlash.esm.js +5 -1
  297. package/removeUrlQueryParams.cjs.js +5 -11
  298. package/removeUrlQueryParams.esm.js +5 -11
  299. package/render.cjs.js +52 -112
  300. package/render.esm.js +52 -112
  301. package/round.cjs.js +11 -3
  302. package/round.esm.js +11 -3
  303. package/roundTo.cjs.js +22 -10
  304. package/roundTo.esm.js +22 -10
  305. package/serializeCookie.cjs.js +13 -67
  306. package/serializeCookie.esm.js +13 -67
  307. package/setCookie.cjs.js +11 -41
  308. package/setCookie.esm.js +11 -41
  309. package/shuffle.cjs.js +15 -16
  310. package/shuffle.esm.js +15 -16
  311. package/slugify.cjs.js +20 -9
  312. package/slugify.esm.js +20 -9
  313. package/split.cjs.js +6 -1
  314. package/split.esm.js +6 -1
  315. package/splitReverse.cjs.js +6 -1
  316. package/splitReverse.esm.js +6 -1
  317. package/swapMap.cjs.js +5 -7
  318. package/swapMap.esm.js +5 -7
  319. package/throttle.cjs.js +6 -14
  320. package/throttle.d.ts +1 -1
  321. package/throttle.esm.js +6 -14
  322. package/titleCase.cjs.js +6 -3
  323. package/titleCase.esm.js +6 -3
  324. package/toNumber.cjs.js +5 -1
  325. package/toNumber.esm.js +5 -1
  326. package/toRgba.cjs.js +5 -7
  327. package/toRgba.esm.js +5 -7
  328. package/transformToUrlPathname.cjs.js +9 -3
  329. package/transformToUrlPathname.esm.js +9 -3
  330. package/truncate.cjs.js +5 -5
  331. package/truncate.esm.js +5 -5
  332. package/tryUntil.cjs.js +14 -14
  333. package/tryUntil.esm.js +14 -14
  334. package/uid.cjs.js +5 -5
  335. package/uid.esm.js +5 -5
  336. package/updateLinkParams.cjs.js +7 -5
  337. package/updateLinkParams.esm.js +7 -5
  338. package/updateUrlQueryParams.cjs.js +5 -7
  339. package/updateUrlQueryParams.esm.js +5 -7
  340. package/uppercase.cjs.js +6 -1
  341. package/uppercase.d.ts +1 -1
  342. package/uppercase.esm.js +6 -1
  343. package/uuid.cjs.js +6 -4
  344. package/uuid.esm.js +6 -4
  345. package/uuidNumeric.cjs.js +4 -1
  346. package/uuidNumeric.esm.js +4 -1
  347. package/wait.cjs.js +5 -1
  348. package/wait.esm.js +5 -1
  349. package/accentSets.cjs.d.ts +0 -2
  350. package/accentSets.cjs.default.js +0 -1
  351. package/accentSets.cjs.js +0 -36
  352. package/accentSets.cjs.mjs +0 -2
  353. package/accentSets.esm.js +0 -31
  354. /package/{accentSets.d.ts → accentsSets.d.ts} +0 -0
@@ -1,13 +1,19 @@
1
- let createPalette = (name, shades) => {
2
- const map = shades.reduce((map, def) => {
3
- map[def[0]] = def[1];
4
- return map;
5
- }, {});
6
- const tailwindPalette = shades.reduce((map, def) => {
7
- map[`${name}-${def[0]}`] = def[1];
8
- return map;
9
- }, {});
10
- return [map, tailwindPalette, Object.values(map)];
11
- };
1
+ /**
2
+ * Create palette, this is primarily thought to improve the reuse of a palette
3
+ * definition between TailwindCSS and straight ES imports
4
+ *
5
+ * @category colors
6
+ * @category tailwind
7
+ * @category responsive
8
+ *
9
+ * @returns An array with: 1) A flat palette map 2) A TailwindCSS ready palette
10
+ * object 3) A flat array of colors (no special sorting, same order as the `shades`
11
+ * given as argument)
12
+ */let createPalette=(e,t)=>{let r=t.reduce((e,t)=>(e[t[0]]=t[1],e),{});return [r,// NOTE: the following breaks typedoc, with `any` it compiles
13
+ // const map = shades.reduce((map, def) => {
14
+ // map[def[0]] = def[1] as TColor;
15
+ // return map;
16
+ // }, {} as { [s: string]: TColor });
17
+ t.reduce((t,r)=>(t[`${e}-${r[0]}`]=r[1],t),{}),Object.values(r)]};
12
18
 
13
19
  export { createPalette, createPalette as default };
package/debounce.cjs.js CHANGED
@@ -2,23 +2,13 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- let debounce = (fn, wait, immediate) => {
6
- let timeout;
7
- return function (...args) {
8
- const context = this;
9
- const later = function () {
10
- timeout = null;
11
- if (!immediate)
12
- fn.apply(context, args);
13
- };
14
- const callNow = immediate && !timeout;
15
- if (timeout)
16
- clearTimeout(timeout);
17
- timeout = setTimeout(later, wait);
18
- if (callNow)
19
- fn.apply(context, args);
20
- };
21
- };
5
+ /**
6
+ * Debounce function (with `setTimeout`)
7
+ *
8
+ * @category function
9
+ * @borrows [davidwalsh/debounce](https://davidwalsh.name/javascript-debounce-function)
10
+ */let debounce=(e,t,l)=>{let u;return function(...n){// eslint-disable-next-line @typescript-eslint/no-this-alias
11
+ let o=this,p=l&&!u;u&&clearTimeout(u),u=setTimeout(function(){u=null,l||e.apply(o,n);},t),p&&e.apply(o,n);}};
22
12
 
23
13
  exports.debounce = debounce;
24
14
  exports["default"] = debounce;
package/debounce.esm.js CHANGED
@@ -1,19 +1,9 @@
1
- let debounce = (fn, wait, immediate) => {
2
- let timeout;
3
- return function (...args) {
4
- const context = this;
5
- const later = function () {
6
- timeout = null;
7
- if (!immediate)
8
- fn.apply(context, args);
9
- };
10
- const callNow = immediate && !timeout;
11
- if (timeout)
12
- clearTimeout(timeout);
13
- timeout = setTimeout(later, wait);
14
- if (callNow)
15
- fn.apply(context, args);
16
- };
17
- };
1
+ /**
2
+ * Debounce function (with `setTimeout`)
3
+ *
4
+ * @category function
5
+ * @borrows [davidwalsh/debounce](https://davidwalsh.name/javascript-debounce-function)
6
+ */let debounce=(e,t,l)=>{let u;return function(...n){// eslint-disable-next-line @typescript-eslint/no-this-alias
7
+ let o=this,p=l&&!u;u&&clearTimeout(u),u=setTimeout(function(){u=null,l||e.apply(o,n);},t),p&&e.apply(o,n);}};
18
8
 
19
9
  export { debounce, debounce as default };
@@ -2,57 +2,22 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- let debouncePromise = (func, waitMilliseconds = 50, options = {}) => {
6
- let timeoutId;
7
- const isImmediate = options.isImmediate ?? false;
8
- const callback = options.callback ?? false;
9
- const maxWait = options.maxWait;
10
- let lastInvokeTime = Date.now();
11
- let promises = [];
12
- function nextInvokeTimeout() {
13
- if (maxWait !== undefined) {
14
- const timeSinceLastInvocation = Date.now() - lastInvokeTime;
15
- if (timeSinceLastInvocation + waitMilliseconds >= maxWait) {
16
- return maxWait - timeSinceLastInvocation;
17
- }
18
- }
19
- return waitMilliseconds;
20
- }
21
- const debouncedFunction = function (...args) {
22
- const context = this;
23
- return new Promise((resolve, reject) => {
24
- const invokeFunction = function () {
25
- timeoutId = undefined;
26
- lastInvokeTime = Date.now();
27
- if (!isImmediate) {
28
- const result = func.apply(context, args);
29
- callback && callback(result);
30
- promises.forEach(({ resolve }) => resolve(result));
31
- promises = [];
32
- }
33
- };
34
- const shouldCallNow = isImmediate && timeoutId === undefined;
35
- if (timeoutId !== undefined) {
36
- clearTimeout(timeoutId);
37
- }
38
- timeoutId = setTimeout(invokeFunction, nextInvokeTimeout());
39
- if (shouldCallNow) {
40
- const result = func.apply(context, args);
41
- callback && callback(result);
42
- return resolve(result);
43
- }
44
- promises.push({ resolve, reject });
45
- });
46
- };
47
- debouncedFunction.cancel = function (reason) {
48
- if (timeoutId !== undefined) {
49
- clearTimeout(timeoutId);
50
- }
51
- promises.forEach(({ reject }) => reject(reason));
52
- promises = [];
53
- };
54
- return debouncedFunction;
55
- };
5
+ /**
6
+ * Copy pasted from [chodorowicz/ts-debounce](https://github.com/chodorowicz/ts-debounce/blob/master/src/index.ts)
7
+ *
8
+ * @module
9
+ *//**
10
+ * @categroy functionn
11
+ *//**
12
+ * @categroy functionn
13
+ *//**
14
+ * Debounce function (with `Promise`)
15
+ *
16
+ * @category function
17
+ * @borrows [chodorowicz/ts-debounce](https://github.com/chodorowicz/ts-debounce)
18
+ * @license MIT: Jakub Chodorowicz
19
+ */let debouncePromise=(e,t=50,o={})=>{let i;let n=o.isImmediate??!1,r=o.callback??!1,a=o.maxWait,l=Date.now(),u=[],c=function(...o){// eslint-disable-next-line @typescript-eslint/no-this-alias
20
+ let c=this;return new Promise((f,d)=>{let m=n&&void 0===i;if(void 0!==i&&clearTimeout(i),i=setTimeout(function(){if(i=void 0,l=Date.now(),!n){let t=e.apply(c,o);r&&r(t),u.forEach(({resolve:e})=>e(t)),u=[];}},function(){if(void 0!==a){let e=Date.now()-l;if(e+t>=a)return a-e}return t}()),m){let t=e.apply(c,o);return r&&r(t),f(t)}u.push({resolve:f,reject:d});})};return c.cancel=function(e){void 0!==i&&clearTimeout(i),u.forEach(({reject:t})=>t(e)),u=[];},c};
56
21
 
57
22
  exports.debouncePromise = debouncePromise;
58
23
  exports["default"] = debouncePromise;
@@ -1,53 +1,18 @@
1
- let debouncePromise = (func, waitMilliseconds = 50, options = {}) => {
2
- let timeoutId;
3
- const isImmediate = options.isImmediate ?? false;
4
- const callback = options.callback ?? false;
5
- const maxWait = options.maxWait;
6
- let lastInvokeTime = Date.now();
7
- let promises = [];
8
- function nextInvokeTimeout() {
9
- if (maxWait !== undefined) {
10
- const timeSinceLastInvocation = Date.now() - lastInvokeTime;
11
- if (timeSinceLastInvocation + waitMilliseconds >= maxWait) {
12
- return maxWait - timeSinceLastInvocation;
13
- }
14
- }
15
- return waitMilliseconds;
16
- }
17
- const debouncedFunction = function (...args) {
18
- const context = this;
19
- return new Promise((resolve, reject) => {
20
- const invokeFunction = function () {
21
- timeoutId = undefined;
22
- lastInvokeTime = Date.now();
23
- if (!isImmediate) {
24
- const result = func.apply(context, args);
25
- callback && callback(result);
26
- promises.forEach(({ resolve }) => resolve(result));
27
- promises = [];
28
- }
29
- };
30
- const shouldCallNow = isImmediate && timeoutId === undefined;
31
- if (timeoutId !== undefined) {
32
- clearTimeout(timeoutId);
33
- }
34
- timeoutId = setTimeout(invokeFunction, nextInvokeTimeout());
35
- if (shouldCallNow) {
36
- const result = func.apply(context, args);
37
- callback && callback(result);
38
- return resolve(result);
39
- }
40
- promises.push({ resolve, reject });
41
- });
42
- };
43
- debouncedFunction.cancel = function (reason) {
44
- if (timeoutId !== undefined) {
45
- clearTimeout(timeoutId);
46
- }
47
- promises.forEach(({ reject }) => reject(reason));
48
- promises = [];
49
- };
50
- return debouncedFunction;
51
- };
1
+ /**
2
+ * Copy pasted from [chodorowicz/ts-debounce](https://github.com/chodorowicz/ts-debounce/blob/master/src/index.ts)
3
+ *
4
+ * @module
5
+ *//**
6
+ * @categroy functionn
7
+ *//**
8
+ * @categroy functionn
9
+ *//**
10
+ * Debounce function (with `Promise`)
11
+ *
12
+ * @category function
13
+ * @borrows [chodorowicz/ts-debounce](https://github.com/chodorowicz/ts-debounce)
14
+ * @license MIT: Jakub Chodorowicz
15
+ */let debouncePromise=(e,t=50,o={})=>{let i;let n=o.isImmediate??!1,r=o.callback??!1,a=o.maxWait,l=Date.now(),u=[],c=function(...o){// eslint-disable-next-line @typescript-eslint/no-this-alias
16
+ let c=this;return new Promise((f,d)=>{let m=n&&void 0===i;if(void 0!==i&&clearTimeout(i),i=setTimeout(function(){if(i=void 0,l=Date.now(),!n){let t=e.apply(c,o);r&&r(t),u.forEach(({resolve:e})=>e(t)),u=[];}},function(){if(void 0!==a){let e=Date.now()-l;if(e+t>=a)return a-e}return t}()),m){let t=e.apply(c,o);return r&&r(t),f(t)}u.push({resolve:f,reject:d});})};return c.cancel=function(e){void 0!==i&&clearTimeout(i),u.forEach(({reject:t})=>t(e)),u=[];},c};
52
17
 
53
18
  export { debouncePromise, debouncePromise as default };
@@ -2,18 +2,16 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- function debounceRaf(fn) {
6
- let timeout;
7
- return function (...args) {
8
- const context = this;
9
- if (timeout) {
10
- window.cancelAnimationFrame(timeout);
11
- }
12
- timeout = window.requestAnimationFrame(function () {
13
- fn.apply(context, args);
14
- });
15
- };
16
- }
5
+ /**
6
+ * Debounce function (with `requestAnimationFrame`)
7
+ *
8
+ * @category function
9
+ * @borrows [vanillajstoolkit/debounce](https://vanillajstoolkit.com/helpers/debounce/)
10
+ * @license (c) 2021 Chris Ferdinandi, MIT License, https://gomakethings.com
11
+ */function debounceRaf(n){let e;return function(...t){// eslint-disable-next-line @typescript-eslint/no-this-alias
12
+ let o=this;// If there's a timer, cancel it
13
+ e&&window.cancelAnimationFrame(e),// Setup the new requestAnimationFrame()
14
+ e=window.requestAnimationFrame(function(){n.apply(o,t);});}}
17
15
 
18
16
  exports.debounceRaf = debounceRaf;
19
17
  exports["default"] = debounceRaf;
@@ -1,14 +1,12 @@
1
- function debounceRaf(fn) {
2
- let timeout;
3
- return function (...args) {
4
- const context = this;
5
- if (timeout) {
6
- window.cancelAnimationFrame(timeout);
7
- }
8
- timeout = window.requestAnimationFrame(function () {
9
- fn.apply(context, args);
10
- });
11
- };
12
- }
1
+ /**
2
+ * Debounce function (with `requestAnimationFrame`)
3
+ *
4
+ * @category function
5
+ * @borrows [vanillajstoolkit/debounce](https://vanillajstoolkit.com/helpers/debounce/)
6
+ * @license (c) 2021 Chris Ferdinandi, MIT License, https://gomakethings.com
7
+ */function debounceRaf(n){let e;return function(...t){// eslint-disable-next-line @typescript-eslint/no-this-alias
8
+ let o=this;// If there's a timer, cancel it
9
+ e&&window.cancelAnimationFrame(e),// Setup the new requestAnimationFrame()
10
+ e=window.requestAnimationFrame(function(){n.apply(o,t);});}}
13
11
 
14
12
  export { debounceRaf, debounceRaf as default };
package/decode.cjs.js CHANGED
@@ -2,7 +2,10 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- let decode = (str) => str.replace(/.{3}/g, (c) => String.fromCharCode(parseInt(c, 10)));
5
+ /**
6
+ * @category security
7
+ * @see https://stackoverflow.com/a/22405578/9122820
8
+ */let decode=e=>e.replace(/.{3}/g,e=>String.fromCharCode(parseInt(e,10)));
6
9
 
7
10
  exports.decode = decode;
8
11
  exports["default"] = decode;
package/decode.esm.js CHANGED
@@ -1,3 +1,6 @@
1
- let decode = (str) => str.replace(/.{3}/g, (c) => String.fromCharCode(parseInt(c, 10)));
1
+ /**
2
+ * @category security
3
+ * @see https://stackoverflow.com/a/22405578/9122820
4
+ */let decode=e=>e.replace(/.{3}/g,e=>String.fromCharCode(parseInt(e,10)));
2
5
 
3
6
  export { decode, decode as default };
package/encode.cjs.js CHANGED
@@ -2,7 +2,10 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- let encode = (str) => str.replace(/./g, (c) => ("00" + c.charCodeAt(0)).slice(-3));
5
+ /**
6
+ * @category security
7
+ * @see https://stackoverflow.com/a/22405578/9122820
8
+ */let encode=e=>e.replace(/./g,e=>("00"+e.charCodeAt(0)).slice(-3));
6
9
 
7
10
  exports["default"] = encode;
8
11
  exports.encode = encode;
package/encode.esm.js CHANGED
@@ -1,3 +1,6 @@
1
- let encode = (str) => str.replace(/./g, (c) => ("00" + c.charCodeAt(0)).slice(-3));
1
+ /**
2
+ * @category security
3
+ * @see https://stackoverflow.com/a/22405578/9122820
4
+ */let encode=e=>e.replace(/./g,e=>("00"+e.charCodeAt(0)).slice(-3));
2
5
 
3
6
  export { encode as default, encode };
package/ensureInt.cjs.js CHANGED
@@ -2,7 +2,11 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- let ensureInt = (input) => typeof input === "string" ? parseInt(input, 10) : Math.round(input);
5
+ /**
6
+ * Ensure input to be an integer
7
+ *
8
+ * @category cast
9
+ */let ensureInt=e=>"string"==typeof e?parseInt(e,10):Math.round(e);
6
10
 
7
11
  exports["default"] = ensureInt;
8
12
  exports.ensureInt = ensureInt;
package/ensureInt.esm.js CHANGED
@@ -1,3 +1,7 @@
1
- let ensureInt = (input) => typeof input === "string" ? parseInt(input, 10) : Math.round(input);
1
+ /**
2
+ * Ensure input to be an integer
3
+ *
4
+ * @category cast
5
+ */let ensureInt=e=>"string"==typeof e?parseInt(e,10):Math.round(e);
2
6
 
3
7
  export { ensureInt as default, ensureInt };
@@ -5,7 +5,12 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var isString = require('./isString.cjs.js');
6
6
  require('./getType.cjs.js');
7
7
 
8
- let errorToString = (e) => e instanceof Error ? e.message : isString.isString(e) ? e : "";
8
+ /**
9
+ * Ensure to transform a JavaScript `Error` into a string (uses its `message`)
10
+ *
11
+ * @category error
12
+ * @category cast
13
+ */let errorToString=o=>o instanceof Error?o.message:isString.isString(o)?o:"";
9
14
 
10
15
  exports["default"] = errorToString;
11
16
  exports.errorToString = errorToString;
@@ -1,6 +1,11 @@
1
1
  import { isString } from './isString.esm.js';
2
2
  import './getType.esm.js';
3
3
 
4
- let errorToString = (e) => e instanceof Error ? e.message : isString(e) ? e : "";
4
+ /**
5
+ * Ensure to transform a JavaScript `Error` into a string (uses its `message`)
6
+ *
7
+ * @category error
8
+ * @category cast
9
+ */let errorToString=o=>o instanceof Error?o.message:isString(o)?o:"";
5
10
 
6
11
  export { errorToString as default, errorToString };
@@ -2,7 +2,13 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- let escapeRegExp = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
5
+ /**
6
+ * @borrows [MDN Docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions)
7
+ * @borrows [SO's answer by Mathias Bynens](https://stackoverflow.com/a/9310752/1938970)
8
+ *
9
+ * @category escape
10
+ * @category RegExp
11
+ */let escapeRegExp=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");// text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
6
12
 
7
13
  exports["default"] = escapeRegExp;
8
14
  exports.escapeRegExp = escapeRegExp;
@@ -1,3 +1,9 @@
1
- let escapeRegExp = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1
+ /**
2
+ * @borrows [MDN Docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions)
3
+ * @borrows [SO's answer by Mathias Bynens](https://stackoverflow.com/a/9310752/1938970)
4
+ *
5
+ * @category escape
6
+ * @category RegExp
7
+ */let escapeRegExp=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");// text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
2
8
 
3
9
  export { escapeRegExp as default, escapeRegExp };
@@ -2,16 +2,9 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- let findDuplicatedIndexes = (arr) => {
6
- const indexes = {};
7
- for (let i = 0; i < arr.length; i++) {
8
- const idxInArray = arr.indexOf(arr[i]);
9
- if (idxInArray !== i && idxInArray !== -1) {
10
- indexes[i] = true;
11
- }
12
- }
13
- return indexes;
14
- };
5
+ /**
6
+ * @category array
7
+ */let findDuplicatedIndexes=e=>{let t={};for(let d=0;d<e.length;d++){let l=e.indexOf(e[d]);l!==d&&-1!==l&&(t[d]=!0);}return t};
15
8
 
16
9
  exports["default"] = findDuplicatedIndexes;
17
10
  exports.findDuplicatedIndexes = findDuplicatedIndexes;
@@ -1,12 +1,5 @@
1
- let findDuplicatedIndexes = (arr) => {
2
- const indexes = {};
3
- for (let i = 0; i < arr.length; i++) {
4
- const idxInArray = arr.indexOf(arr[i]);
5
- if (idxInArray !== i && idxInArray !== -1) {
6
- indexes[i] = true;
7
- }
8
- }
9
- return indexes;
10
- };
1
+ /**
2
+ * @category array
3
+ */let findDuplicatedIndexes=e=>{let t={};for(let d=0;d<e.length;d++){let l=e.indexOf(e[d]);l!==d&&-1!==l&&(t[d]=!0);}return t};
11
4
 
12
5
  export { findDuplicatedIndexes as default, findDuplicatedIndexes };
package/forin.cjs.js CHANGED
@@ -2,11 +2,12 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- let forin = (object, cb) => {
6
- for (const key in object) {
7
- cb(key, object[key]);
8
- }
9
- };
5
+ /**
6
+ * To easily get typed native `for in`
7
+ *
8
+ * @category native
9
+ * @category object
10
+ */let forin=(e,o)=>{for(let r in e)o(r,e[r]);};
10
11
 
11
12
  exports["default"] = forin;
12
13
  exports.forin = forin;
package/forin.esm.js CHANGED
@@ -1,7 +1,8 @@
1
- let forin = (object, cb) => {
2
- for (const key in object) {
3
- cb(key, object[key]);
4
- }
5
- };
1
+ /**
2
+ * To easily get typed native `for in`
3
+ *
4
+ * @category native
5
+ * @category object
6
+ */let forin=(e,o)=>{for(let r in e)o(r,e[r]);};
6
7
 
7
8
  export { forin as default, forin };
package/gbToBytes.cjs.js CHANGED
@@ -2,7 +2,11 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- let gbToBytes = (bytes) => bytes * 1000 * 1000 * 1000;
5
+ /**
6
+ * Gigabytes to bytes
7
+ *
8
+ * @category format
9
+ */let gbToBytes=e=>1e9*e;
6
10
 
7
11
  exports["default"] = gbToBytes;
8
12
  exports.gbToBytes = gbToBytes;
package/gbToBytes.esm.js CHANGED
@@ -1,3 +1,7 @@
1
- let gbToBytes = (bytes) => bytes * 1000 * 1000 * 1000;
1
+ /**
2
+ * Gigabytes to bytes
3
+ *
4
+ * @category format
5
+ */let gbToBytes=e=>1e9*e;
2
6
 
3
7
  export { gbToBytes as default, gbToBytes };
@@ -5,9 +5,12 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var isNumber = require('./isNumber.cjs.js');
6
6
  require('./getType.cjs.js');
7
7
 
8
- let getEmptyArray = (length) => Array.from({
9
- length: !isNumber.isNumber(length) ? parseInt(length, 10) : length,
10
- });
8
+ /**
9
+ * Returns an array of undefined values of the desired length, useful to build
10
+ * skeleton UIs.
11
+ *
12
+ * @category array
13
+ */let getEmptyArray=/* <T extends undefined | null = undefined> */t=>Array.from({length:isNumber.isNumber(t)?t:parseInt(t,10)});
11
14
 
12
15
  exports["default"] = getEmptyArray;
13
16
  exports.getEmptyArray = getEmptyArray;
@@ -1,8 +1,11 @@
1
1
  import { isNumber } from './isNumber.esm.js';
2
2
  import './getType.esm.js';
3
3
 
4
- let getEmptyArray = (length) => Array.from({
5
- length: !isNumber(length) ? parseInt(length, 10) : length,
6
- });
4
+ /**
5
+ * Returns an array of undefined values of the desired length, useful to build
6
+ * skeleton UIs.
7
+ *
8
+ * @category array
9
+ */let getEmptyArray=/* <T extends undefined | null = undefined> */t=>Array.from({length:isNumber(t)?t:parseInt(t,10)});
7
10
 
8
11
  export { getEmptyArray as default, getEmptyArray };
package/getKeys.cjs.js CHANGED
@@ -2,7 +2,14 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- let getKeys = Object.keys;
5
+ /**
6
+ * Type safe replacement for `Object.keys(myObject)` to iterate over a record
7
+ * without loosing the key's types in simple `string`s.
8
+ *
9
+ * @category native
10
+ * @category object
11
+ * @see https://stackoverflow.com/a/59459000/1938970
12
+ */let getKeys=Object.keys;
6
13
 
7
14
  exports["default"] = getKeys;
8
15
  exports.getKeys = getKeys;
package/getKeys.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare let getKeys: <T extends object>(obj: T) => (keyof T)[];
1
+ export declare let getKeys: <T extends object>(obj: T) => Array<keyof T>;
2
2
  export default getKeys;
package/getKeys.esm.js CHANGED
@@ -1,3 +1,10 @@
1
- let getKeys = Object.keys;
1
+ /**
2
+ * Type safe replacement for `Object.keys(myObject)` to iterate over a record
3
+ * without loosing the key's types in simple `string`s.
4
+ *
5
+ * @category native
6
+ * @category object
7
+ * @see https://stackoverflow.com/a/59459000/1938970
8
+ */let getKeys=Object.keys;
2
9
 
3
10
  export { getKeys as default, getKeys };