@koine/utils 2.0.0-beta.4 → 2.0.0-beta.42

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 (451) hide show
  1. package/Defer.d.ts +0 -15
  2. package/Emitter.d.ts +2 -21
  3. package/README.md +4 -2
  4. package/accentSets.d.ts +1 -15
  5. package/addOrReplaceAtIdx.d.ts +1 -5
  6. package/areEqual.d.ts +2 -17
  7. package/arrayFilterFalsy.d.ts +1 -0
  8. package/arrayOfAll.d.ts +1 -28
  9. package/arraySum.d.ts +1 -7
  10. package/arrayToLookup.d.ts +1 -7
  11. package/arrayUniqueByProperties.d.ts +1 -0
  12. package/buildUrlQueryString.d.ts +2 -12
  13. package/capitalize.d.ts +1 -8
  14. package/changeCaseCamel.d.ts +2 -0
  15. package/changeCaseCapital.d.ts +2 -0
  16. package/changeCaseConstant.d.ts +2 -0
  17. package/changeCaseDot.d.ts +2 -0
  18. package/changeCaseHelpers.d.ts +19 -0
  19. package/changeCaseKebab.d.ts +2 -0
  20. package/changeCaseNone.d.ts +2 -0
  21. package/changeCasePascal.d.ts +2 -0
  22. package/changeCasePascalSnake.d.ts +2 -0
  23. package/changeCasePath.d.ts +2 -0
  24. package/changeCaseSentence.d.ts +2 -0
  25. package/changeCaseSnake.d.ts +2 -0
  26. package/changeCaseTrain.d.ts +2 -0
  27. package/chunkByChunks.d.ts +1 -7
  28. package/chunkBySize.d.ts +1 -6
  29. package/clamp.d.ts +1 -8
  30. package/clsx.d.ts +6 -9
  31. package/convertRange.d.ts +1 -14
  32. package/cookie.d.ts +1 -37
  33. package/createPalette.d.ts +2 -12
  34. package/debounce.d.ts +1 -8
  35. package/debouncePromise.d.ts +10 -11
  36. package/debounceRaf.d.ts +0 -8
  37. package/decode.d.ts +1 -6
  38. package/encode.d.ts +1 -6
  39. package/ensureInt.d.ts +1 -7
  40. package/env.d.ts +0 -0
  41. package/errorToString.d.ts +1 -7
  42. package/findDuplicatedIndexes.d.ts +1 -5
  43. package/forin.d.ts +1 -7
  44. package/gbToBytes.d.ts +1 -7
  45. package/getEmptyArray.d.ts +1 -9
  46. package/getKeys.d.ts +1 -9
  47. package/getMediaQueryWidthResolvers.d.ts +1 -2
  48. package/getMediaQueryWidthTailwindScreens.d.ts +1 -2
  49. package/getNonce.d.ts +1 -6
  50. package/getParamAmong.d.ts +1 -12
  51. package/getParamAsInt.d.ts +1 -12
  52. package/getParamAsString.d.ts +1 -11
  53. package/getType.d.ts +4 -17
  54. package/getUrlHashParams.d.ts +1 -9
  55. package/getUrlHashPathname.d.ts +1 -9
  56. package/getUrlPathnameParts.d.ts +1 -12
  57. package/getUrlQueryParams.d.ts +1 -14
  58. package/imgEmptyPixel.d.ts +1 -7
  59. package/index.cjs.d.ts +1 -0
  60. package/index.cjs.default.js +1 -0
  61. package/index.cjs.js +482 -0
  62. package/index.cjs.mjs +2 -0
  63. package/index.d.ts +24 -5
  64. package/index.esm.js +330 -0
  65. package/invariant.d.ts +1 -19
  66. package/isAnyObject.d.ts +2 -8
  67. package/isArray.d.ts +1 -7
  68. package/isBlob.d.ts +1 -7
  69. package/isBoolean.d.ts +1 -7
  70. package/isBrowser.d.ts +1 -6
  71. package/isBrowserNow.d.ts +1 -6
  72. package/isDate.d.ts +1 -7
  73. package/isEmptyArray.d.ts +1 -7
  74. package/isEmptyObject.d.ts +4 -8
  75. package/isEmptyString.d.ts +1 -7
  76. package/isError.d.ts +1 -7
  77. package/isExternalUrl.d.ts +1 -9
  78. package/isFile.d.ts +1 -7
  79. package/isFloat.d.ts +1 -7
  80. package/isFormData.d.ts +1 -7
  81. package/isFullArray.d.ts +1 -7
  82. package/isFullObject.d.ts +2 -8
  83. package/isFullString.d.ts +1 -7
  84. package/isFunction.d.ts +2 -8
  85. package/isInt.d.ts +1 -7
  86. package/isMap.d.ts +1 -7
  87. package/isNaNValue.d.ts +1 -7
  88. package/isNegativeNumber.d.ts +1 -7
  89. package/isNull.d.ts +1 -7
  90. package/isNullOrUndefined.d.ts +1 -7
  91. package/isNumber.d.ts +1 -9
  92. package/isNumericLiteral.d.ts +1 -0
  93. package/isObject.d.ts +2 -8
  94. package/isObjectLike.d.ts +2 -10
  95. package/isObjectStringKeyed.d.ts +2 -0
  96. package/isOneOf.d.ts +1 -5
  97. package/isPlainObject.d.ts +2 -8
  98. package/isPositiveNumber.d.ts +1 -7
  99. package/isPrimitive.d.ts +1 -7
  100. package/isPromise.d.ts +1 -7
  101. package/isRegExp.d.ts +1 -7
  102. package/isServer.d.ts +1 -6
  103. package/isServerNow.d.ts +1 -6
  104. package/isSet.d.ts +1 -7
  105. package/isString.d.ts +1 -7
  106. package/isSymbol.d.ts +1 -7
  107. package/isType.d.ts +2 -11
  108. package/isUndefined.d.ts +1 -7
  109. package/isWeakMap.d.ts +1 -7
  110. package/isWeakSet.d.ts +1 -7
  111. package/kbToBytes.d.ts +1 -7
  112. package/location.d.ts +0 -3
  113. package/lowercase.d.ts +1 -7
  114. package/mapListBy.d.ts +1 -7
  115. package/matchSorter.d.ts +2 -10
  116. package/mbToBytes.d.ts +1 -7
  117. package/mergeObjects.d.ts +1 -7
  118. package/mergeUrlQueryParams.d.ts +2 -9
  119. package/moveSortableArrayItemByKey.d.ts +1 -9
  120. package/noop.d.ts +1 -7
  121. package/normaliseUrl.d.ts +1 -11
  122. package/normaliseUrlPathname.d.ts +1 -10
  123. package/objectFlat.d.ts +3 -0
  124. package/objectFlip.d.ts +1 -0
  125. package/objectOmit.d.ts +1 -11
  126. package/objectPick.d.ts +1 -8
  127. package/objectSortByKeysMatching.d.ts +3 -0
  128. package/objectToArray.d.ts +1 -0
  129. package/package.json +9 -10
  130. package/parseCookie.d.ts +2 -11
  131. package/parseURL.d.ts +1 -8
  132. package/quaranteneProps.d.ts +2 -17
  133. package/randomInt.d.ts +1 -7
  134. package/randomKey.d.ts +1 -8
  135. package/readCookie.d.ts +0 -1
  136. package/removeAccents.d.ts +2 -6
  137. package/removeCookie.d.ts +1 -9
  138. package/removeDuplicates.d.ts +0 -0
  139. package/removeDuplicatesByKey.d.ts +1 -8
  140. package/removeDuplicatesComparing.d.ts +1 -5
  141. package/removeIndexesFromArray.d.ts +1 -5
  142. package/removeTrailingSlash.d.ts +1 -7
  143. package/removeUrlQueryParams.d.ts +1 -8
  144. package/render.d.ts +2 -41
  145. package/round.d.ts +2 -0
  146. package/roundTo.d.ts +1 -8
  147. package/serializeCookie.d.ts +2 -27
  148. package/setCookie.d.ts +1 -9
  149. package/shuffle.d.ts +1 -16
  150. package/slugify.d.ts +1 -11
  151. package/split.d.ts +1 -2
  152. package/splitReverse.d.ts +4 -0
  153. package/swapMap.d.ts +1 -7
  154. package/throttle.d.ts +1 -8
  155. package/titleCase.d.ts +1 -7
  156. package/toNumber.d.ts +1 -5
  157. package/toRgba.d.ts +1 -5
  158. package/transformToUrlPathname.d.ts +1 -11
  159. package/truncate.d.ts +1 -7
  160. package/tryUntil.d.ts +1 -8
  161. package/types.d.ts +1 -18
  162. package/typings.d.ts +31 -5
  163. package/uid.d.ts +1 -7
  164. package/updateLinkParams.d.ts +2 -10
  165. package/updateUrlQueryParams.d.ts +2 -9
  166. package/uppercase.d.ts +1 -7
  167. package/uuid.d.ts +1 -8
  168. package/uuidNumeric.d.ts +1 -6
  169. package/wait.d.ts +1 -7
  170. package/without.d.ts +0 -0
  171. package/Defer.js +0 -35
  172. package/Defer.mjs +0 -27
  173. package/Emitter.js +0 -53
  174. package/Emitter.mjs +0 -35
  175. package/accentSets.js +0 -133
  176. package/accentSets.mjs +0 -122
  177. package/addOrReplaceAtIdx.js +0 -40
  178. package/addOrReplaceAtIdx.mjs +0 -22
  179. package/areEqual.js +0 -75
  180. package/areEqual.mjs +0 -71
  181. package/arrayOfAll.js +0 -45
  182. package/arrayOfAll.mjs +0 -27
  183. package/arraySum.js +0 -24
  184. package/arraySum.mjs +0 -6
  185. package/arrayToLookup.js +0 -29
  186. package/arrayToLookup.mjs +0 -11
  187. package/buildUrlQueryString.js +0 -39
  188. package/buildUrlQueryString.mjs +0 -28
  189. package/capitalize.js +0 -28
  190. package/capitalize.mjs +0 -10
  191. package/changeUrlPath.d.ts +0 -10
  192. package/changeUrlPath.js +0 -29
  193. package/changeUrlPath.mjs +0 -17
  194. package/chunkByChunks.js +0 -52
  195. package/chunkByChunks.mjs +0 -34
  196. package/chunkBySize.js +0 -29
  197. package/chunkBySize.mjs +0 -11
  198. package/clamp.js +0 -27
  199. package/clamp.mjs +0 -9
  200. package/clsx.js +0 -59
  201. package/clsx.mjs +0 -46
  202. package/convertRange.js +0 -33
  203. package/convertRange.mjs +0 -15
  204. package/cookie.js +0 -21
  205. package/cookie.mjs +0 -11
  206. package/createPalette.js +0 -34
  207. package/createPalette.mjs +0 -25
  208. package/debounce.js +0 -39
  209. package/debounce.mjs +0 -21
  210. package/debouncePromise.js +0 -21
  211. package/debouncePromise.mjs +0 -8
  212. package/debounceRaf.js +0 -40
  213. package/debounceRaf.mjs +0 -22
  214. package/decode.js +0 -27
  215. package/decode.mjs +0 -9
  216. package/encode.js +0 -27
  217. package/encode.mjs +0 -9
  218. package/ensureInt.js +0 -24
  219. package/ensureInt.mjs +0 -6
  220. package/env.js +0 -3
  221. package/env.mjs +0 -2
  222. package/errorToString.js +0 -22
  223. package/errorToString.mjs +0 -7
  224. package/findDuplicatedIndexes.js +0 -31
  225. package/findDuplicatedIndexes.mjs +0 -13
  226. package/forin.js +0 -28
  227. package/forin.mjs +0 -10
  228. package/gbToBytes.js +0 -24
  229. package/gbToBytes.mjs +0 -6
  230. package/getEmptyArray.js +0 -29
  231. package/getEmptyArray.mjs +0 -16
  232. package/getKeys.js +0 -26
  233. package/getKeys.mjs +0 -8
  234. package/getMediaQueryWidthResolvers.js +0 -81
  235. package/getMediaQueryWidthResolvers.mjs +0 -63
  236. package/getMediaQueryWidthTailwindScreens.js +0 -51
  237. package/getMediaQueryWidthTailwindScreens.mjs +0 -33
  238. package/getNonce.js +0 -23
  239. package/getNonce.mjs +0 -8
  240. package/getParamAmong.js +0 -25
  241. package/getParamAmong.mjs +0 -15
  242. package/getParamAsInt.js +0 -28
  243. package/getParamAsInt.mjs +0 -18
  244. package/getParamAsString.js +0 -24
  245. package/getParamAsString.mjs +0 -13
  246. package/getType.js +0 -30
  247. package/getType.mjs +0 -17
  248. package/getUrlHashParams.js +0 -27
  249. package/getUrlHashParams.mjs +0 -14
  250. package/getUrlHashPathname.js +0 -29
  251. package/getUrlHashPathname.mjs +0 -11
  252. package/getUrlPathnameParts.js +0 -25
  253. package/getUrlPathnameParts.mjs +0 -15
  254. package/getUrlQueryParams.js +0 -36
  255. package/getUrlQueryParams.mjs +0 -27
  256. package/imgEmptyPixel.js +0 -24
  257. package/imgEmptyPixel.mjs +0 -6
  258. package/index.js +0 -532
  259. package/index.mjs +0 -132
  260. package/invariant.js +0 -50
  261. package/invariant.mjs +0 -32
  262. package/isAnyObject.js +0 -24
  263. package/isAnyObject.mjs +0 -9
  264. package/isArray.js +0 -24
  265. package/isArray.mjs +0 -9
  266. package/isBlob.js +0 -24
  267. package/isBlob.mjs +0 -9
  268. package/isBoolean.js +0 -24
  269. package/isBoolean.mjs +0 -9
  270. package/isBrowser.js +0 -23
  271. package/isBrowser.mjs +0 -5
  272. package/isBrowserNow.js +0 -22
  273. package/isBrowserNow.mjs +0 -6
  274. package/isDate.js +0 -24
  275. package/isDate.mjs +0 -9
  276. package/isEmptyArray.js +0 -24
  277. package/isEmptyArray.mjs +0 -9
  278. package/isEmptyObject.js +0 -24
  279. package/isEmptyObject.mjs +0 -9
  280. package/isEmptyString.js +0 -26
  281. package/isEmptyString.mjs +0 -8
  282. package/isError.js +0 -24
  283. package/isError.mjs +0 -9
  284. package/isExternalUrl.js +0 -32
  285. package/isExternalUrl.mjs +0 -19
  286. package/isFile.js +0 -24
  287. package/isFile.mjs +0 -9
  288. package/isFloat.js +0 -24
  289. package/isFloat.mjs +0 -9
  290. package/isFormData.js +0 -24
  291. package/isFormData.mjs +0 -9
  292. package/isFullArray.js +0 -24
  293. package/isFullArray.mjs +0 -9
  294. package/isFullObject.js +0 -24
  295. package/isFullObject.mjs +0 -9
  296. package/isFullString.js +0 -24
  297. package/isFullString.mjs +0 -9
  298. package/isFunction.js +0 -22
  299. package/isFunction.mjs +0 -8
  300. package/isInt.js +0 -24
  301. package/isInt.mjs +0 -9
  302. package/isMap.js +0 -24
  303. package/isMap.mjs +0 -9
  304. package/isNaNValue.js +0 -24
  305. package/isNaNValue.mjs +0 -9
  306. package/isNegativeNumber.js +0 -24
  307. package/isNegativeNumber.mjs +0 -9
  308. package/isNull.js +0 -24
  309. package/isNull.mjs +0 -9
  310. package/isNullOrUndefined.js +0 -24
  311. package/isNullOrUndefined.mjs +0 -9
  312. package/isNumber.js +0 -24
  313. package/isNumber.mjs +0 -11
  314. package/isObject.js +0 -24
  315. package/isObject.mjs +0 -9
  316. package/isObjectLike.js +0 -24
  317. package/isObjectLike.mjs +0 -11
  318. package/isOneOf.js +0 -22
  319. package/isOneOf.mjs +0 -4
  320. package/isPlainObject.js +0 -25
  321. package/isPlainObject.mjs +0 -10
  322. package/isPositiveNumber.js +0 -24
  323. package/isPositiveNumber.mjs +0 -9
  324. package/isPrimitive.js +0 -29
  325. package/isPrimitive.mjs +0 -14
  326. package/isPromise.js +0 -24
  327. package/isPromise.mjs +0 -9
  328. package/isRegExp.js +0 -24
  329. package/isRegExp.mjs +0 -9
  330. package/isServer.js +0 -23
  331. package/isServer.mjs +0 -7
  332. package/isServerNow.js +0 -22
  333. package/isServerNow.mjs +0 -6
  334. package/isSet.js +0 -24
  335. package/isSet.mjs +0 -9
  336. package/isString.js +0 -24
  337. package/isString.mjs +0 -9
  338. package/isSymbol.js +0 -24
  339. package/isSymbol.mjs +0 -9
  340. package/isType.js +0 -32
  341. package/isType.mjs +0 -20
  342. package/isUndefined.js +0 -24
  343. package/isUndefined.mjs +0 -9
  344. package/isWeakMap.js +0 -24
  345. package/isWeakMap.mjs +0 -9
  346. package/isWeakSet.js +0 -24
  347. package/isWeakSet.mjs +0 -9
  348. package/kbToBytes.js +0 -24
  349. package/kbToBytes.mjs +0 -6
  350. package/location.js +0 -6
  351. package/location.mjs +0 -3
  352. package/lowercase.js +0 -24
  353. package/lowercase.mjs +0 -6
  354. package/mapListBy.js +0 -29
  355. package/mapListBy.mjs +0 -11
  356. package/matchSorter.js +0 -373
  357. package/matchSorter.mjs +0 -352
  358. package/mbToBytes.js +0 -24
  359. package/mbToBytes.mjs +0 -6
  360. package/mergeObjects.js +0 -39
  361. package/mergeObjects.mjs +0 -34
  362. package/mergeUrlQueryParams.js +0 -32
  363. package/mergeUrlQueryParams.mjs +0 -18
  364. package/moveSortableArrayItemByKey.js +0 -35
  365. package/moveSortableArrayItemByKey.mjs +0 -17
  366. package/noop.js +0 -24
  367. package/noop.mjs +0 -6
  368. package/normaliseUrl.js +0 -24
  369. package/normaliseUrl.mjs +0 -13
  370. package/normaliseUrlPathname.js +0 -24
  371. package/normaliseUrlPathname.mjs +0 -12
  372. package/objectOmit.js +0 -35
  373. package/objectOmit.mjs +0 -17
  374. package/objectPick.js +0 -32
  375. package/objectPick.mjs +0 -14
  376. package/parseCookie.js +0 -55
  377. package/parseCookie.mjs +0 -44
  378. package/parseURL.js +0 -37
  379. package/parseURL.mjs +0 -19
  380. package/quaranteneProps.js +0 -49
  381. package/quaranteneProps.mjs +0 -31
  382. package/randomInt.js +0 -26
  383. package/randomInt.mjs +0 -8
  384. package/randomKey.js +0 -28
  385. package/randomKey.mjs +0 -10
  386. package/readCookie.js +0 -51
  387. package/readCookie.mjs +0 -33
  388. package/removeAccents.js +0 -28
  389. package/removeAccents.mjs +0 -12
  390. package/removeCookie.js +0 -28
  391. package/removeCookie.mjs +0 -16
  392. package/removeDuplicates.js +0 -13
  393. package/removeDuplicates.mjs +0 -12
  394. package/removeDuplicatesByKey.js +0 -36
  395. package/removeDuplicatesByKey.mjs +0 -18
  396. package/removeDuplicatesComparing.js +0 -25
  397. package/removeDuplicatesComparing.mjs +0 -9
  398. package/removeIndexesFromArray.js +0 -31
  399. package/removeIndexesFromArray.mjs +0 -13
  400. package/removeTrailingSlash.js +0 -26
  401. package/removeTrailingSlash.mjs +0 -8
  402. package/removeUrlQueryParams.js +0 -33
  403. package/removeUrlQueryParams.mjs +0 -19
  404. package/render.js +0 -93
  405. package/render.mjs +0 -110
  406. package/roundTo.js +0 -50
  407. package/roundTo.mjs +0 -32
  408. package/serializeCookie.js +0 -102
  409. package/serializeCookie.mjs +0 -98
  410. package/setCookie.js +0 -68
  411. package/setCookie.mjs +0 -55
  412. package/shuffle.js +0 -50
  413. package/shuffle.mjs +0 -32
  414. package/slugify.js +0 -35
  415. package/slugify.mjs +0 -25
  416. package/split.js +0 -22
  417. package/split.mjs +0 -4
  418. package/swapMap.js +0 -30
  419. package/swapMap.mjs +0 -12
  420. package/throttle.js +0 -38
  421. package/throttle.mjs +0 -20
  422. package/titleCase.js +0 -24
  423. package/titleCase.mjs +0 -6
  424. package/toNumber.js +0 -23
  425. package/toNumber.mjs +0 -7
  426. package/toRgba.js +0 -32
  427. package/toRgba.mjs +0 -14
  428. package/transformToUrlPathname.js +0 -24
  429. package/transformToUrlPathname.mjs +0 -13
  430. package/truncate.js +0 -24
  431. package/truncate.mjs +0 -6
  432. package/tryUntil.js +0 -42
  433. package/tryUntil.mjs +0 -24
  434. package/types.js +0 -5
  435. package/types.mjs +0 -2
  436. package/uid.js +0 -24
  437. package/uid.mjs +0 -10
  438. package/updateLinkParams.js +0 -26
  439. package/updateLinkParams.mjs +0 -13
  440. package/updateUrlQueryParams.js +0 -28
  441. package/updateUrlQueryParams.mjs +0 -14
  442. package/uppercase.js +0 -24
  443. package/uppercase.mjs +0 -6
  444. package/uuid.js +0 -28
  445. package/uuid.mjs +0 -10
  446. package/uuidNumeric.js +0 -23
  447. package/uuidNumeric.mjs +0 -5
  448. package/wait.js +0 -24
  449. package/wait.mjs +0 -6
  450. package/without.js +0 -55
  451. package/without.mjs +0 -54
package/setCookie.js DELETED
@@ -1,68 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: all[name]
9
- });
10
- }
11
- _export(exports, {
12
- setCookie: function() {
13
- return setCookie;
14
- },
15
- default: function() {
16
- return _default;
17
- }
18
- });
19
- const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
20
- const _cookie = require("./cookie");
21
- const _isNumber = /*#__PURE__*/ _interop_require_default._(require("./isNumber"));
22
- const _isUndefined = /*#__PURE__*/ _interop_require_default._(require("./isUndefined"));
23
- function converterWrite(value) {
24
- return encodeURIComponent(value).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g, decodeURIComponent);
25
- }
26
- function setCookie(name, value, attributes = {}) {
27
- // eslint-disable-next-line prefer-const
28
- let { expires, ...restAttrs } = attributes;
29
- const cleanedAttrs = {
30
- expires: "",
31
- ..._cookie.defaultAttributesClient,
32
- ...restAttrs
33
- };
34
- if ((0, _isUndefined.default)(document)) {
35
- if (process.env["NODE_ENV"] !== "production") {
36
- console.warn("[@koine/utils:setCookie] document is undefined");
37
- }
38
- return undefined;
39
- }
40
- if ((0, _isNumber.default)(expires)) {
41
- expires = new Date(Date.now() + expires * 864e5);
42
- }
43
- if (expires) {
44
- cleanedAttrs.expires = expires.toUTCString();
45
- }
46
- name = encodeURIComponent(name).replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape);
47
- let stringifiedAttributes = "";
48
- for(const name in attributes){
49
- const attrName = name;
50
- if (!attributes[attrName]) {
51
- continue;
52
- }
53
- stringifiedAttributes += "; " + attrName;
54
- if (attributes[attrName] === true) {
55
- continue;
56
- }
57
- // Considers RFC 6265 section 5.2:
58
- // ...
59
- // 3. If the remaining unparsed-attributes contains a %x3B (";")
60
- // character:
61
- // Consume the characters of the unparsed-attributes up to,
62
- // not including, the first %x3B (";") character.
63
- // ...
64
- stringifiedAttributes += "=" + String(attributes[attrName]).split(";")[0];
65
- }
66
- return document.cookie = name + "=" + converterWrite(value) + stringifiedAttributes;
67
- }
68
- const _default = setCookie;
package/setCookie.mjs DELETED
@@ -1,55 +0,0 @@
1
- import { defaultAttributesClient } from "./cookie";
2
- import isNumber from "./isNumber";
3
- import isUndefined from "./isUndefined";
4
- function converterWrite(value) {
5
- return encodeURIComponent(value).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g, decodeURIComponent);
6
- }
7
- /**
8
- * @category cookie
9
- *
10
- * All cookie related code is inspired and adapted from:
11
- * - [js-cookie](https://github.com/js-cookie/js-cookie)
12
- * - [cookie](https://github.com/jshttp/cookie)
13
- */ export function setCookie(name, value, attributes = {}) {
14
- // eslint-disable-next-line prefer-const
15
- let { expires, ...restAttrs } = attributes;
16
- const cleanedAttrs = {
17
- expires: "",
18
- ...defaultAttributesClient,
19
- ...restAttrs
20
- };
21
- if (isUndefined(document)) {
22
- if (process.env["NODE_ENV"] !== "production") {
23
- console.warn("[@koine/utils:setCookie] document is undefined");
24
- }
25
- return undefined;
26
- }
27
- if (isNumber(expires)) {
28
- expires = new Date(Date.now() + expires * 864e5);
29
- }
30
- if (expires) {
31
- cleanedAttrs.expires = expires.toUTCString();
32
- }
33
- name = encodeURIComponent(name).replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape);
34
- let stringifiedAttributes = "";
35
- for(const name in attributes){
36
- const attrName = name;
37
- if (!attributes[attrName]) {
38
- continue;
39
- }
40
- stringifiedAttributes += "; " + attrName;
41
- if (attributes[attrName] === true) {
42
- continue;
43
- }
44
- // Considers RFC 6265 section 5.2:
45
- // ...
46
- // 3. If the remaining unparsed-attributes contains a %x3B (";")
47
- // character:
48
- // Consume the characters of the unparsed-attributes up to,
49
- // not including, the first %x3B (";") character.
50
- // ...
51
- stringifiedAttributes += "=" + String(attributes[attrName]).split(";")[0];
52
- }
53
- return document.cookie = name + "=" + converterWrite(value) + stringifiedAttributes;
54
- }
55
- export default setCookie;
package/shuffle.js DELETED
@@ -1,50 +0,0 @@
1
- /**
2
- * Creates an array of shuffled values, using a version of the
3
- * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
4
- *
5
- * @see lodash.shuffle
6
- * @since 0.1.0
7
- * @category arrays
8
- * @param {Array} array The array to shuffle.
9
- * @returns {Array} Returns the new shuffled array.
10
- * @example
11
- *
12
- * shuffle([1, 2, 3, 4])
13
- * // => [4, 1, 3, 2]
14
- */ "use strict";
15
- Object.defineProperty(exports, "__esModule", {
16
- value: true
17
- });
18
- function _export(target, all) {
19
- for(var name in all)Object.defineProperty(target, name, {
20
- enumerable: true,
21
- get: all[name]
22
- });
23
- }
24
- _export(exports, {
25
- shuffle: function() {
26
- return shuffle;
27
- },
28
- default: function() {
29
- return _default;
30
- }
31
- });
32
- function shuffle(array) {
33
- const length = array == null ? 0 : array.length;
34
- if (!length) {
35
- return [];
36
- }
37
- let index = -1;
38
- const lastIndex = length - 1;
39
- const result = [
40
- ...array
41
- ];
42
- while(++index < length){
43
- const rand = index + Math.floor(Math.random() * (lastIndex - index + 1));
44
- const value = result[rand];
45
- result[rand] = result[index];
46
- result[index] = value;
47
- }
48
- return result;
49
- }
50
- const _default = shuffle;
package/shuffle.mjs DELETED
@@ -1,32 +0,0 @@
1
- /**
2
- * Creates an array of shuffled values, using a version of the
3
- * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
4
- *
5
- * @see lodash.shuffle
6
- * @since 0.1.0
7
- * @category arrays
8
- * @param {Array} array The array to shuffle.
9
- * @returns {Array} Returns the new shuffled array.
10
- * @example
11
- *
12
- * shuffle([1, 2, 3, 4])
13
- * // => [4, 1, 3, 2]
14
- */ export function shuffle(array) {
15
- const length = array == null ? 0 : array.length;
16
- if (!length) {
17
- return [];
18
- }
19
- let index = -1;
20
- const lastIndex = length - 1;
21
- const result = [
22
- ...array
23
- ];
24
- while(++index < length){
25
- const rand = index + Math.floor(Math.random() * (lastIndex - index + 1));
26
- const value = result[rand];
27
- result[rand] = result[index];
28
- result[index] = value;
29
- }
30
- return result;
31
- }
32
- export default shuffle;
package/slugify.js DELETED
@@ -1,35 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: all[name]
9
- });
10
- }
11
- _export(exports, {
12
- slugify: function() {
13
- return slugify;
14
- },
15
- default: function() {
16
- return _default;
17
- }
18
- });
19
- const _accentSets = require("./accentSets");
20
- const _removeAccents = require("./removeAccents");
21
- function slugify(text, separator = "-") {
22
- return (0, _removeAccents.removeAccents)(text.toString().toLowerCase().trim(), _accentSets.accentsSets.concat([
23
- [
24
- "-",
25
- "[·/_,:;']"
26
- ]
27
- ])).replace(/\s+/g, "-") // replace spaces with -
28
- .replace(/&/g, "-and-") // replace & with 'and'
29
- .replace(/[^\w-]+/g, "") // remove all non-word chars
30
- .replace(/--+/g, "-") // replace multiple - with single -
31
- .replace(/^-+/, "") // trim - from start of text
32
- .replace(/-+$/, "") // trim - from end of text
33
- .replace(/-/g, separator);
34
- }
35
- const _default = slugify;
package/slugify.mjs DELETED
@@ -1,25 +0,0 @@
1
- import { accentsSets } from "./accentSets";
2
- import { removeAccents } from "./removeAccents";
3
- /**
4
- * Slugify a text
5
- *
6
- * - replaces the accented letters
7
- * - replaces the punctuation with dashes
8
- *
9
- * @category text
10
- * @see https://gist.github.com/mathewbyrne/1280286#gistcomment-3498021
11
- */ export function slugify(text, separator = "-") {
12
- return removeAccents(text.toString().toLowerCase().trim(), accentsSets.concat([
13
- [
14
- "-",
15
- "[·/_,:;']"
16
- ]
17
- ])).replace(/\s+/g, "-") // replace spaces with -
18
- .replace(/&/g, "-and-") // replace & with 'and'
19
- .replace(/[^\w-]+/g, "") // remove all non-word chars
20
- .replace(/--+/g, "-") // replace multiple - with single -
21
- .replace(/^-+/, "") // trim - from start of text
22
- .replace(/-+$/, "") // trim - from end of text
23
- .replace(/-/g, separator);
24
- }
25
- export default slugify;
package/split.js DELETED
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: all[name]
9
- });
10
- }
11
- _export(exports, {
12
- split: function() {
13
- return split;
14
- },
15
- default: function() {
16
- return _default;
17
- }
18
- });
19
- function split(str, delimiter) {
20
- return str.split(delimiter);
21
- }
22
- const _default = split;
package/split.mjs DELETED
@@ -1,4 +0,0 @@
1
- export function split(str, delimiter) {
2
- return str.split(delimiter);
3
- }
4
- export default split;
package/swapMap.js DELETED
@@ -1,30 +0,0 @@
1
- /**
2
- * Swap object map key/value
3
- *
4
- * @category objects
5
- */ "use strict";
6
- Object.defineProperty(exports, "__esModule", {
7
- value: true
8
- });
9
- function _export(target, all) {
10
- for(var name in all)Object.defineProperty(target, name, {
11
- enumerable: true,
12
- get: all[name]
13
- });
14
- }
15
- _export(exports, {
16
- swapMap: function() {
17
- return swapMap;
18
- },
19
- default: function() {
20
- return _default;
21
- }
22
- });
23
- function swapMap(map = {}) {
24
- const output = {};
25
- for(const key in map){
26
- output[map[key]] = key;
27
- }
28
- return output;
29
- }
30
- const _default = swapMap;
package/swapMap.mjs DELETED
@@ -1,12 +0,0 @@
1
- /**
2
- * Swap object map key/value
3
- *
4
- * @category objects
5
- */ export function swapMap(map = {}) {
6
- const output = {};
7
- for(const key in map){
8
- output[map[key]] = key;
9
- }
10
- return output;
11
- }
12
- export default swapMap;
package/throttle.js DELETED
@@ -1,38 +0,0 @@
1
- /**
2
- * Throttle function (e.g. for resize / scroll handlers)
3
- *
4
- * @category function
5
- * @see https://github.com/Mobius1/Rangeable/
6
- */ "use strict";
7
- Object.defineProperty(exports, "__esModule", {
8
- value: true
9
- });
10
- function _export(target, all) {
11
- for(var name in all)Object.defineProperty(target, name, {
12
- enumerable: true,
13
- get: all[name]
14
- });
15
- }
16
- _export(exports, {
17
- throttle: function() {
18
- return throttle;
19
- },
20
- default: function() {
21
- return _default;
22
- }
23
- });
24
- function throttle(fn, limit, context) {
25
- let wait;
26
- return function(...args) {
27
- context = context || this;
28
- if (!wait) {
29
- fn.apply(context, ...args);
30
- wait = true;
31
- return setTimeout(function() {
32
- wait = false;
33
- }, limit);
34
- }
35
- return;
36
- };
37
- }
38
- const _default = throttle;
package/throttle.mjs DELETED
@@ -1,20 +0,0 @@
1
- /**
2
- * Throttle function (e.g. for resize / scroll handlers)
3
- *
4
- * @category function
5
- * @see https://github.com/Mobius1/Rangeable/
6
- */ export function throttle(fn, limit, context) {
7
- let wait;
8
- return function(...args) {
9
- context = context || this;
10
- if (!wait) {
11
- fn.apply(context, ...args);
12
- wait = true;
13
- return setTimeout(function() {
14
- wait = false;
15
- }, limit);
16
- }
17
- return;
18
- };
19
- }
20
- export default throttle;
package/titleCase.js DELETED
@@ -1,24 +0,0 @@
1
- /**
2
- * @category typography
3
- * @see https://github.com/blakeembrey/change-case/blob/master/packages/title-case/src/index.ts
4
- * @author Blake Embrey (hello@blakeembrey.com)
5
- */ "use strict";
6
- Object.defineProperty(exports, "__esModule", {
7
- value: true
8
- });
9
- function _export(target, all) {
10
- for(var name in all)Object.defineProperty(target, name, {
11
- enumerable: true,
12
- get: all[name]
13
- });
14
- }
15
- _export(exports, {
16
- titleCase: function() {
17
- return titleCase;
18
- },
19
- default: function() {
20
- return _default;
21
- }
22
- });
23
- const titleCase = (input)=>input ? input.replace(/\w\S*/g, (txt)=>txt.charAt(0).toUpperCase() + txt.substring(1).toLowerCase()) : "";
24
- const _default = titleCase;
package/titleCase.mjs DELETED
@@ -1,6 +0,0 @@
1
- /**
2
- * @category typography
3
- * @see https://github.com/blakeembrey/change-case/blob/master/packages/title-case/src/index.ts
4
- * @author Blake Embrey (hello@blakeembrey.com)
5
- */ export const titleCase = (input)=>input ? input.replace(/\w\S*/g, (txt)=>txt.charAt(0).toUpperCase() + txt.substring(1).toLowerCase()) : "";
6
- export default titleCase;
package/toNumber.js DELETED
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: all[name]
9
- });
10
- }
11
- _export(exports, {
12
- toNumber: function() {
13
- return toNumber;
14
- },
15
- default: function() {
16
- return _default;
17
- }
18
- });
19
- const _isNumber = require("./isNumber");
20
- function toNumber(input, fallback) {
21
- return (0, _isNumber.isNumber)(input) ? input : input ? parseFloat(input) : fallback || 0;
22
- }
23
- const _default = toNumber;
package/toNumber.mjs DELETED
@@ -1,7 +0,0 @@
1
- import { isNumber } from "./isNumber";
2
- /**
3
- * @category cast
4
- */ export function toNumber(input, fallback) {
5
- return isNumber(input) ? input : input ? parseFloat(input) : fallback || 0;
6
- }
7
- export default toNumber;
package/toRgba.js DELETED
@@ -1,32 +0,0 @@
1
- // import hexRgb from "hex-rgb";
2
- // export const toRgb = (hexColor: string) => hexRgb(hexColor, { format: "css" });
3
- // export const toRgba = (hexColor: string, alpha: number) =>
4
- // hexRgb(hexColor, { format: "css", alpha });
5
- /**
6
- * @category colors
7
- */ "use strict";
8
- Object.defineProperty(exports, "__esModule", {
9
- value: true
10
- });
11
- function _export(target, all) {
12
- for(var name in all)Object.defineProperty(target, name, {
13
- enumerable: true,
14
- get: all[name]
15
- });
16
- }
17
- _export(exports, {
18
- toRgba: function() {
19
- return toRgba;
20
- },
21
- default: function() {
22
- return _default;
23
- }
24
- });
25
- function toRgba(hex, alpha = 1) {
26
- const r = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
27
- if (r) {
28
- return `rgba(${parseInt(r[1], 16)},${parseInt(r[2], 16)},${parseInt(r[3], 16)},${alpha})`;
29
- }
30
- return "";
31
- }
32
- const _default = toRgba;
package/toRgba.mjs DELETED
@@ -1,14 +0,0 @@
1
- // import hexRgb from "hex-rgb";
2
- // export const toRgb = (hexColor: string) => hexRgb(hexColor, { format: "css" });
3
- // export const toRgba = (hexColor: string, alpha: number) =>
4
- // hexRgb(hexColor, { format: "css", alpha });
5
- /**
6
- * @category colors
7
- */ export function toRgba(hex, alpha = 1) {
8
- const r = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
9
- if (r) {
10
- return `rgba(${parseInt(r[1], 16)},${parseInt(r[2], 16)},${parseInt(r[3], 16)},${alpha})`;
11
- }
12
- return "";
13
- }
14
- export default toRgba;
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: all[name]
9
- });
10
- }
11
- _export(exports, {
12
- transformToUrlPathname: function() {
13
- return transformToUrlPathname;
14
- },
15
- default: function() {
16
- return _default;
17
- }
18
- });
19
- const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
20
- const _isString = /*#__PURE__*/ _interop_require_default._(require("./isString"));
21
- function transformToUrlPathname(toPathname) {
22
- return (0, _isString.default)(toPathname) ? `/${encodeURIComponent(toPathname.replace(/\s/g, "-").toLowerCase())}` : "";
23
- }
24
- const _default = transformToUrlPathname;
@@ -1,13 +0,0 @@
1
- import isString from "./isString";
2
- /**
3
- * Transform string in a URL pathname (relative URL)
4
- *
5
- * - adds an initial slash
6
- * - encode the string
7
- * - replaces whitespaces with dashes
8
- *
9
- * @category location
10
- */ export function transformToUrlPathname(toPathname) {
11
- return isString(toPathname) ? `/${encodeURIComponent(toPathname.replace(/\s/g, "-").toLowerCase())}` : "";
12
- }
13
- export default transformToUrlPathname;
package/truncate.js DELETED
@@ -1,24 +0,0 @@
1
- /**
2
- * Truncate string
3
- *
4
- * @category typography
5
- */ "use strict";
6
- Object.defineProperty(exports, "__esModule", {
7
- value: true
8
- });
9
- function _export(target, all) {
10
- for(var name in all)Object.defineProperty(target, name, {
11
- enumerable: true,
12
- get: all[name]
13
- });
14
- }
15
- _export(exports, {
16
- truncate: function() {
17
- return truncate;
18
- },
19
- default: function() {
20
- return _default;
21
- }
22
- });
23
- const truncate = (input, length)=>input ? input.length > length ? input.substring(0, length) + "..." : input : "";
24
- const _default = truncate;
package/truncate.mjs DELETED
@@ -1,6 +0,0 @@
1
- /**
2
- * Truncate string
3
- *
4
- * @category typography
5
- */ export const truncate = (input, length)=>input ? input.length > length ? input.substring(0, length) + "..." : input : "";
6
- export default truncate;
package/tryUntil.js DELETED
@@ -1,42 +0,0 @@
1
- /**
2
- * @borrows [https://levelup.gitconnected.com/javascript-wait-until-something-happens-or-timeout-82636839ea93]
3
- *
4
- * @param timeout in `ms`
5
- * @param interval in `ms`
6
- */ "use strict";
7
- Object.defineProperty(exports, "__esModule", {
8
- value: true
9
- });
10
- function _export(target, all) {
11
- for(var name in all)Object.defineProperty(target, name, {
12
- enumerable: true,
13
- get: all[name]
14
- });
15
- }
16
- _export(exports, {
17
- tryUntil: function() {
18
- return tryUntil;
19
- },
20
- default: function() {
21
- return _default;
22
- }
23
- });
24
- const tryUntil = (test, timeout, interval, resolve, reject)=>{
25
- // return new Promise((resolve, reject) => {
26
- const timeWas = new Date();
27
- const wait = setInterval(function() {
28
- if (test()) {
29
- // console.log("resolved after", new Date() - timeWas, "ms");
30
- clearInterval(wait);
31
- resolve();
32
- // @ts-expect-error ...
33
- } else if (new Date() - timeWas > timeout) {
34
- // Timeout
35
- // console.log("rejected after", new Date() - timeWas, "ms");
36
- clearInterval(wait);
37
- if (reject) reject();
38
- }
39
- }, interval);
40
- // });
41
- };
42
- const _default = tryUntil;
package/tryUntil.mjs DELETED
@@ -1,24 +0,0 @@
1
- /**
2
- * @borrows [https://levelup.gitconnected.com/javascript-wait-until-something-happens-or-timeout-82636839ea93]
3
- *
4
- * @param timeout in `ms`
5
- * @param interval in `ms`
6
- */ export const tryUntil = (test, timeout, interval, resolve, reject)=>{
7
- // return new Promise((resolve, reject) => {
8
- const timeWas = new Date();
9
- const wait = setInterval(function() {
10
- if (test()) {
11
- // console.log("resolved after", new Date() - timeWas, "ms");
12
- clearInterval(wait);
13
- resolve();
14
- // @ts-expect-error ...
15
- } else if (new Date() - timeWas > timeout) {
16
- // Timeout
17
- // console.log("rejected after", new Date() - timeWas, "ms");
18
- clearInterval(wait);
19
- if (reject) reject();
20
- }
21
- }, interval);
22
- // });
23
- };
24
- export default tryUntil;
package/types.js DELETED
@@ -1,5 +0,0 @@
1
- // import type { Replace } from "@koine/utils";
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
package/types.mjs DELETED
@@ -1,2 +0,0 @@
1
- // import type { Replace } from "@koine/utils";
2
- export { };