@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
package/randomInt.cjs.js CHANGED
@@ -2,7 +2,11 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- let randomInt = (min, max) => Math.floor(Math.random() * (max - min + 1) + min);
5
+ /**
6
+ * Get random int (min and max included)
7
+ *
8
+ * @category math
9
+ */let randomInt=(t,o)=>Math.floor(Math.random()*(o-t+1)+t);
6
10
 
7
11
  exports["default"] = randomInt;
8
12
  exports.randomInt = randomInt;
package/randomInt.esm.js CHANGED
@@ -1,3 +1,7 @@
1
- let randomInt = (min, max) => Math.floor(Math.random() * (max - min + 1) + min);
1
+ /**
2
+ * Get random int (min and max included)
3
+ *
4
+ * @category math
5
+ */let randomInt=(t,o)=>Math.floor(Math.random()*(o-t+1)+t);
2
6
 
3
7
  export { randomInt as default, randomInt };
package/randomKey.cjs.js CHANGED
@@ -2,10 +2,12 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- let randomKey = (obj) => {
6
- const keys = Object.keys(obj);
7
- return keys[(keys.length * Math.random()) << 0];
8
- };
5
+ /**
6
+ * Get random key from given object
7
+ *
8
+ * @category misc
9
+ * @see https://stackoverflow.com/a/15106541/1938970
10
+ */let randomKey=e=>{let t=Object.keys(e);return t[t.length*Math.random()<<0]};
9
11
 
10
12
  exports["default"] = randomKey;
11
13
  exports.randomKey = randomKey;
package/randomKey.esm.js CHANGED
@@ -1,6 +1,8 @@
1
- let randomKey = (obj) => {
2
- const keys = Object.keys(obj);
3
- return keys[(keys.length * Math.random()) << 0];
4
- };
1
+ /**
2
+ * Get random key from given object
3
+ *
4
+ * @category misc
5
+ * @see https://stackoverflow.com/a/15106541/1938970
6
+ */let randomKey=e=>{let t=Object.keys(e);return t[t.length*Math.random()<<0]};
5
7
 
6
8
  export { randomKey as default, randomKey };
package/readCookie.cjs.js CHANGED
@@ -2,39 +2,11 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- let converterRead = (value) => {
6
- if (value[0] === '"') {
7
- value = value.slice(1, -1);
8
- }
9
- return value.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent);
10
- };
11
- function readCookie(name) {
12
- if (typeof document === "undefined") {
13
- if (process.env["NODE_ENV"] === "development") {
14
- console.warn("[@koine/utils:readCookie] document is undefined");
15
- }
16
- return name ? "" : {};
17
- }
18
- const cookies = document.cookie ? document.cookie.split("; ") : [];
19
- const all = {};
20
- for (let i = 0; i < cookies.length; i++) {
21
- const parts = cookies[i].split("=");
22
- const value = parts.slice(1).join("=");
23
- try {
24
- const found = decodeURIComponent(parts[0]);
25
- all[found] = converterRead(value);
26
- if (name === found) {
27
- break;
28
- }
29
- }
30
- catch (e) {
31
- if (process.env["NODE_ENV"] === "development") {
32
- console.warn("[@koine/utils:readCookie] failed to decode", value);
33
- }
34
- }
35
- }
36
- return name ? all[name] : all;
37
- }
5
+ let e=e=>('"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent));/**
6
+ * Read cookie
7
+ *
8
+ * @category cookie
9
+ */function readCookie(o){if("undefined"==typeof document)return "development"===process.env.NODE_ENV&&console.warn("[@koine/utils:readCookie] document is undefined"),o?"":{};let n=document.cookie?document.cookie.split("; "):[],t={};for(let d=0;d<n.length;d++){let i=n[d].split("="),c=i.slice(1).join("=");try{let n=decodeURIComponent(i[0]);if(t[n]=e(c),o===n)break}catch(e){"development"===process.env.NODE_ENV&&console.warn("[@koine/utils:readCookie] failed to decode",c);}}return o?t[o]:t}
38
10
 
39
11
  exports["default"] = readCookie;
40
12
  exports.readCookie = readCookie;
package/readCookie.esm.js CHANGED
@@ -1,35 +1,7 @@
1
- let converterRead = (value) => {
2
- if (value[0] === '"') {
3
- value = value.slice(1, -1);
4
- }
5
- return value.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent);
6
- };
7
- function readCookie(name) {
8
- if (typeof document === "undefined") {
9
- if (process.env["NODE_ENV"] === "development") {
10
- console.warn("[@koine/utils:readCookie] document is undefined");
11
- }
12
- return name ? "" : {};
13
- }
14
- const cookies = document.cookie ? document.cookie.split("; ") : [];
15
- const all = {};
16
- for (let i = 0; i < cookies.length; i++) {
17
- const parts = cookies[i].split("=");
18
- const value = parts.slice(1).join("=");
19
- try {
20
- const found = decodeURIComponent(parts[0]);
21
- all[found] = converterRead(value);
22
- if (name === found) {
23
- break;
24
- }
25
- }
26
- catch (e) {
27
- if (process.env["NODE_ENV"] === "development") {
28
- console.warn("[@koine/utils:readCookie] failed to decode", value);
29
- }
30
- }
31
- }
32
- return name ? all[name] : all;
33
- }
1
+ let e=e=>('"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent));/**
2
+ * Read cookie
3
+ *
4
+ * @category cookie
5
+ */function readCookie(o){if("undefined"==typeof document)return "development"===process.env.NODE_ENV&&console.warn("[@koine/utils:readCookie] document is undefined"),o?"":{};let n=document.cookie?document.cookie.split("; "):[],t={};for(let d=0;d<n.length;d++){let i=n[d].split("="),c=i.slice(1).join("=");try{let n=decodeURIComponent(i[0]);if(t[n]=e(c),o===n)break}catch(e){"development"===process.env.NODE_ENV&&console.warn("[@koine/utils:readCookie] failed to decode",c);}}return o?t[o]:t}
34
6
 
35
7
  export { readCookie as default, readCookie };
@@ -2,16 +2,11 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var accentSets = require('./accentSets.cjs.js');
5
+ var accentsSets = require('./accentsSets.cjs.js');
6
6
 
7
- let removeAccents = (text = "", sets = accentSets.accentsSets) => {
8
- let len = sets.length;
9
- while (len--) {
10
- const [to, from] = sets[len];
11
- text = text.replace(new RegExp(`[${from}]`, "gi"), to);
12
- }
13
- return text;
14
- };
7
+ /**
8
+ * @category text
9
+ */let removeAccents=(t="",r=accentsSets.accentsSets)=>{let c=r.length;for(;c--;){let[e,o]=r[c];t=t.replace(RegExp(`[${o}]`,"gi"),e);}return t};
15
10
 
16
11
  exports["default"] = removeAccents;
17
12
  exports.removeAccents = removeAccents;
@@ -1,3 +1,3 @@
1
- import type { AccentsSet } from "./accentSets";
1
+ import type { AccentsSet } from "./accentsSets";
2
2
  export declare let removeAccents: (text?: string, sets?: AccentsSet[]) => string;
3
3
  export default removeAccents;
@@ -1,12 +1,7 @@
1
- import { accentsSets } from './accentSets.esm.js';
1
+ import { accentsSets } from './accentsSets.esm.js';
2
2
 
3
- let removeAccents = (text = "", sets = accentsSets) => {
4
- let len = sets.length;
5
- while (len--) {
6
- const [to, from] = sets[len];
7
- text = text.replace(new RegExp(`[${from}]`, "gi"), to);
8
- }
9
- return text;
10
- };
3
+ /**
4
+ * @category text
5
+ */let removeAccents=(t="",r=accentsSets)=>{let c=r.length;for(;c--;){let[e,o]=r[c];t=t.replace(RegExp(`[${o}]`,"gi"),e);}return t};
11
6
 
12
7
  export { removeAccents as default, removeAccents };
@@ -8,13 +8,9 @@ require('./isNumber.cjs.js');
8
8
  require('./getType.cjs.js');
9
9
  require('./isUndefined.cjs.js');
10
10
 
11
- let removeCookie = (name, attributes = {}) => {
12
- setCookie.setCookie(name, "", {
13
- ...cookie.defaultAttributesClient,
14
- ...attributes,
15
- expires: -1,
16
- });
17
- };
11
+ /**
12
+ * @category cookie
13
+ */let removeCookie=(r,i={})=>{setCookie.setCookie(r,"",{...cookie.defaultAttributesClient,...i,expires:-1});};
18
14
 
19
15
  exports["default"] = removeCookie;
20
16
  exports.removeCookie = removeCookie;
@@ -4,12 +4,8 @@ import './isNumber.esm.js';
4
4
  import './getType.esm.js';
5
5
  import './isUndefined.esm.js';
6
6
 
7
- let removeCookie = (name, attributes = {}) => {
8
- setCookie(name, "", {
9
- ...defaultAttributesClient,
10
- ...attributes,
11
- expires: -1,
12
- });
13
- };
7
+ /**
8
+ * @category cookie
9
+ */let removeCookie=(r,i={})=>{setCookie(r,"",{...defaultAttributesClient,...i,expires:-1});};
14
10
 
15
11
  export { removeCookie as default, removeCookie };
@@ -2,7 +2,14 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- let removeDuplicates = (arr) => [...new Set(arr)];
5
+ /**
6
+ * FIXME: Type 'Set<any>' can only be iterated through when using the
7
+ * '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.
8
+ * I am not sure I want to use those ts options here. Let's keep it commented
9
+ * for now
10
+ *
11
+ * @category array
12
+ */let removeDuplicates=e=>[...new Set(e)];
6
13
 
7
14
  exports["default"] = removeDuplicates;
8
15
  exports.removeDuplicates = removeDuplicates;
@@ -1,3 +1,10 @@
1
- let removeDuplicates = (arr) => [...new Set(arr)];
1
+ /**
2
+ * FIXME: Type 'Set<any>' can only be iterated through when using the
3
+ * '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.
4
+ * I am not sure I want to use those ts options here. Let's keep it commented
5
+ * for now
6
+ *
7
+ * @category array
8
+ */let removeDuplicates=e=>[...new Set(e)];
2
9
 
3
10
  export { removeDuplicates as default, removeDuplicates };
@@ -2,18 +2,12 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- let removeDuplicatesByKey = (array = [], key) => {
6
- const keysMap = {};
7
- const output = [];
8
- for (let i = 0; i < array.length; i++) {
9
- const item = array[i];
10
- if (!keysMap[item[key]]) {
11
- output.push(item);
12
- keysMap[item[key]] = true;
13
- }
14
- }
15
- return output;
16
- };
5
+ /**
6
+ * Remove duplicated array objects, equality is determined by a strict (`===`)
7
+ * comparison of each object's given key
8
+ *
9
+ * @category array
10
+ */let removeDuplicatesByKey=(e=[],t)=>{let l={},r=[];for(let o=0;o<e.length;o++){let p=e[o];l[p[t]]||(r.push(p),l[p[t]]=!0);}return r};
17
11
 
18
12
  exports["default"] = removeDuplicatesByKey;
19
13
  exports.removeDuplicatesByKey = removeDuplicatesByKey;
@@ -1,14 +1,8 @@
1
- let removeDuplicatesByKey = (array = [], key) => {
2
- const keysMap = {};
3
- const output = [];
4
- for (let i = 0; i < array.length; i++) {
5
- const item = array[i];
6
- if (!keysMap[item[key]]) {
7
- output.push(item);
8
- keysMap[item[key]] = true;
9
- }
10
- }
11
- return output;
12
- };
1
+ /**
2
+ * Remove duplicated array objects, equality is determined by a strict (`===`)
3
+ * comparison of each object's given key
4
+ *
5
+ * @category array
6
+ */let removeDuplicatesByKey=(e=[],t)=>{let l={},r=[];for(let o=0;o<e.length;o++){let p=e[o];l[p[t]]||(r.push(p),l[p[t]]=!0);}return r};
13
7
 
14
8
  export { removeDuplicatesByKey as default, removeDuplicatesByKey };
@@ -5,10 +5,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var findDuplicatedIndexes = require('./findDuplicatedIndexes.cjs.js');
6
6
  var removeIndexesFromArray = require('./removeIndexesFromArray.cjs.js');
7
7
 
8
- let removeDuplicatesComparing = (from, to) => {
9
- const indexes = findDuplicatedIndexes.findDuplicatedIndexes(from);
10
- return removeIndexesFromArray.removeIndexesFromArray(to, indexes);
11
- };
8
+ /**
9
+ * @category array
10
+ */let removeDuplicatesComparing=(o,m)=>removeIndexesFromArray.removeIndexesFromArray(m,findDuplicatedIndexes.findDuplicatedIndexes(o));
12
11
 
13
12
  exports["default"] = removeDuplicatesComparing;
14
13
  exports.removeDuplicatesComparing = removeDuplicatesComparing;
@@ -1,9 +1,8 @@
1
1
  import { findDuplicatedIndexes } from './findDuplicatedIndexes.esm.js';
2
2
  import { removeIndexesFromArray } from './removeIndexesFromArray.esm.js';
3
3
 
4
- let removeDuplicatesComparing = (from, to) => {
5
- const indexes = findDuplicatedIndexes(from);
6
- return removeIndexesFromArray(to, indexes);
7
- };
4
+ /**
5
+ * @category array
6
+ */let removeDuplicatesComparing=(o,m)=>removeIndexesFromArray(m,findDuplicatedIndexes(o));
8
7
 
9
8
  export { removeDuplicatesComparing as default, removeDuplicatesComparing };
@@ -2,15 +2,10 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- let removeIndexesFromArray = (arr, indexes) => {
6
- const output = [];
7
- for (let i = 0; i < arr.length; i++) {
8
- if (!indexes.hasOwnProperty(i)) {
9
- output.push(arr[i]);
10
- }
11
- }
12
- return output;
13
- };
5
+ /**
6
+ * @category array
7
+ */let removeIndexesFromArray=(e,r)=>{let t=[];for(let o=0;o<e.length;o++)// eslint-disable-next-line no-prototype-builtins
8
+ r.hasOwnProperty(o)||t.push(e[o]);return t};
14
9
 
15
10
  exports["default"] = removeIndexesFromArray;
16
11
  exports.removeIndexesFromArray = removeIndexesFromArray;
@@ -1,11 +1,6 @@
1
- let removeIndexesFromArray = (arr, indexes) => {
2
- const output = [];
3
- for (let i = 0; i < arr.length; i++) {
4
- if (!indexes.hasOwnProperty(i)) {
5
- output.push(arr[i]);
6
- }
7
- }
8
- return output;
9
- };
1
+ /**
2
+ * @category array
3
+ */let removeIndexesFromArray=(e,r)=>{let t=[];for(let o=0;o<e.length;o++)// eslint-disable-next-line no-prototype-builtins
4
+ r.hasOwnProperty(o)||t.push(e[o]);return t};
10
5
 
11
6
  export { removeIndexesFromArray as default, removeIndexesFromArray };
@@ -2,7 +2,11 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- let removeTrailingSlash = (urlLike) => (urlLike || "").replace(/\/*$/, "");
5
+ /**
6
+ * Strips out the trailing slash
7
+ *
8
+ * @category location
9
+ */let removeTrailingSlash=e=>(e||"").replace(/\/*$/,"");
6
10
 
7
11
  exports["default"] = removeTrailingSlash;
8
12
  exports.removeTrailingSlash = removeTrailingSlash;
@@ -1,3 +1,7 @@
1
- let removeTrailingSlash = (urlLike) => (urlLike || "").replace(/\/*$/, "");
1
+ /**
2
+ * Strips out the trailing slash
3
+ *
4
+ * @category location
5
+ */let removeTrailingSlash=e=>(e||"").replace(/\/*$/,"");
2
6
 
3
7
  export { removeTrailingSlash as default, removeTrailingSlash };
@@ -10,17 +10,11 @@ require('./isNull.cjs.js');
10
10
  require('./isUndefined.cjs.js');
11
11
  require('./isBrowser.cjs.js');
12
12
 
13
- let removeUrlQueryParams = (url, paramsToRemove = []) => {
14
- const parts = url.split("?");
15
- const allParams = getUrlQueryParams.getUrlQueryParams(url);
16
- const params = {};
17
- for (const key in allParams) {
18
- if (!paramsToRemove.includes(key)) {
19
- params[key] = allParams[key];
20
- }
21
- }
22
- return parts[0] + buildUrlQueryString.buildUrlQueryString(params);
23
- };
13
+ /**
14
+ * Remove the given keys from the given URL query parameters
15
+ *
16
+ * @category location
17
+ */let removeUrlQueryParams=(t,l=[])=>{let m=t.split("?"),o=getUrlQueryParams.getUrlQueryParams(t),u={};for(let r in o)l.includes(r)||(u[r]=o[r]);return m[0]+buildUrlQueryString.buildUrlQueryString(u)};
24
18
 
25
19
  exports["default"] = removeUrlQueryParams;
26
20
  exports.removeUrlQueryParams = removeUrlQueryParams;
@@ -6,16 +6,10 @@ import './isNull.esm.js';
6
6
  import './isUndefined.esm.js';
7
7
  import './isBrowser.esm.js';
8
8
 
9
- let removeUrlQueryParams = (url, paramsToRemove = []) => {
10
- const parts = url.split("?");
11
- const allParams = getUrlQueryParams(url);
12
- const params = {};
13
- for (const key in allParams) {
14
- if (!paramsToRemove.includes(key)) {
15
- params[key] = allParams[key];
16
- }
17
- }
18
- return parts[0] + buildUrlQueryString(params);
19
- };
9
+ /**
10
+ * Remove the given keys from the given URL query parameters
11
+ *
12
+ * @category location
13
+ */let removeUrlQueryParams=(t,l=[])=>{let m=t.split("?"),o=getUrlQueryParams(t),u={};for(let r in o)l.includes(r)||(u[r]=o[r]);return m[0]+buildUrlQueryString(u)};
20
14
 
21
15
  export { removeUrlQueryParams as default, removeUrlQueryParams };
package/render.cjs.js CHANGED
@@ -2,118 +2,58 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- let varname = "data";
6
- let evaluate = /<%([\s\S]+?(\}?)+)%>/g;
7
- let interpolate = /<%=([\s\S]+?)%>/g;
8
- let conditional = /<%\?(\?)?\s*([\s\S]*?)\s*%>/g;
9
- let iterate = /<%~\s*(?:%>|([\s\S]+?)\s*:\s*([\w$]+)\s*(?::\s*([\w$]+))?\s*%>)/g;
10
- let use = /<%#([\s\S]+?)%>/g;
11
- let useParams = /(^|[^\w$])def(?:\.|\[['"])([\w$.]+)(?:['"]\])?\s*:\s*([\w$.]+|"[^"]+"|'[^']+'|\{[^}]+\})/g;
12
- let define = /<%##\s*([\w.$]+)\s*(:|=)([\s\S]+?)#%>/g;
13
- let defineParams = /^\s*([\w$]+):([\s\S]+)/;
14
- let start = "'+(";
15
- let end = ")+'";
16
- let skip = /$^/;
17
- let resolveDefs = (block, def) => (typeof block === "string" ? block : block.toString())
18
- .replace(define || skip, (_, code, assign, value) => {
19
- if (code.indexOf("def.") === 0) {
20
- code = code.substring(4);
21
- }
22
- if (!(code in def)) {
23
- if (assign === ":") {
24
- value.replace(defineParams, (_, param, v) => {
25
- def[code] = { arg: param, text: v };
26
- });
27
- if (!(code in def))
28
- def[code] = value;
29
- }
30
- else {
31
- new Function("def", "def['" + code + "']=" + value)(def);
32
- }
33
- }
34
- return "";
35
- })
36
- .replace(use || skip, (_, code) => {
37
- code = code.replace(useParams, (_, s, d, param) => {
38
- if (def[d] && def[d].arg && param) {
39
- let rw = (d + ":" + param).replace(/'|\\/g, "_");
40
- def.__exp = def.__exp || {};
41
- def.__exp[rw] = def[d].text.replace(new RegExp("(^|[^\\w$])" + def[d].arg + "([^\\w$])", "g"), "$1" + param + "$2");
42
- return s + "def.__exp['" + rw + "']";
43
- }
44
- return s;
45
- });
46
- let v = new Function("def", "return " + code)(def);
47
- return v ? resolveDefs(v, def) : v;
48
- });
49
- let unescape = (code) => code.replace(/\\('|\\)/g, "$1").replace(/[\r\t\n]/g, " ");
50
- let render = (tmpl, def) => {
51
- let sid = 0;
52
- let indv;
53
- let str = use || define ? resolveDefs(tmpl, def || {}) : tmpl;
54
- str = ("var X='" +
55
- str
56
- .replace(/(^|\r|\n)\t* +| +\t*(\r|\n|$)/g, " ")
57
- .replace(/\r|\n|\t|\/\*[\s\S]*?\*\//g, "")
58
- .replace(/'|\\/g, "\\$&")
59
- .replace(interpolate || skip, (_, code) => start + unescape(code) + end)
60
- .replace(conditional || skip, (_, elseCase, code) => elseCase
61
- ? code
62
- ? "';}else if(" + unescape(code) + "){X+='"
63
- : "';}else{X+='"
64
- : code
65
- ? "';if(" + unescape(code) + "){X+='"
66
- : "';}X+='")
67
- .replace(iterate || skip, (_, arr, vName, iName) => {
68
- if (!arr)
69
- return "';} } X+='";
70
- sid++;
71
- indv = iName || "i" + sid;
72
- arr = unescape(arr);
73
- return ("';var arr" +
74
- sid +
75
- "=" +
76
- arr +
77
- ";if(arr" +
78
- sid +
79
- "){var " +
80
- vName +
81
- "," +
82
- indv +
83
- "=-1,l" +
84
- sid +
85
- "=arr" +
86
- sid +
87
- ".length-1;while(" +
88
- indv +
89
- "<l" +
90
- sid +
91
- "){" +
92
- vName +
93
- "=arr" +
94
- sid +
95
- "[" +
96
- indv +
97
- "+=1];X+='");
98
- })
99
- .replace(evaluate || skip, (_, code) => "';" + unescape(code) + "X+='") +
100
- "';return X;")
101
- .replace(/\n/g, "\\n")
102
- .replace(/\t/g, "\\t")
103
- .replace(/\r/g, "\\r")
104
- .replace(/(\s|;|\}|^|\{)X\+='';/g, "$1")
105
- .replace(/\+''/g, "");
106
- try {
107
- return new Function(varname, str);
108
- }
109
- catch (e) {
110
- if (process.env["NODE_ENV"] === "development") {
111
- console.log("Could not create a template function: " + str);
112
- throw e;
113
- }
114
- }
115
- return () => "";
116
- };
5
+ let e=/<%([\s\S]+?(\}?)+)%>/g,r=/<%=([\s\S]+?)%>/g,t=/<%\?(\?)?\s*([\s\S]*?)\s*%>/g,a=/<%~\s*(?:%>|([\s\S]+?)\s*:\s*([\w$]+)\s*(?::\s*([\w$]+))?\s*%>)/g,// let encode = /<%!([\s\S]+?)%>/g;
6
+ l=/<%#([\s\S]+?)%>/g,n=/(^|[^\w$])def(?:\.|\[['"])([\w$.]+)(?:['"]\])?\s*:\s*([\w$.]+|"[^"]+"|'[^']+'|\{[^}]+\})/g,p=/<%##\s*([\w.$]+)\s*(:|=)([\s\S]+?)#%>/g,s=/^\s*([\w$]+):([\s\S]+)/,// let startencode = "'+encodeHTML(";
7
+ c=/$^/,g=(e,r)=>("string"==typeof e?e:e.toString()).replace(p||c,(e,t,a,l)=>(0===t.indexOf("def.")&&(t=t.substring(4)),t in r||(":"===a?(l.replace(s,// @ts-expect-error nevermind
8
+ (e,a,l)=>{r[t]={arg:a,text:l};}),// @ts-expect-error nevermind
9
+ t in r||(r[t]=l)):Function("def","def['"+t+"']="+l)(r)),"")).replace(l||c,(e,t)=>{let a=Function("def","return "+(t=t.replace(n,(e,t,a,l)=>{if(r[a]&&r[a].arg&&l){let e=(a+":"+l).replace(/'|\\/g,"_");return r.__exp=r.__exp||{},r.__exp[e]=r[a].text.replace(RegExp("(^|[^\\w$])"+r[a].arg+"([^\\w$])","g"),"$1"+l+"$2"),t+"def.__exp['"+e+"']"}return t})))(r);return a?g(a,r):a}),i=e=>e.replace(/\\('|\\)/g,"$1").replace(/[\r\t\n]/g," ");/**
10
+ * Render template (adapted from doT.js)
11
+ *
12
+ * The data made available to the template is always on the `data` key, e.g.:
13
+ * `renderer({ myVal: "xx" })`
14
+ * ... will be accessible on
15
+ * `<%= data.myVal %>`
16
+ *
17
+ * The default delimiters are customised to work without conflicts with Blade and Twig:
18
+ * ```
19
+ * <% %> for evaluation
20
+ * <%= %> for interpolation
21
+ * <%? %> for conditionals
22
+ * <%~ %> for array iteration
23
+ * <%# %> for compile-time evaluation/includes and partials
24
+ * <%## #%> for compile-time defines
25
+ *
26
+ * Unsupported:
27
+ * <%! %> for interpolation with encoding
28
+ * ```
29
+ *
30
+ * @category impl
31
+ * @example
32
+ *
33
+ * ```ts
34
+ * import { render } from "...";
35
+ *
36
+ * const data = { name: "XYZ" };
37
+ * const tpl = `Hello <%= data.name %>`;
38
+ * const renderer = render(tpl);
39
+ *
40
+ * console.log(renderer(data)); // outputs 'Hello XYZ'
41
+ * ```
42
+ *
43
+ * @borrows [olado/doT by Laura Doktorova](https://github.com/olado/doT)
44
+ * @see https://olado.github.io/doT/index.html
45
+ */let render=(n,s)=>{let o,$=0,f=l||p?g(n,s||{}):n;f=("var X='"+f.replace(/(^|\r|\n)\t* +| +\t*(\r|\n|$)/g," ").replace(/\r|\n|\t|\/\*[\s\S]*?\*\//g,"").replace(/'|\\/g,"\\$&").replace(r||c,(e,r)=>"'+("+i(r)+")+'").// .replace(
46
+ // encode || skip,
47
+ // (_, code) => cse.startencode + unescape(code) + cse.end
48
+ // )
49
+ replace(t||c,(e,r,t)=>r?t?"';}else if("+i(t)+"){X+='":"';}else{X+='":t?"';if("+i(t)+"){X+='":"';}X+='").replace(a||c,(e,r,t,a)=>r?($++,o=a||"i"+$,r=i(r),"';var arr"+$+"="+r+";if(arr"+$+"){var "+t+","+o+"=-1,l"+$+"=arr"+$+".length-1;while("+o+"<l"+$+"){"+t+"=arr"+$+"["+o+"+=1];X+='"):"';} } X+='").replace(e||c,(e,r)=>"';"+i(r)+"X+='")+"';return X;").replace(/\n/g,"\\n").replace(/\t/g,"\\t").replace(/\r/g,"\\r").replace(/(\s|;|\}|^|\{)X\+='';/g,"$1").replace(/\+''/g,"");//.replace(/(\s|;|\}|^|\{)X\+=''\+/g,'$1X+=');
50
+ try{return Function(// RenderData;
51
+ /**
52
+ * Returned render function
53
+ *//**
54
+ * Default render function creator
55
+ */// eslint-disable-next-line @typescript-eslint/no-unused-vars
56
+ "data",f)}catch(e){if("development"===process.env.NODE_ENV)throw console.log("Could not create a template function: "+f),e}return ()=>""};
117
57
 
118
58
  exports["default"] = render;
119
59
  exports.render = render;