@koine/utils 2.0.0-beta.1 → 2.0.0-beta.11

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 (331) hide show
  1. package/Defer.mjs +6 -5
  2. package/Emitter.d.ts +3 -1
  3. package/Emitter.mjs +16 -17
  4. package/README.md +6 -1
  5. package/accentSets.d.ts +3 -2
  6. package/accentSets.mjs +116 -31
  7. package/addOrReplaceAtIdx.d.ts +4 -0
  8. package/addOrReplaceAtIdx.mjs +13 -6
  9. package/areEqual.d.ts +1 -1
  10. package/areEqual.mjs +17 -23
  11. package/arrayOfAll.d.ts +1 -2
  12. package/arrayOfAll.mjs +2 -8
  13. package/arraySum.d.ts +2 -1
  14. package/arraySum.mjs +3 -5
  15. package/arrayToLookup.mjs +2 -4
  16. package/buildUrlQueryString.mjs +11 -14
  17. package/capitalize.d.ts +2 -1
  18. package/capitalize.mjs +5 -6
  19. package/changeUrlPath.mjs +2 -3
  20. package/chunkByChunks.d.ts +1 -1
  21. package/chunkByChunks.mjs +18 -21
  22. package/chunkBySize.mjs +3 -4
  23. package/clamp.mjs +1 -2
  24. package/clsx.d.ts +6 -2
  25. package/clsx.mjs +14 -15
  26. package/convertRange.d.ts +3 -1
  27. package/convertRange.mjs +5 -4
  28. package/cookie.d.ts +13 -1
  29. package/cookie.mjs +8 -3
  30. package/createPalette.d.ts +3 -1
  31. package/createPalette.mjs +17 -7
  32. package/debounce.mjs +9 -17
  33. package/debouncePromise.d.ts +22 -4
  34. package/debouncePromise.mjs +73 -3
  35. package/debounceRaf.d.ts +1 -1
  36. package/debounceRaf.mjs +6 -11
  37. package/decode.mjs +2 -3
  38. package/encode.mjs +2 -3
  39. package/ensureInt.mjs +1 -4
  40. package/env.mjs +0 -1
  41. package/errorToString.d.ts +2 -1
  42. package/errorToString.mjs +3 -5
  43. package/findDuplicatedIndexes.mjs +4 -5
  44. package/forin.d.ts +2 -1
  45. package/forin.mjs +4 -4
  46. package/gbToBytes.mjs +1 -2
  47. package/getEmptyArray.d.ts +0 -1
  48. package/getEmptyArray.mjs +4 -4
  49. package/getKeys.d.ts +2 -1
  50. package/getKeys.mjs +3 -3
  51. package/getMediaQueryWidthResolvers.d.ts +6 -0
  52. package/getMediaQueryWidthResolvers.mjs +49 -50
  53. package/getMediaQueryWidthTailwindScreens.d.ts +4 -0
  54. package/getMediaQueryWidthTailwindScreens.mjs +22 -15
  55. package/getNonce.mjs +1 -2
  56. package/getParamAmong.d.ts +3 -2
  57. package/getParamAmong.mjs +5 -6
  58. package/getParamAsInt.d.ts +2 -2
  59. package/getParamAsInt.mjs +4 -6
  60. package/getParamAsString.d.ts +1 -1
  61. package/getParamAsString.mjs +2 -3
  62. package/getType.d.ts +0 -3
  63. package/getType.mjs +2 -7
  64. package/getUrlHashParams.mjs +2 -4
  65. package/getUrlHashPathname.mjs +1 -3
  66. package/getUrlPathnameParts.mjs +2 -7
  67. package/getUrlQueryParams.d.ts +3 -4
  68. package/getUrlQueryParams.mjs +10 -22
  69. package/imgEmptyPixel.mjs +1 -2
  70. package/index.d.ts +5 -2
  71. package/index.mjs +2 -2
  72. package/invariant.mjs +6 -8
  73. package/isAnyObject.mjs +1 -2
  74. package/isArray.mjs +1 -2
  75. package/isBlob.mjs +1 -2
  76. package/isBoolean.mjs +1 -2
  77. package/isBrowser.mjs +1 -2
  78. package/isBrowserNow.mjs +1 -2
  79. package/isDate.mjs +1 -2
  80. package/isEmptyArray.mjs +1 -2
  81. package/isEmptyObject.mjs +1 -2
  82. package/isEmptyString.mjs +1 -2
  83. package/isError.mjs +1 -2
  84. package/isExternalUrl.mjs +4 -6
  85. package/isFile.mjs +1 -2
  86. package/isFloat.mjs +1 -2
  87. package/isFormData.mjs +1 -2
  88. package/isFullArray.mjs +1 -2
  89. package/isFullObject.mjs +1 -2
  90. package/isFullString.mjs +1 -2
  91. package/isFunction.mjs +1 -2
  92. package/isInt.mjs +1 -2
  93. package/isMap.mjs +1 -2
  94. package/isNaNValue.mjs +1 -2
  95. package/isNegativeNumber.mjs +1 -2
  96. package/isNull.mjs +1 -2
  97. package/isNullOrUndefined.mjs +1 -2
  98. package/isNumber.mjs +1 -2
  99. package/isObject.mjs +1 -2
  100. package/isObjectLike.mjs +1 -2
  101. package/isOneOf.mjs +1 -7
  102. package/isPlainObject.mjs +3 -6
  103. package/isPositiveNumber.mjs +1 -2
  104. package/isPrimitive.mjs +5 -11
  105. package/isPromise.mjs +1 -2
  106. package/isRegExp.mjs +1 -2
  107. package/isServer.mjs +1 -2
  108. package/isServerNow.mjs +1 -2
  109. package/isSet.mjs +1 -2
  110. package/isString.mjs +1 -2
  111. package/isSymbol.mjs +1 -2
  112. package/isType.mjs +3 -5
  113. package/isUndefined.mjs +1 -2
  114. package/isWeakMap.mjs +1 -2
  115. package/isWeakSet.mjs +1 -2
  116. package/kbToBytes.mjs +1 -2
  117. package/location.mjs +3 -1
  118. package/lowercase.mjs +1 -4
  119. package/mapListBy.mjs +2 -5
  120. package/matchSorter.mjs +110 -128
  121. package/mbToBytes.mjs +1 -2
  122. package/mergeObjects.d.ts +2 -2
  123. package/mergeObjects.mjs +13 -16
  124. package/mergeUrlQueryParams.d.ts +0 -1
  125. package/mergeUrlQueryParams.mjs +4 -9
  126. package/moveSortableArrayItemByKey.d.ts +1 -1
  127. package/moveSortableArrayItemByKey.mjs +9 -9
  128. package/noop.mjs +1 -2
  129. package/normaliseUrl.mjs +1 -3
  130. package/normaliseUrlPathname.mjs +1 -3
  131. package/objectOmit.d.ts +1 -1
  132. package/objectOmit.mjs +4 -6
  133. package/objectPick.d.ts +1 -1
  134. package/objectPick.mjs +5 -6
  135. package/package.json +7 -11
  136. package/parseCookie.mjs +11 -15
  137. package/parseURL.mjs +5 -6
  138. package/quaranteneProps.d.ts +1 -1
  139. package/quaranteneProps.mjs +7 -9
  140. package/randomInt.mjs +1 -2
  141. package/randomKey.mjs +3 -4
  142. package/readCookie.d.ts +5 -0
  143. package/readCookie.mjs +7 -8
  144. package/removeAccents.mjs +5 -8
  145. package/removeCookie.d.ts +0 -4
  146. package/removeCookie.mjs +6 -9
  147. package/removeDuplicates.mjs +0 -1
  148. package/removeDuplicatesByKey.mjs +5 -7
  149. package/removeDuplicatesComparing.mjs +3 -4
  150. package/removeIndexesFromArray.mjs +3 -4
  151. package/removeTrailingSlash.mjs +1 -3
  152. package/removeUrlQueryParams.d.ts +0 -1
  153. package/removeUrlQueryParams.mjs +5 -8
  154. package/render.d.ts +2 -1
  155. package/render.mjs +45 -99
  156. package/roundTo.mjs +15 -17
  157. package/serializeCookie.d.ts +1 -5
  158. package/serializeCookie.mjs +10 -20
  159. package/setCookie.d.ts +0 -4
  160. package/setCookie.mjs +13 -20
  161. package/shuffle.d.ts +7 -6
  162. package/shuffle.mjs +17 -16
  163. package/slugify.d.ts +2 -1
  164. package/slugify.mjs +15 -12
  165. package/split.d.ts +4 -0
  166. package/split.mjs +4 -1
  167. package/swapMap.d.ts +1 -1
  168. package/swapMap.mjs +4 -6
  169. package/throttle.d.ts +2 -1
  170. package/throttle.mjs +6 -12
  171. package/titleCase.d.ts +4 -3
  172. package/titleCase.mjs +5 -9
  173. package/toNumber.mjs +1 -2
  174. package/toRgba.mjs +3 -5
  175. package/transformToUrlPathname.mjs +2 -5
  176. package/truncate.d.ts +1 -1
  177. package/truncate.mjs +2 -9
  178. package/tryUntil.d.ts +4 -1
  179. package/tryUntil.mjs +11 -11
  180. package/types.mjs +2 -1
  181. package/typings.d.ts +1 -6
  182. package/uid.mjs +3 -5
  183. package/updateLinkParams.mjs +2 -3
  184. package/updateUrlQueryParams.d.ts +0 -1
  185. package/updateUrlQueryParams.mjs +3 -8
  186. package/uppercase.d.ts +1 -0
  187. package/uppercase.mjs +2 -4
  188. package/uuid.mjs +2 -5
  189. package/uuidNumeric.mjs +1 -2
  190. package/wait.mjs +1 -4
  191. package/without.mjs +1 -3
  192. package/Defer.js +0 -30
  193. package/Emitter.js +0 -42
  194. package/accentSets.js +0 -41
  195. package/addOrReplaceAtIdx.js +0 -23
  196. package/areEqual.js +0 -81
  197. package/arrayOfAll.js +0 -36
  198. package/arraySum.js +0 -13
  199. package/arrayToLookup.js +0 -17
  200. package/buildUrlQueryString.js +0 -36
  201. package/capitalize.js +0 -16
  202. package/changeUrlPath.js +0 -23
  203. package/chunkByChunks.js +0 -41
  204. package/chunkBySize.js +0 -16
  205. package/clamp.js +0 -14
  206. package/clsx.js +0 -53
  207. package/convertRange.js +0 -20
  208. package/cookie.js +0 -13
  209. package/createPalette.js +0 -26
  210. package/debounce.js +0 -33
  211. package/debouncePromise.js +0 -12
  212. package/debounceRaf.js +0 -31
  213. package/decode.js +0 -14
  214. package/encode.js +0 -14
  215. package/ensureInt.js +0 -13
  216. package/env.js +0 -3
  217. package/errorToString.js +0 -15
  218. package/findDuplicatedIndexes.js +0 -18
  219. package/forin.js +0 -15
  220. package/gbToBytes.js +0 -11
  221. package/getEmptyArray.js +0 -20
  222. package/getKeys.js +0 -12
  223. package/getMediaQueryWidthResolvers.js +0 -72
  224. package/getMediaQueryWidthTailwindScreens.js +0 -33
  225. package/getNonce.js +0 -13
  226. package/getParamAmong.js +0 -22
  227. package/getParamAsInt.js +0 -25
  228. package/getParamAsString.js +0 -19
  229. package/getType.js +0 -23
  230. package/getUrlHashParams.js +0 -20
  231. package/getUrlHashPathname.js +0 -17
  232. package/getUrlPathnameParts.js +0 -25
  233. package/getUrlQueryParams.js +0 -43
  234. package/imgEmptyPixel.js +0 -10
  235. package/index.js +0 -267
  236. package/invariant.js +0 -38
  237. package/isAnyObject.js +0 -15
  238. package/isArray.js +0 -15
  239. package/isBlob.js +0 -15
  240. package/isBoolean.js +0 -15
  241. package/isBrowser.js +0 -9
  242. package/isBrowserNow.js +0 -12
  243. package/isDate.js +0 -15
  244. package/isEmptyArray.js +0 -15
  245. package/isEmptyObject.js +0 -15
  246. package/isEmptyString.js +0 -13
  247. package/isError.js +0 -15
  248. package/isExternalUrl.js +0 -26
  249. package/isFile.js +0 -15
  250. package/isFloat.js +0 -15
  251. package/isFormData.js +0 -15
  252. package/isFullArray.js +0 -15
  253. package/isFullObject.js +0 -15
  254. package/isFullString.js +0 -15
  255. package/isFunction.js +0 -13
  256. package/isInt.js +0 -15
  257. package/isMap.js +0 -15
  258. package/isNaNValue.js +0 -15
  259. package/isNegativeNumber.js +0 -15
  260. package/isNull.js +0 -15
  261. package/isNullOrUndefined.js +0 -14
  262. package/isNumber.js +0 -17
  263. package/isObject.js +0 -15
  264. package/isObjectLike.js +0 -17
  265. package/isOneOf.js +0 -14
  266. package/isPlainObject.js +0 -18
  267. package/isPositiveNumber.js +0 -15
  268. package/isPrimitive.js +0 -25
  269. package/isPromise.js +0 -15
  270. package/isRegExp.js +0 -15
  271. package/isServer.js +0 -12
  272. package/isServerNow.js +0 -12
  273. package/isSet.js +0 -15
  274. package/isString.js +0 -15
  275. package/isSymbol.js +0 -15
  276. package/isType.js +0 -27
  277. package/isUndefined.js +0 -15
  278. package/isWeakMap.js +0 -15
  279. package/isWeakSet.js +0 -15
  280. package/kbToBytes.js +0 -11
  281. package/location.js +0 -2
  282. package/lowercase.js +0 -13
  283. package/mapListBy.js +0 -18
  284. package/matchSorter.js +0 -374
  285. package/mbToBytes.js +0 -11
  286. package/mergeObjects.js +0 -41
  287. package/mergeUrlQueryParams.js +0 -27
  288. package/moveSortableArrayItemByKey.js +0 -21
  289. package/noop.js +0 -11
  290. package/normaliseUrl.js +0 -20
  291. package/normaliseUrlPathname.js +0 -19
  292. package/objectOmit.js +0 -23
  293. package/objectPick.js +0 -19
  294. package/parseCookie.js +0 -52
  295. package/parseURL.js +0 -24
  296. package/quaranteneProps.js +0 -37
  297. package/randomInt.js +0 -13
  298. package/randomKey.js +0 -15
  299. package/readCookie.js +0 -38
  300. package/removeAccents.js +0 -19
  301. package/removeCookie.js +0 -19
  302. package/removeDuplicates.js +0 -13
  303. package/removeDuplicatesByKey.js +0 -24
  304. package/removeDuplicatesComparing.js +0 -14
  305. package/removeIndexesFromArray.js +0 -18
  306. package/removeTrailingSlash.js +0 -14
  307. package/removeUrlQueryParams.js +0 -26
  308. package/render.js +0 -169
  309. package/roundTo.js +0 -38
  310. package/serializeCookie.js +0 -108
  311. package/setCookie.js +0 -62
  312. package/shuffle.js +0 -36
  313. package/slugify.js +0 -27
  314. package/split.js +0 -8
  315. package/swapMap.js +0 -18
  316. package/throttle.js +0 -30
  317. package/titleCase.js +0 -15
  318. package/toNumber.js +0 -12
  319. package/toRgba.js +0 -20
  320. package/transformToUrlPathname.js +0 -21
  321. package/truncate.js +0 -17
  322. package/tryUntil.js +0 -31
  323. package/types.js +0 -2
  324. package/uid.js +0 -16
  325. package/updateLinkParams.js +0 -19
  326. package/updateUrlQueryParams.js +0 -23
  327. package/uppercase.js +0 -13
  328. package/uuid.js +0 -17
  329. package/uuidNumeric.js +0 -10
  330. package/wait.js +0 -13
  331. package/without.js +0 -56
@@ -1,68 +1,67 @@
1
- import { __assign } from "tslib";
2
- export function getMediaQueryWidthResolvers(customBreakpoints) {
3
- var breakpoints = __assign({ xs: 0 }, customBreakpoints);
4
- var sortedBreakpointsNames = Object.keys(breakpoints).map(function (key) {
5
- var br = key;
6
- return [br, breakpoints[br]];
7
- })
8
- .sort(function (a, b) { return a[1] - b[1]; })
9
- .map(function (item) { return item[0]; });
10
- var getNextBreakpoint = function (breakpoint) {
11
- var index = sortedBreakpointsNames.indexOf(breakpoint);
1
+ /**
2
+ * @category responsive
3
+ */ /**
4
+ * @category responsive
5
+ */ export function getMediaQueryWidthResolvers(customBreakpoints) {
6
+ const breakpoints = {
7
+ xs: 0,
8
+ ...customBreakpoints
9
+ };
10
+ const sortedBreakpointsNames = Object.keys(breakpoints).map((key)=>{
11
+ const br = key;
12
+ return [
13
+ br,
14
+ breakpoints[br]
15
+ ];
16
+ }).sort((a, b)=>a[1] - b[1]).map((item)=>item[0]);
17
+ const getNextBreakpoint = (breakpoint)=>{
18
+ const index = sortedBreakpointsNames.indexOf(breakpoint);
12
19
  return sortedBreakpointsNames[index + 1];
13
20
  };
14
21
  /**
15
- * It behaves the same as `(min-width: ${value}px)`
16
- * where value is the given breakpoint value.
17
- * For ease of use this can be used both as a function `min("md")` and as an
18
- * object literal `min.md`.
19
- */
20
- var min = function (br) { return "(min-width: ".concat(breakpoints[br], "px)"); };
22
+ * It behaves the same as `(min-width: ${value}px)`
23
+ * where value is the given breakpoint value.
24
+ * For ease of use this can be used both as a function `min("md")` and as an
25
+ * object literal `min.md`.
26
+ */ const min = (br)=>`(min-width: ${breakpoints[br]}px)`;
21
27
  /**
22
- * It behaves the same as `(max-width: ${value}px)`
23
- * where value is the given breakpoint value.
24
- * For ease of use this can be used both as a function `max("md")` and as an
25
- * object literal `max.md`.
26
- */
27
- var max = function (br) { return "(max-width: ".concat(breakpoints[br] - 0.02, "px)"); };
28
+ * It behaves the same as `(max-width: ${value}px)`
29
+ * where value is the given breakpoint value.
30
+ * For ease of use this can be used both as a function `max("md")` and as an
31
+ * object literal `max.md`.
32
+ */ const max = (br)=>`(max-width: ${breakpoints[br] - 0.02}px)`;
28
33
  /**
29
- * It behaves the same as `min`
30
- * @inheritdoc {max}
31
- */
32
- var up = min;
34
+ * It behaves the same as `min`
35
+ * @inheritdoc {max}
36
+ */ const up = min;
33
37
  /**
34
- * It behaves similarly to `max` but you will use the "next" breakpoint,
35
- * specifying CSS that will apply from the given breakpoint and down.
36
- */
37
- var down = function (br) {
38
- var brNext = getNextBreakpoint(br);
38
+ * It behaves similarly to `max` but you will use the "next" breakpoint,
39
+ * specifying CSS that will apply from the given breakpoint and down.
40
+ */ const down = (br)=>{
41
+ const brNext = getNextBreakpoint(br);
39
42
  // TODO: if br does not exists otherwise throw Error
40
- return brNext && "(max-width: ".concat(breakpoints[brNext] - 0.02, "px)");
43
+ return brNext && `(max-width: ${breakpoints[brNext] - 0.02}px)`;
41
44
  };
42
45
  /**
43
- * Media query between the two given breakpoints
44
- */
45
- var between = function (br1, br2) {
46
+ * Media query between the two given breakpoints
47
+ */ const between = (br1, br2)=>{
46
48
  br2 = br2 || getNextBreakpoint(br1);
47
- return br2
48
- ? "(min-width: ".concat(breakpoints[br1], "px) and (max-width: ").concat(breakpoints[br2] - 0.02, "px)")
49
- : min(br1);
49
+ return br2 ? `(min-width: ${breakpoints[br1]}px) and (max-width: ${breakpoints[br2] - 0.02}px)` : min(br1);
50
50
  };
51
51
  /**
52
- * Media query to apply from the given breakpoint until the next, just for its
53
- * full range
54
- */
55
- var only = function (br) {
56
- var brNext = getNextBreakpoint(br);
52
+ * Media query to apply from the given breakpoint until the next, just for its
53
+ * full range
54
+ */ const only = (br)=>{
55
+ const brNext = getNextBreakpoint(br);
57
56
  return brNext ? between(br, brNext) : min(br);
58
57
  };
59
58
  return {
60
- max: max,
61
- min: min,
62
- down: down,
63
- up: up,
64
- between: between,
65
- only: only,
59
+ max,
60
+ min,
61
+ down,
62
+ up,
63
+ between,
64
+ only
66
65
  };
67
66
  }
68
67
  export default getMediaQueryWidthResolvers;
@@ -1,4 +1,8 @@
1
1
  import { type GetMediaQueryWidthResolversBreakpoints } from "./getMediaQueryWidthResolvers";
2
+ /**
3
+ * @category responsive
4
+ * @category tailwind
5
+ */
2
6
  export declare function getMediaQueryWidthTailwindScreens(breakpoints: GetMediaQueryWidthResolversBreakpoints): Record<string, {
3
7
  raw: string;
4
8
  }>;
@@ -1,24 +1,31 @@
1
- import { getMediaQueryWidthResolvers, } from "./getMediaQueryWidthResolvers";
2
- export function getMediaQueryWidthTailwindScreens(breakpoints) {
3
- var mqWidthResolvers = getMediaQueryWidthResolvers(breakpoints);
1
+ import { getMediaQueryWidthResolvers } from "./getMediaQueryWidthResolvers";
2
+ /**
3
+ * @category responsive
4
+ * @category tailwind
5
+ */ export function getMediaQueryWidthTailwindScreens(breakpoints) {
6
+ const mqWidthResolvers = getMediaQueryWidthResolvers(breakpoints);
4
7
  // Object.keys(breakpoints).reduce((screens, br) => {
5
- var screens = Object.keys(breakpoints).reduce(function (output, br, idx) {
6
- var brNext = Object.keys(breakpoints)[idx + 1];
7
- for (var resolverName in mqWidthResolvers) {
8
+ const screens = Object.keys(breakpoints).reduce((output, br, idx)=>{
9
+ const brNext = Object.keys(breakpoints)[idx + 1];
10
+ for(const resolverName in mqWidthResolvers){
8
11
  // this line is just for typescript..
9
- var resolver = resolverName;
10
- var resolverFn = mqWidthResolvers[resolver];
11
- var raw = resolverFn(br);
12
+ const resolver = resolverName;
13
+ const resolverFn = mqWidthResolvers[resolver];
14
+ const raw = resolverFn(br);
12
15
  if (raw) {
13
16
  if (resolverName === "min") {
14
- output["@".concat(br)] = { raw: raw };
17
+ output[`@${br}`] = {
18
+ raw
19
+ };
15
20
  }
16
21
  if (resolverName === "between") {
17
- if (brNext)
18
- output["@".concat(resolverName, "-").concat(br, "_").concat(brNext)] = { raw: raw };
19
- }
20
- else {
21
- output["@".concat(resolverName, "-").concat(br)] = { raw: raw };
22
+ if (brNext) output[`@${resolverName}-${br}_${brNext}`] = {
23
+ raw
24
+ };
25
+ } else {
26
+ output[`@${resolverName}-${br}`] = {
27
+ raw
28
+ };
22
29
  }
23
30
  }
24
31
  }
package/getNonce.mjs CHANGED
@@ -2,8 +2,7 @@ import { isUndefined } from "./isUndefined";
2
2
  /**
3
3
  * @category security
4
4
  * @see https://github.com/styled-components/styled-components/blob/main/packages/styled-components/src/utils/nonce.ts
5
- */
6
- export function getNonce() {
5
+ */ export function getNonce() {
7
6
  return isUndefined(__webpack_nonce__) ? null : __webpack_nonce__;
8
7
  }
9
8
  export default getNonce;
@@ -5,8 +5,9 @@
5
5
  *
6
6
  * @category location
7
7
  *
8
- * @param {string} [raw] - The _raw_ query parameter
9
- * @param {string[]} [allowedValues=[]] - The list of values (as strings) that the parameter can have, if not one of them `null` is returned
8
+ * @param raw The _raw_ query parameter
9
+ * @param allowedValues The list of values (as strings) that the parameter can
10
+ * have, if not one of them `null` is returned
10
11
  */
11
12
  export declare function getParamAmong<T extends string[]>(raw?: string | string[], allowedValues?: T): T[number] | null;
12
13
  export default getParamAmong;
package/getParamAmong.mjs CHANGED
@@ -6,12 +6,11 @@ import getParamAsString from "./getParamAsString";
6
6
  *
7
7
  * @category location
8
8
  *
9
- * @param {string} [raw] - The _raw_ query parameter
10
- * @param {string[]} [allowedValues=[]] - The list of values (as strings) that the parameter can have, if not one of them `null` is returned
11
- */
12
- export function getParamAmong(raw, allowedValues) {
13
- if (allowedValues === void 0) { allowedValues = []; }
14
- var string = getParamAsString(raw);
9
+ * @param raw The _raw_ query parameter
10
+ * @param allowedValues The list of values (as strings) that the parameter can
11
+ * have, if not one of them `null` is returned
12
+ */ export function getParamAmong(raw, allowedValues = []) {
13
+ const string = getParamAsString(raw);
15
14
  return allowedValues.includes(string) ? string : null;
16
15
  }
17
16
  export default getParamAmong;
@@ -5,8 +5,8 @@
5
5
  *
6
6
  * @category location
7
7
  *
8
- * @param {string} [raw] - The _raw_ query parameter
9
- * @param {number} [fallback] - Fallback number, we return `null` if not provided
8
+ * @param raw The _raw_ query parameter
9
+ * @param fallback Fallback number, we return `null` if not provided
10
10
  */
11
11
  export declare function getParamAsInt<TFallback extends number | null | undefined>(raw?: string | string[], fallback?: TFallback): number | TFallback;
12
12
  export default getParamAsInt;
package/getParamAsInt.mjs CHANGED
@@ -6,12 +6,10 @@ import getParamAsString from "./getParamAsString";
6
6
  *
7
7
  * @category location
8
8
  *
9
- * @param {string} [raw] - The _raw_ query parameter
10
- * @param {number} [fallback] - Fallback number, we return `null` if not provided
11
- */
12
- export function getParamAsInt(raw, fallback) {
13
- if (fallback === void 0) { fallback = null; }
14
- var string = getParamAsString(raw);
9
+ * @param raw The _raw_ query parameter
10
+ * @param fallback Fallback number, we return `null` if not provided
11
+ */ export function getParamAsInt(raw, fallback = null) {
12
+ const string = getParamAsString(raw);
15
13
  if (string) {
16
14
  return parseInt(string, 10);
17
15
  }
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * @category location
7
7
  *
8
- * @param {string} [raw] - The _raw_ query parameter
8
+ * @param raw The _raw_ query parameter
9
9
  */
10
10
  export declare function getParamAsString(raw?: string | string[]): string;
11
11
  export default getParamAsString;
@@ -6,9 +6,8 @@ import isArray from "./isArray";
6
6
  *
7
7
  * @category location
8
8
  *
9
- * @param {string} [raw] - The _raw_ query parameter
10
- */
11
- export function getParamAsString(raw) {
9
+ * @param raw The _raw_ query parameter
10
+ */ export function getParamAsString(raw) {
12
11
  return (isArray(raw) ? raw[0] : raw) || "";
13
12
  }
14
13
  export default getParamAsString;
package/getType.d.ts CHANGED
@@ -14,9 +14,6 @@ export type PlainObject = Record<string | number | symbol, any>;
14
14
  export type TypeGuard<A, B extends A> = (payload: A) => payload is B;
15
15
  /**
16
16
  * Returns the object type of the given payload
17
- *
18
- * @param {*} payload
19
- * @returns {string}
20
17
  */
21
18
  export declare function getType(payload: any): string;
22
19
  export default getType;
package/getType.mjs CHANGED
@@ -6,14 +6,9 @@
6
6
  * - `isFormData`
7
7
  * - `isInt`
8
8
  * - `isFloat`
9
- */
10
- /**
9
+ */ /**
11
10
  * Returns the object type of the given payload
12
- *
13
- * @param {*} payload
14
- * @returns {string}
15
- */
16
- export function getType(payload) {
11
+ */ export function getType(payload) {
17
12
  return Object.prototype.toString.call(payload).slice(8, -1);
18
13
  }
19
14
  export default getType;
@@ -3,11 +3,9 @@
3
3
  * string or, if not provided, failling back reading the `location.hash`
4
4
  *
5
5
  * @category location
6
- */
7
- export function getUrlHashParams(hash) {
8
- if (hash === void 0) { hash = ""; }
6
+ */ export function getUrlHashParams(hash = "") {
9
7
  hash = hash || location.hash;
10
- var hashParts = hash.split("?");
8
+ const hashParts = hash.split("?");
11
9
  if (hashParts.length >= 1) {
12
10
  return Object.fromEntries(new URLSearchParams(hashParts[1]));
13
11
  }
@@ -4,9 +4,7 @@
4
4
  * back reading the `location.hash`
5
5
  *
6
6
  * @category location
7
- */
8
- export function getUrlHashPathname(hash) {
9
- if (hash === void 0) { hash = ""; }
7
+ */ export function getUrlHashPathname(hash = "") {
10
8
  hash = hash || location.hash;
11
9
  return hash.split("?")[0].replace(/^#\//, "");
12
10
  }
@@ -8,13 +8,8 @@ import isBrowser from "./isBrowser";
8
8
  * `[locale, prefix, collection, slug]`
9
9
  *
10
10
  * @category location
11
- */
12
- export function getUrlPathnameParts(pathname) {
13
- if (pathname === void 0) { pathname = ""; }
11
+ */ export function getUrlPathnameParts(pathname = "") {
14
12
  pathname = pathname || isBrowser ? location.pathname : "";
15
- return pathname
16
- .replace(/^\//, "")
17
- .split("/")
18
- .filter(function (part) { return part; });
13
+ return pathname.replace(/^\//, "").split("/").filter((part)=>part);
19
14
  }
20
15
  export default getUrlPathnameParts;
@@ -4,10 +4,9 @@ import { type AnyQueryParams } from "./location";
4
4
  *
5
5
  * @category location
6
6
  * @param url A URL which contains a `?`, e.g. `?myparam=x` or `https://a.com?myparams=x`.
7
- * If not provided it defaults reading the current URL query string with
8
- * `location.search`. Through this argument you can use this
9
- * same function to parse, for instance, the query params of
10
- * the `href` of a `<a href="...">` HTML tag.
7
+ * If not provided it defaults reading the current URL query string with
8
+ * `location.search`. Through this argument you can use this same function to
9
+ * parse, for instance, the query params of the `href` of a `<a href="...">` HTML tag.
11
10
  *
12
11
  */
13
12
  export declare function getUrlQueryParams<T extends NonNullable<AnyQueryParams>>(url?: string): T;
@@ -4,34 +4,22 @@ import isBrowser from "./isBrowser";
4
4
  *
5
5
  * @category location
6
6
  * @param url A URL which contains a `?`, e.g. `?myparam=x` or `https://a.com?myparams=x`.
7
- * If not provided it defaults reading the current URL query string with
8
- * `location.search`. Through this argument you can use this
9
- * same function to parse, for instance, the query params of
10
- * the `href` of a `<a href="...">` HTML tag.
7
+ * If not provided it defaults reading the current URL query string with
8
+ * `location.search`. Through this argument you can use this same function to
9
+ * parse, for instance, the query params of the `href` of a `<a href="...">` HTML tag.
11
10
  *
12
- */
13
- export function getUrlQueryParams(url) {
14
- var _a;
15
- var params = {};
16
- var search = url
17
- ? (_a = url.split("?")) === null || _a === void 0 ? void 0 : _a[1]
18
- : isBrowser
19
- ? location.search.substring(1)
20
- : "";
11
+ */ export function getUrlQueryParams(url) {
12
+ let params = {};
13
+ const search = url ? url.split("?")?.[1] : isBrowser ? location.search.substring(1) : "";
21
14
  if (!search) {
22
15
  return {};
23
16
  }
24
17
  try {
25
18
  // @see https://stackoverflow.com/a/8649003/1938970
26
- var paramsAsObj = "{\"".concat(search
27
- .replace(/&/g, '","')
28
- .replace(/=/g, '":"'), "\"}");
29
- params = JSON.parse(paramsAsObj, function (key, value) {
30
- return key === "" ? value : decodeURIComponent(value);
31
- });
32
- }
33
- catch (e) {
34
- // do nothing or warn on process.env["NODE_ENV"] !== "production"
19
+ const paramsAsObj = `{"${search.replace(/&/g, '","').replace(/=/g, '":"')}"}`;
20
+ params = JSON.parse(paramsAsObj, (key, value)=>key === "" ? value : decodeURIComponent(value));
21
+ } catch (e) {
22
+ // do nothing or warn on process.env["NODE_ENV"] !== "production"
35
23
  }
36
24
  return params;
37
25
  }
package/imgEmptyPixel.mjs CHANGED
@@ -2,6 +2,5 @@
2
2
  * Empty img pixel as a string to inline
3
3
  *
4
4
  * @category img
5
- */
6
- export var imgEmptyPixel = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=";
5
+ */ export const imgEmptyPixel = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=";
7
6
  export default imgEmptyPixel;
package/index.d.ts CHANGED
@@ -10,7 +10,7 @@ export { changeUrlPath } from "./changeUrlPath";
10
10
  export { chunkByChunks } from "./chunkByChunks";
11
11
  export { chunkBySize } from "./chunkBySize";
12
12
  export { clamp } from "./clamp";
13
- export { clsx } from "./clsx";
13
+ export { clsx, type ClsxClassValue } from "./clsx";
14
14
  export { convertRange } from "./convertRange";
15
15
  export { type CookieAttributesClient, type CookieAttributesServer, } from "./cookie";
16
16
  export { createPalette } from "./createPalette";
@@ -131,4 +131,7 @@ export { uuid } from "./uuid";
131
131
  export { uuidNumeric } from "./uuidNumeric";
132
132
  export { wait } from "./wait";
133
133
  export type { AnythingFalsy, KeysStartsWith, KeysTailsStartsWith, PickStartsWith, PickStartsWithTails, } from "./types";
134
- export type { Primitive, Class, Constructor, TypedArray, Observer, ObservableLike, Except, Writable, Merge, MergeDeep, MergeExclusive, RequireAtLeastOne, RequireExactlyOne, RequireAllOrNone, RemoveIndexSignature, PartialDeep, ReadonlyDeep, LiteralUnion, Opaque, InvariantOf, SetOptional, SetRequired, ValueOf, ConditionalKeys, ConditionalPick, ConditionalExcept, UnionToIntersection, LiteralToPrimitive, Stringified, IterableElement, Entry, Exact, Entries, SetReturnType, Simplify, Get, StringKeyOf, Schema, Jsonify, JsonPrimitive, JsonObject, JsonArray, JsonValue, Promisable, AsyncReturnType, Asyncify, Trim, Split, Includes, Join, LastArrayElement, FixedLengthArray, MultidimensionalArray, MultidimensionalReadonlyArray, PositiveInfinity, NegativeInfinity, Finite, Integer, Float, NegativeFloat, Negative, NonNegative, NegativeInteger, NonNegativeInteger, CamelCase, CamelCasedProperties, CamelCasedPropertiesDeep, KebabCase, KebabCasedProperties, KebabCasedPropertiesDeep, PascalCase, PascalCasedProperties, PascalCasedPropertiesDeep, SnakeCase, SnakeCasedProperties, SnakeCasedPropertiesDeep, ScreamingSnakeCase, DelimiterCase, DelimiterCasedProperties, DelimiterCasedPropertiesDeep, PackageJson, TsConfigJson, SetNonNullable, Spread, PartialOnUndefinedDeep, OptionalKeysOf, HasOptionalKeys, RequiredKeysOf, HasRequiredKeys, UnwrapOpaque, EmptyObject, IsEmptyObject, TupleToUnion, OmitIndexSignature, PickIndexSignature, ConditionalPickDeep, } from "type-fest";
134
+ /**
135
+ * These types should not be documented by using [`excludeExternals` TypeDoc flag](https://typedoc.org/options/input/#excludeexternals)
136
+ */
137
+ export type { Primitive, Class, Constructor, TypedArray, Observer, ObservableLike, Except, Writable, Merge, MergeDeep, MergeExclusive, RequireAtLeastOne, RequireExactlyOne, RequireAllOrNone, PartialDeep, ReadonlyDeep, LiteralUnion, Opaque, InvariantOf, SetOptional, SetRequired, ValueOf, ConditionalKeys, ConditionalPick, ConditionalExcept, UnionToIntersection, LiteralToPrimitive, Stringified, IterableElement, Entry, Exact, Entries, SetReturnType, Simplify, Get, StringKeyOf, Schema, Jsonify, JsonPrimitive, JsonObject, JsonArray, JsonValue, Promisable, AsyncReturnType, Asyncify, Trim, Split, Includes, Join, LastArrayElement, FixedLengthArray, MultidimensionalArray, MultidimensionalReadonlyArray, PositiveInfinity, NegativeInfinity, Finite, Integer, Float, NegativeFloat, Negative, NonNegative, NegativeInteger, NonNegativeInteger, CamelCase, CamelCasedProperties, CamelCasedPropertiesDeep, KebabCase, KebabCasedProperties, KebabCasedPropertiesDeep, PascalCase, PascalCasedProperties, PascalCasedPropertiesDeep, SnakeCase, SnakeCasedProperties, SnakeCasedPropertiesDeep, ScreamingSnakeCase, DelimiterCase, DelimiterCasedProperties, DelimiterCasedPropertiesDeep, PackageJson, TsConfigJson, SetNonNullable, Spread, PartialOnUndefinedDeep, OptionalKeysOf, HasOptionalKeys, RequiredKeysOf, HasRequiredKeys, UnwrapOpaque, EmptyObject, IsEmptyObject, TupleToUnion, OmitIndexSignature, PickIndexSignature, ConditionalPickDeep, } from "type-fest";
package/index.mjs CHANGED
@@ -15,7 +15,7 @@ export { convertRange } from "./convertRange";
15
15
  export { createPalette } from "./createPalette";
16
16
  export { debounce } from "./debounce";
17
17
  export { debounceRaf } from "./debounceRaf";
18
- export { debouncePromise, } from "./debouncePromise";
18
+ export { debouncePromise } from "./debouncePromise";
19
19
  export { decode } from "./decode";
20
20
  export { Defer } from "./Defer";
21
21
  export { Emitter } from "./Emitter";
@@ -34,7 +34,7 @@ export { getNonce } from "./getNonce";
34
34
  export { getParamAmong } from "./getParamAmong";
35
35
  export { getParamAsInt } from "./getParamAsInt";
36
36
  export { getParamAsString } from "./getParamAsString";
37
- export { getType, } from "./getType";
37
+ export { getType } from "./getType";
38
38
  export { getUrlHashParams } from "./getUrlHashParams";
39
39
  export { getUrlHashPathname } from "./getUrlHashPathname";
40
40
  export { getUrlPathnameParts } from "./getUrlPathnameParts";
package/invariant.mjs CHANGED
@@ -14,19 +14,17 @@
14
14
  * @param message A string or a function that returns a string
15
15
  * @param lib The library name to show in the error message prefix. When `lib` is also specified it outputs `[lib:prefix]: the message`, otherwise just `[lib|prefix]: the message`)
16
16
  * @param prefix The library name to show in the error message prefix. When `lib` is also specified it outputs `[lib:prefix]: the message`, otherwise just `[lib|prefix]: the message`)
17
- */
18
- export function invariant(condition, message, lib, prefix) {
17
+ */ export function invariant(condition, message, lib, prefix) {
19
18
  if (process.env["NODE_ENV"] !== "production") {
20
19
  if (condition) {
21
20
  return;
22
21
  }
23
- var msgProvided = typeof message === "function" ? message() : message;
24
- var msgPrefix = "";
22
+ const msgProvided = typeof message === "function" ? message() : message;
23
+ let msgPrefix = "";
25
24
  if (lib && prefix) {
26
- msgPrefix = "[".concat(lib, ":").concat(prefix, "] ");
27
- }
28
- else if (lib) {
29
- msgPrefix = "[".concat(lib, "] ");
25
+ msgPrefix = `[${lib}:${prefix}] `;
26
+ } else if (lib) {
27
+ msgPrefix = `[${lib}] `;
30
28
  }
31
29
  throw new Error(msgPrefix + msgProvided);
32
30
  }
package/isAnyObject.mjs CHANGED
@@ -3,8 +3,7 @@ import getType from "./getType";
3
3
  * Returns whether the payload is an any kind of object (including special classes or objects with different prototypes)
4
4
  *
5
5
  * @category is
6
- */
7
- export function isAnyObject(payload) {
6
+ */ export function isAnyObject(payload) {
8
7
  return getType(payload) === "Object";
9
8
  }
10
9
  export default isAnyObject;
package/isArray.mjs CHANGED
@@ -3,8 +3,7 @@ import getType from "./getType";
3
3
  * Returns whether the payload is an array
4
4
  *
5
5
  * @category is
6
- */
7
- export function isArray(payload) {
6
+ */ export function isArray(payload) {
8
7
  return getType(payload) === "Array";
9
8
  }
10
9
  export default isArray;
package/isBlob.mjs CHANGED
@@ -3,8 +3,7 @@ import getType from "./getType";
3
3
  * Returns whether the payload is a Blob
4
4
  *
5
5
  * @category is
6
- */
7
- export function isBlob(payload) {
6
+ */ export function isBlob(payload) {
8
7
  return getType(payload) === "Blob";
9
8
  }
10
9
  export default isBlob;
package/isBoolean.mjs CHANGED
@@ -3,8 +3,7 @@ import getType from "./getType";
3
3
  * Returns whether the payload is a boolean
4
4
  *
5
5
  * @category is
6
- */
7
- export function isBoolean(payload) {
6
+ */ export function isBoolean(payload) {
8
7
  return getType(payload) === "Boolean";
9
8
  }
10
9
  export default isBoolean;
package/isBrowser.mjs CHANGED
@@ -1,6 +1,5 @@
1
1
  /**
2
2
  * @category ssr
3
3
  * @category is
4
- */
5
- export var isBrowser = typeof window !== "undefined";
4
+ */ export const isBrowser = typeof window !== "undefined";
6
5
  export default isBrowser;
package/isBrowserNow.mjs CHANGED
@@ -2,6 +2,5 @@ import isUndefined from "./isUndefined";
2
2
  /**
3
3
  * @category ssr
4
4
  * @category is
5
- */
6
- export var isBrowserNow = function () { return !isUndefined(window); };
5
+ */ export const isBrowserNow = ()=>!isUndefined(window);
7
6
  export default isBrowserNow;
package/isDate.mjs CHANGED
@@ -3,8 +3,7 @@ import getType from "./getType";
3
3
  * Returns whether the payload is a Date, and that the date is valid
4
4
  *
5
5
  * @category is
6
- */
7
- export function isDate(payload) {
6
+ */ export function isDate(payload) {
8
7
  return getType(payload) === "Date" && !isNaN(payload);
9
8
  }
10
9
  export default isDate;
package/isEmptyArray.mjs CHANGED
@@ -3,8 +3,7 @@ import isArray from "./isArray";
3
3
  * Returns whether the payload is a an empty array
4
4
  *
5
5
  * @category is
6
- */
7
- export function isEmptyArray(payload) {
6
+ */ export function isEmptyArray(payload) {
8
7
  return isArray(payload) && payload.length === 0;
9
8
  }
10
9
  export default isEmptyArray;
package/isEmptyObject.mjs CHANGED
@@ -3,8 +3,7 @@ import isPlainObject from "./isPlainObject";
3
3
  * Returns whether the payload is a an empty object (excluding special classes or objects with other prototypes)
4
4
  *
5
5
  * @category is
6
- */
7
- export function isEmptyObject(payload) {
6
+ */ export function isEmptyObject(payload) {
8
7
  return isPlainObject(payload) && Object.keys(payload).length === 0;
9
8
  }
10
9
  export default isEmptyObject;
package/isEmptyString.mjs CHANGED
@@ -2,8 +2,7 @@
2
2
  * Returns whether the payload is ''
3
3
  *
4
4
  * @category is
5
- */
6
- export function isEmptyString(payload) {
5
+ */ export function isEmptyString(payload) {
7
6
  return payload === "";
8
7
  }
9
8
  export default isEmptyString;
package/isError.mjs CHANGED
@@ -3,8 +3,7 @@ import getType from "./getType";
3
3
  * Returns whether the payload is an Error
4
4
  *
5
5
  * @category is
6
- */
7
- export function isError(payload) {
6
+ */ export function isError(payload) {
8
7
  return getType(payload) === "Error";
9
8
  }
10
9
  export default isError;
package/isExternalUrl.mjs CHANGED
@@ -5,17 +5,15 @@ import isBrowser from "./isBrowser";
5
5
  *
6
6
  * @category location
7
7
  *
8
- */
9
- export function isExternalUrl(url, currentUrl) {
10
- var _a;
11
- var reg = /https?:\/\/((?:[\w\d-]+\.)+[\w\d]{2,})/i;
12
- var urlMatches = reg.exec(url);
8
+ */ export function isExternalUrl(url, currentUrl) {
9
+ const reg = /https?:\/\/((?:[\w\d-]+\.)+[\w\d]{2,})/i;
10
+ const urlMatches = reg.exec(url);
13
11
  // if no matches are found it means we either have an invalid URL, a relative
14
12
  // URL or a hash link, and those are not considered externals
15
13
  if (!urlMatches) {
16
14
  return false;
17
15
  }
18
16
  currentUrl = currentUrl || isBrowser ? location.href : "";
19
- return currentUrl ? ((_a = reg.exec(currentUrl)) === null || _a === void 0 ? void 0 : _a[1]) !== urlMatches[1] : true;
17
+ return currentUrl ? reg.exec(currentUrl)?.[1] !== urlMatches[1] : true;
20
18
  }
21
19
  export default isExternalUrl;
package/isFile.mjs CHANGED
@@ -3,8 +3,7 @@ import getType from "./getType";
3
3
  * Returns whether the payload is a File
4
4
  *
5
5
  * @category is
6
- */
7
- export function isFile(payload) {
6
+ */ export function isFile(payload) {
8
7
  return getType(payload) === "File";
9
8
  }
10
9
  export default isFile;