@koine/utils 1.0.26 → 1.0.29

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 (345) hide show
  1. package/{async.d.ts → Defer.d.ts} +5 -5
  2. package/{async.js → Defer.js} +2 -7
  3. package/{emitter.d.ts → Emitter.d.ts} +1 -0
  4. package/{emitter.js → Emitter.js} +1 -0
  5. package/accentSets.d.ts +16 -0
  6. package/accentSets.js +38 -0
  7. package/addOrReplaceAtIdx.d.ts +5 -0
  8. package/addOrReplaceAtIdx.js +19 -0
  9. package/arrayToLookup.d.ts +7 -0
  10. package/arrayToLookup.js +13 -0
  11. package/buildUrlQueryString.d.ts +12 -0
  12. package/buildUrlQueryString.js +24 -0
  13. package/changeUrlPath.d.ts +10 -0
  14. package/changeUrlPath.js +18 -0
  15. package/chunkByChunks.d.ts +7 -0
  16. package/chunkByChunks.js +37 -0
  17. package/chunkBySize.d.ts +6 -0
  18. package/chunkBySize.js +12 -0
  19. package/clamp.d.ts +8 -0
  20. package/clamp.js +10 -0
  21. package/clsx.d.ts +9 -0
  22. package/clsx.js +49 -0
  23. package/convertRange.d.ts +14 -0
  24. package/convertRange.js +16 -0
  25. package/cookie.d.ts +7 -26
  26. package/cookie.js +3 -221
  27. package/decode.d.ts +6 -0
  28. package/decode.js +10 -0
  29. package/encode.d.ts +6 -0
  30. package/encode.js +10 -0
  31. package/{cast.d.ts → ensureInt.d.ts} +3 -1
  32. package/{cast.js → ensureInt.js} +3 -4
  33. package/findDuplicatedIndexes.d.ts +5 -0
  34. package/findDuplicatedIndexes.js +14 -0
  35. package/getKeys.d.ts +9 -0
  36. package/getKeys.js +9 -0
  37. package/getNonce.d.ts +6 -0
  38. package/getNonce.js +9 -0
  39. package/getType.d.ts +22 -0
  40. package/getType.js +19 -0
  41. package/getUrlHashParams.d.ts +9 -0
  42. package/getUrlHashParams.js +16 -0
  43. package/getUrlHashPathname.d.ts +9 -0
  44. package/getUrlHashPathname.js +13 -0
  45. package/getUrlPathnameParts.d.ts +12 -0
  46. package/getUrlPathnameParts.js +20 -0
  47. package/getUrlQueryParams.d.ts +14 -0
  48. package/getUrlQueryParams.js +38 -0
  49. package/index.d.ts +107 -15
  50. package/index.js +108 -16
  51. package/isAnyObject.d.ts +8 -0
  52. package/isAnyObject.js +10 -0
  53. package/isArray.d.ts +7 -0
  54. package/isArray.js +10 -0
  55. package/isBlob.d.ts +7 -0
  56. package/isBlob.js +10 -0
  57. package/isBoolean.d.ts +7 -0
  58. package/isBoolean.js +10 -0
  59. package/isBrowser.d.ts +6 -0
  60. package/{ssr.js → isBrowser.js} +5 -2
  61. package/isDate.d.ts +7 -0
  62. package/isDate.js +10 -0
  63. package/isEmptyArray.d.ts +7 -0
  64. package/isEmptyArray.js +10 -0
  65. package/isEmptyObject.d.ts +9 -0
  66. package/isEmptyObject.js +10 -0
  67. package/isEmptyString.d.ts +7 -0
  68. package/isEmptyString.js +9 -0
  69. package/isError.d.ts +7 -0
  70. package/isError.js +10 -0
  71. package/isExternalUrl.d.ts +9 -0
  72. package/isExternalUrl.js +21 -0
  73. package/isFile.d.ts +7 -0
  74. package/isFile.js +10 -0
  75. package/isFloat.d.ts +7 -0
  76. package/isFloat.js +10 -0
  77. package/isFormData.d.ts +7 -0
  78. package/isFormData.js +10 -0
  79. package/isFullArray.d.ts +7 -0
  80. package/isFullArray.js +10 -0
  81. package/isFullObject.d.ts +8 -0
  82. package/isFullObject.js +10 -0
  83. package/isFullString.d.ts +7 -0
  84. package/isFullString.js +10 -0
  85. package/isFunction.d.ts +8 -0
  86. package/isFunction.js +9 -0
  87. package/{detect.d.ts → isIE.d.ts} +3 -4
  88. package/isIE.js +18 -0
  89. package/isInt.d.ts +7 -0
  90. package/isInt.js +10 -0
  91. package/isMap.d.ts +7 -0
  92. package/isMap.js +10 -0
  93. package/isMobile.d.ts +7 -0
  94. package/{detect.js → isMobile.js} +4 -15
  95. package/isNaNValue.d.ts +7 -0
  96. package/isNaNValue.js +10 -0
  97. package/isNegativeNumber.d.ts +7 -0
  98. package/isNegativeNumber.js +10 -0
  99. package/isNull.d.ts +7 -0
  100. package/isNull.js +10 -0
  101. package/isNullOrUndefined.d.ts +7 -0
  102. package/isNullOrUndefined.js +10 -0
  103. package/isNumber.d.ts +9 -0
  104. package/isNumber.js +12 -0
  105. package/isObject.d.ts +8 -0
  106. package/isObject.js +10 -0
  107. package/isObjectLike.d.ts +10 -0
  108. package/isObjectLike.js +12 -0
  109. package/isOneOf.d.ts +9 -0
  110. package/isOneOf.js +10 -0
  111. package/isPlainObject.d.ts +8 -0
  112. package/isPlainObject.js +13 -0
  113. package/isPositiveNumber.d.ts +7 -0
  114. package/isPositiveNumber.js +10 -0
  115. package/isPrimitive.d.ts +7 -0
  116. package/isPrimitive.js +20 -0
  117. package/isPromise.d.ts +7 -0
  118. package/isPromise.js +10 -0
  119. package/isRegExp.d.ts +7 -0
  120. package/isRegExp.js +10 -0
  121. package/isServer.d.ts +6 -0
  122. package/isServer.js +8 -0
  123. package/isSet.d.ts +7 -0
  124. package/isSet.js +10 -0
  125. package/isString.d.ts +7 -0
  126. package/isString.js +10 -0
  127. package/isSymbol.d.ts +7 -0
  128. package/isSymbol.js +10 -0
  129. package/isType.d.ts +11 -0
  130. package/isType.js +22 -0
  131. package/isUndefined.d.ts +7 -0
  132. package/isUndefined.js +10 -0
  133. package/isWeakMap.d.ts +7 -0
  134. package/isWeakMap.js +10 -0
  135. package/isWeakSet.d.ts +7 -0
  136. package/isWeakSet.js +10 -0
  137. package/location.d.ts +2 -145
  138. package/location.js +1 -299
  139. package/mapListBy.d.ts +7 -0
  140. package/mapListBy.js +14 -0
  141. package/{match-sorter.d.ts → matchSorter.d.ts} +1 -0
  142. package/{match-sorter.js → matchSorter.js} +2 -1
  143. package/mergeObjects.d.ts +7 -0
  144. package/{objects.js → mergeObjects.js} +2 -31
  145. package/mergeUrlQueryParams.d.ts +9 -0
  146. package/mergeUrlQueryParams.js +22 -0
  147. package/navigateToHashParams.d.ts +9 -0
  148. package/navigateToHashParams.js +22 -0
  149. package/navigateToMergedHashParams.d.ts +8 -0
  150. package/navigateToMergedHashParams.js +14 -0
  151. package/navigateToMergedParams.d.ts +9 -0
  152. package/navigateToMergedParams.js +14 -0
  153. package/navigateToParams.d.ts +10 -0
  154. package/navigateToParams.js +18 -0
  155. package/navigateWithoutUrlParam.d.ts +8 -0
  156. package/navigateWithoutUrlParam.js +19 -0
  157. package/node/{async.js → Defer.js} +3 -9
  158. package/node/{emitter.js → Emitter.js} +1 -0
  159. package/node/accentSets.js +41 -0
  160. package/node/addOrReplaceAtIdx.js +23 -0
  161. package/node/arrayToLookup.js +17 -0
  162. package/node/buildUrlQueryString.js +28 -0
  163. package/node/changeUrlPath.js +22 -0
  164. package/node/chunkByChunks.js +41 -0
  165. package/node/chunkBySize.js +16 -0
  166. package/node/clamp.js +14 -0
  167. package/node/clsx.js +53 -0
  168. package/node/convertRange.js +20 -0
  169. package/node/cookie.js +4 -227
  170. package/node/decode.js +14 -0
  171. package/node/encode.js +14 -0
  172. package/node/{cast.js → ensureInt.js} +4 -6
  173. package/node/findDuplicatedIndexes.js +18 -0
  174. package/node/getKeys.js +12 -0
  175. package/node/getNonce.js +13 -0
  176. package/node/getType.js +23 -0
  177. package/node/getUrlHashParams.js +20 -0
  178. package/node/getUrlHashPathname.js +17 -0
  179. package/node/getUrlPathnameParts.js +24 -0
  180. package/node/getUrlQueryParams.js +42 -0
  181. package/node/index.js +108 -16
  182. package/node/isAnyObject.js +14 -0
  183. package/node/isArray.js +14 -0
  184. package/node/isBlob.js +14 -0
  185. package/node/isBoolean.js +14 -0
  186. package/node/{ssr.js → isBrowser.js} +6 -3
  187. package/node/isDate.js +14 -0
  188. package/node/isEmptyArray.js +14 -0
  189. package/node/isEmptyObject.js +14 -0
  190. package/node/isEmptyString.js +13 -0
  191. package/node/isError.js +14 -0
  192. package/node/isExternalUrl.js +25 -0
  193. package/node/isFile.js +14 -0
  194. package/node/isFloat.js +14 -0
  195. package/node/isFormData.js +14 -0
  196. package/node/isFullArray.js +14 -0
  197. package/node/isFullObject.js +14 -0
  198. package/node/isFullString.js +14 -0
  199. package/node/isFunction.js +13 -0
  200. package/node/isIE.js +22 -0
  201. package/node/isInt.js +14 -0
  202. package/node/isMap.js +14 -0
  203. package/node/{detect.js → isMobile.js} +6 -18
  204. package/node/isNaNValue.js +14 -0
  205. package/node/isNegativeNumber.js +14 -0
  206. package/node/isNull.js +14 -0
  207. package/node/isNullOrUndefined.js +13 -0
  208. package/node/isNumber.js +16 -0
  209. package/node/isObject.js +14 -0
  210. package/node/isObjectLike.js +16 -0
  211. package/node/isOneOf.js +14 -0
  212. package/node/isPlainObject.js +17 -0
  213. package/node/isPositiveNumber.js +14 -0
  214. package/node/isPrimitive.js +24 -0
  215. package/node/isPromise.js +14 -0
  216. package/node/isRegExp.js +14 -0
  217. package/node/isServer.js +11 -0
  218. package/node/isSet.js +14 -0
  219. package/node/isString.js +14 -0
  220. package/node/isSymbol.js +14 -0
  221. package/node/isType.js +26 -0
  222. package/node/isUndefined.js +14 -0
  223. package/node/isWeakMap.js +14 -0
  224. package/node/isWeakSet.js +14 -0
  225. package/node/location.js +0 -321
  226. package/node/mapListBy.js +18 -0
  227. package/node/{match-sorter.js → matchSorter.js} +3 -2
  228. package/node/{objects.js → mergeObjects.js} +5 -36
  229. package/node/mergeUrlQueryParams.js +26 -0
  230. package/node/navigateToHashParams.js +26 -0
  231. package/node/navigateToMergedHashParams.js +18 -0
  232. package/node/navigateToMergedParams.js +18 -0
  233. package/node/navigateToParams.js +22 -0
  234. package/node/navigateWithoutUrlParam.js +23 -0
  235. package/node/normaliseUrl.js +18 -0
  236. package/node/normaliseUrlPathname.js +18 -0
  237. package/node/{analytics-google.js → pageview.js} +12 -10
  238. package/node/parseCookie.js +52 -0
  239. package/node/parseURL.js +24 -0
  240. package/node/randomInt.js +13 -0
  241. package/node/{misc.js → randomKey.js} +2 -0
  242. package/node/readCookie.js +38 -0
  243. package/node/redirectTo.js +19 -0
  244. package/node/removeAccents.js +19 -0
  245. package/node/removeCookie.js +19 -0
  246. package/node/removeDuplicatesByKey.js +25 -0
  247. package/node/removeDuplicatesComparing.js +14 -0
  248. package/node/removeIndexesFromArray.js +18 -0
  249. package/node/removeTrailingSlash.js +14 -0
  250. package/node/{math.js → roundTo.js} +3 -32
  251. package/node/serializeCookie.js +108 -0
  252. package/node/setCookie.js +61 -0
  253. package/node/shuffle.js +36 -0
  254. package/node/slugify.js +27 -0
  255. package/node/swapMap.js +18 -0
  256. package/node/{typography.js → titleCase.js} +3 -12
  257. package/node/toNumber.js +12 -0
  258. package/node/{colors.js → toRgba.js} +4 -0
  259. package/node/transformToUrlPathname.js +20 -0
  260. package/node/truncate.js +17 -0
  261. package/node/uid.js +4 -13
  262. package/node/updateLinkParams.js +18 -0
  263. package/node/updateUrlQueryParams.js +22 -0
  264. package/node/uuid.js +17 -0
  265. package/node/wait.js +13 -0
  266. package/node/whitelistObject.js +19 -0
  267. package/normaliseUrl.d.ts +10 -0
  268. package/normaliseUrl.js +14 -0
  269. package/normaliseUrlPathname.d.ts +10 -0
  270. package/normaliseUrlPathname.js +14 -0
  271. package/package.json +1 -1
  272. package/{analytics-google.d.ts → pageview.d.ts} +3 -0
  273. package/{analytics-google.js → pageview.js} +12 -10
  274. package/parseCookie.d.ts +11 -0
  275. package/parseCookie.js +48 -0
  276. package/parseURL.d.ts +17 -0
  277. package/parseURL.js +20 -0
  278. package/randomInt.d.ts +7 -0
  279. package/randomInt.js +9 -0
  280. package/{misc.d.ts → randomKey.d.ts} +2 -0
  281. package/{misc.js → randomKey.js} +2 -0
  282. package/readCookie.d.ts +3 -0
  283. package/readCookie.js +34 -0
  284. package/redirectTo.d.ts +9 -0
  285. package/redirectTo.js +15 -0
  286. package/removeAccents.d.ts +6 -0
  287. package/removeAccents.js +15 -0
  288. package/removeCookie.d.ts +10 -0
  289. package/removeCookie.js +15 -0
  290. package/removeDuplicatesByKey.d.ts +8 -0
  291. package/removeDuplicatesByKey.js +21 -0
  292. package/removeDuplicatesComparing.d.ts +5 -0
  293. package/removeDuplicatesComparing.js +10 -0
  294. package/removeIndexesFromArray.d.ts +5 -0
  295. package/removeIndexesFromArray.js +14 -0
  296. package/removeTrailingSlash.d.ts +7 -0
  297. package/removeTrailingSlash.js +10 -0
  298. package/roundTo.d.ts +8 -0
  299. package/{math.js → roundTo.js} +2 -28
  300. package/serializeCookie.d.ts +27 -0
  301. package/serializeCookie.js +104 -0
  302. package/setCookie.d.ts +10 -0
  303. package/setCookie.js +57 -0
  304. package/shuffle.d.ts +16 -0
  305. package/shuffle.js +32 -0
  306. package/{text.d.ts → slugify.d.ts} +2 -5
  307. package/slugify.js +23 -0
  308. package/swapMap.d.ts +7 -0
  309. package/swapMap.js +14 -0
  310. package/{typography.d.ts → titleCase.d.ts} +2 -4
  311. package/{typography.js → titleCase.js} +2 -10
  312. package/toNumber.d.ts +5 -0
  313. package/toNumber.js +8 -0
  314. package/{colors.d.ts → toRgba.d.ts} +4 -0
  315. package/{colors.js → toRgba.js} +4 -0
  316. package/transformToUrlPathname.d.ts +11 -0
  317. package/transformToUrlPathname.js +16 -0
  318. package/truncate.d.ts +7 -0
  319. package/truncate.js +13 -0
  320. package/uid.d.ts +3 -6
  321. package/uid.js +3 -11
  322. package/updateLinkParams.d.ts +10 -0
  323. package/updateLinkParams.js +14 -0
  324. package/updateUrlQueryParams.d.ts +9 -0
  325. package/updateUrlQueryParams.js +18 -0
  326. package/uuid.d.ts +8 -0
  327. package/uuid.js +13 -0
  328. package/wait.d.ts +7 -0
  329. package/wait.js +9 -0
  330. package/whitelistObject.d.ts +8 -0
  331. package/whitelistObject.js +15 -0
  332. package/arrays.d.ts +0 -41
  333. package/arrays.js +0 -153
  334. package/is.d.ts +0 -288
  335. package/is.js +0 -376
  336. package/math.d.ts +0 -28
  337. package/node/arrays.js +0 -166
  338. package/node/is.js +0 -417
  339. package/node/security.js +0 -29
  340. package/node/text.js +0 -70
  341. package/objects.d.ts +0 -22
  342. package/security.d.ts +0 -12
  343. package/security.js +0 -23
  344. package/ssr.d.ts +0 -2
  345. package/text.js +0 -65
package/node/is.js DELETED
@@ -1,417 +0,0 @@
1
- "use strict";
2
- /**
3
- * @file
4
- *
5
- * Same as [is-what](https://github.com/mesqueeb/is-what) plus:
6
- *
7
- * - `isFormData`
8
- * - `isInt`
9
- * - `isFloat`
10
- */
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.isFloat = exports.isInt = exports.isFormData = exports.isType = exports.isOneOf = exports.isNullOrUndefined = exports.isPrimitive = exports.isNaNValue = exports.isError = exports.isPromise = exports.isFile = exports.isBlob = exports.isDate = exports.isSymbol = exports.isWeakSet = exports.isSet = exports.isWeakMap = exports.isMap = exports.isRegExp = exports.isBoolean = exports.isNegativeNumber = exports.isPositiveNumber = exports.isNumber = exports.isEmptyString = exports.isFullString = exports.isString = exports.isEmptyArray = exports.isFullArray = exports.isArray = exports.isFunction = exports.isObjectLike = exports.isAnyObject = exports.isFullObject = exports.isEmptyObject = exports.isObject = exports.isPlainObject = exports.isNull = exports.isUndefined = exports.getType = void 0;
13
- /**
14
- * Returns the object type of the given payload
15
- *
16
- * @param {*} payload
17
- * @returns {string}
18
- */
19
- function getType(payload) {
20
- return Object.prototype.toString.call(payload).slice(8, -1);
21
- }
22
- exports.getType = getType;
23
- /**
24
- * Returns whether the payload is undefined
25
- *
26
- * @param {*} payload
27
- * @returns {payload is undefined}
28
- */
29
- function isUndefined(payload) {
30
- return getType(payload) === "Undefined";
31
- }
32
- exports.isUndefined = isUndefined;
33
- /**
34
- * Returns whether the payload is null
35
- *
36
- * @param {*} payload
37
- * @returns {payload is null}
38
- */
39
- function isNull(payload) {
40
- return getType(payload) === "Null";
41
- }
42
- exports.isNull = isNull;
43
- /**
44
- * Returns whether the payload is a plain JavaScript object (excluding special classes or objects with other prototypes)
45
- *
46
- * @param {*} payload
47
- * @returns {payload is PlainObject}
48
- */
49
- function isPlainObject(payload) {
50
- if (getType(payload) !== "Object")
51
- return false;
52
- return (payload.constructor === Object &&
53
- Object.getPrototypeOf(payload) === Object.prototype);
54
- }
55
- exports.isPlainObject = isPlainObject;
56
- /**
57
- * Returns whether the payload is a plain JavaScript object (excluding special classes or objects with other prototypes)
58
- *
59
- * @param {*} payload
60
- * @returns {payload is PlainObject}
61
- */
62
- function isObject(payload) {
63
- return isPlainObject(payload);
64
- }
65
- exports.isObject = isObject;
66
- /**
67
- * Returns whether the payload is a an empty object (excluding special classes or objects with other prototypes)
68
- *
69
- * @param {*} payload
70
- * @returns {payload is { [K in any]: never }}
71
- */
72
- function isEmptyObject(payload) {
73
- return isPlainObject(payload) && Object.keys(payload).length === 0;
74
- }
75
- exports.isEmptyObject = isEmptyObject;
76
- /**
77
- * Returns whether the payload is a an empty object (excluding special classes or objects with other prototypes)
78
- *
79
- * @param {*} payload
80
- * @returns {payload is PlainObject}
81
- */
82
- function isFullObject(payload) {
83
- return isPlainObject(payload) && Object.keys(payload).length > 0;
84
- }
85
- exports.isFullObject = isFullObject;
86
- /**
87
- * Returns whether the payload is an any kind of object (including special classes or objects with different prototypes)
88
- *
89
- * @param {*} payload
90
- * @returns {payload is PlainObject}
91
- */
92
- function isAnyObject(payload) {
93
- return getType(payload) === "Object";
94
- }
95
- exports.isAnyObject = isAnyObject;
96
- /**
97
- * Returns whether the payload is an object like a type passed in < >
98
- *
99
- * Usage: isObjectLike<{id: any}>(payload) // will make sure it's an object and has an `id` prop.
100
- *
101
- * @template T this must be passed in < >
102
- * @param {*} payload
103
- * @returns {payload is T}
104
- */
105
- function isObjectLike(payload) {
106
- return isAnyObject(payload);
107
- }
108
- exports.isObjectLike = isObjectLike;
109
- /**
110
- * Returns whether the payload is a function (regular or async)
111
- *
112
- * @param {*} payload
113
- * @returns {payload is AnyFunction}
114
- */
115
- function isFunction(payload) {
116
- return typeof payload === "function";
117
- }
118
- exports.isFunction = isFunction;
119
- /**
120
- * Returns whether the payload is an array
121
- *
122
- * @param {any} payload
123
- * @returns {payload is any[]}
124
- */
125
- function isArray(payload) {
126
- return getType(payload) === "Array";
127
- }
128
- exports.isArray = isArray;
129
- /**
130
- * Returns whether the payload is a an array with at least 1 item
131
- *
132
- * @param {*} payload
133
- * @returns {payload is any[]}
134
- */
135
- function isFullArray(payload) {
136
- return isArray(payload) && payload.length > 0;
137
- }
138
- exports.isFullArray = isFullArray;
139
- /**
140
- * Returns whether the payload is a an empty array
141
- *
142
- * @param {*} payload
143
- * @returns {payload is []}
144
- */
145
- function isEmptyArray(payload) {
146
- return isArray(payload) && payload.length === 0;
147
- }
148
- exports.isEmptyArray = isEmptyArray;
149
- /**
150
- * Returns whether the payload is a string
151
- *
152
- * @param {*} payload
153
- * @returns {payload is string}
154
- */
155
- function isString(payload) {
156
- return getType(payload) === "String";
157
- }
158
- exports.isString = isString;
159
- /**
160
- * Returns whether the payload is a string, BUT returns false for ''
161
- *
162
- * @param {*} payload
163
- * @returns {payload is string}
164
- */
165
- function isFullString(payload) {
166
- return isString(payload) && payload !== "";
167
- }
168
- exports.isFullString = isFullString;
169
- /**
170
- * Returns whether the payload is ''
171
- *
172
- * @param {*} payload
173
- * @returns {payload is string}
174
- */
175
- function isEmptyString(payload) {
176
- return payload === "";
177
- }
178
- exports.isEmptyString = isEmptyString;
179
- /**
180
- * Returns whether the payload is a number (but not NaN)
181
- *
182
- * This will return `false` for `NaN`!!
183
- *
184
- * @param {*} payload
185
- * @returns {payload is number}
186
- */
187
- function isNumber(payload) {
188
- return getType(payload) === "Number" && !isNaN(payload);
189
- }
190
- exports.isNumber = isNumber;
191
- /**
192
- * Returns whether the payload is a positive number (but not 0)
193
- *
194
- * @param {*} payload
195
- * @returns {payload is number}
196
- */
197
- function isPositiveNumber(payload) {
198
- return isNumber(payload) && payload > 0;
199
- }
200
- exports.isPositiveNumber = isPositiveNumber;
201
- /**
202
- * Returns whether the payload is a negative number (but not 0)
203
- *
204
- * @param {*} payload
205
- * @returns {payload is number}
206
- */
207
- function isNegativeNumber(payload) {
208
- return isNumber(payload) && payload < 0;
209
- }
210
- exports.isNegativeNumber = isNegativeNumber;
211
- /**
212
- * Returns whether the payload is a boolean
213
- *
214
- * @param {*} payload
215
- * @returns {payload is boolean}
216
- */
217
- function isBoolean(payload) {
218
- return getType(payload) === "Boolean";
219
- }
220
- exports.isBoolean = isBoolean;
221
- /**
222
- * Returns whether the payload is a regular expression (RegExp)
223
- *
224
- * @param {*} payload
225
- * @returns {payload is RegExp}
226
- */
227
- function isRegExp(payload) {
228
- return getType(payload) === "RegExp";
229
- }
230
- exports.isRegExp = isRegExp;
231
- /**
232
- * Returns whether the payload is a Map
233
- *
234
- * @param {*} payload
235
- * @returns {payload is Map<any, any>}
236
- */
237
- function isMap(payload) {
238
- return getType(payload) === "Map";
239
- }
240
- exports.isMap = isMap;
241
- /**
242
- * Returns whether the payload is a WeakMap
243
- *
244
- * @param {*} payload
245
- * @returns {payload is WeakMap<any, any>}
246
- */
247
- function isWeakMap(payload) {
248
- return getType(payload) === "WeakMap";
249
- }
250
- exports.isWeakMap = isWeakMap;
251
- /**
252
- * Returns whether the payload is a Set
253
- *
254
- * @param {*} payload
255
- * @returns {payload is Set<any>}
256
- */
257
- function isSet(payload) {
258
- return getType(payload) === "Set";
259
- }
260
- exports.isSet = isSet;
261
- /**
262
- * Returns whether the payload is a WeakSet
263
- *
264
- * @param {*} payload
265
- * @returns {payload is WeakSet<any>}
266
- */
267
- function isWeakSet(payload) {
268
- return getType(payload) === "WeakSet";
269
- }
270
- exports.isWeakSet = isWeakSet;
271
- /**
272
- * Returns whether the payload is a Symbol
273
- *
274
- * @param {*} payload
275
- * @returns {payload is symbol}
276
- */
277
- function isSymbol(payload) {
278
- return getType(payload) === "Symbol";
279
- }
280
- exports.isSymbol = isSymbol;
281
- /**
282
- * Returns whether the payload is a Date, and that the date is valid
283
- *
284
- * @param {*} payload
285
- * @returns {payload is Date}
286
- */
287
- function isDate(payload) {
288
- return getType(payload) === "Date" && !isNaN(payload);
289
- }
290
- exports.isDate = isDate;
291
- /**
292
- * Returns whether the payload is a Blob
293
- *
294
- * @param {*} payload
295
- * @returns {payload is Blob}
296
- */
297
- function isBlob(payload) {
298
- return getType(payload) === "Blob";
299
- }
300
- exports.isBlob = isBlob;
301
- /**
302
- * Returns whether the payload is a File
303
- *
304
- * @param {*} payload
305
- * @returns {payload is File}
306
- */
307
- function isFile(payload) {
308
- return getType(payload) === "File";
309
- }
310
- exports.isFile = isFile;
311
- /**
312
- * Returns whether the payload is a Promise
313
- *
314
- * @param {*} payload
315
- * @returns {payload is Promise<any>}
316
- */
317
- function isPromise(payload) {
318
- return getType(payload) === "Promise";
319
- }
320
- exports.isPromise = isPromise;
321
- /**
322
- * Returns whether the payload is an Error
323
- *
324
- * @param {*} payload
325
- * @returns {payload is Error}
326
- */
327
- function isError(payload) {
328
- return getType(payload) === "Error";
329
- }
330
- exports.isError = isError;
331
- /**
332
- * Returns whether the payload is literally the value `NaN` (it's `NaN` and also a `number`)
333
- *
334
- * @param {*} payload
335
- * @returns {payload is typeof NaN}
336
- */
337
- function isNaNValue(payload) {
338
- return getType(payload) === "Number" && isNaN(payload);
339
- }
340
- exports.isNaNValue = isNaNValue;
341
- /**
342
- * Returns whether the payload is a primitive type (eg. Boolean | Null | Undefined | Number | String | Symbol)
343
- *
344
- * @param {*} payload
345
- * @returns {(payload is boolean | null | undefined | number | string | symbol)}
346
- */
347
- function isPrimitive(payload) {
348
- return (isBoolean(payload) ||
349
- isNull(payload) ||
350
- isUndefined(payload) ||
351
- isNumber(payload) ||
352
- isString(payload) ||
353
- isSymbol(payload));
354
- }
355
- exports.isPrimitive = isPrimitive;
356
- /**
357
- * Returns true whether the payload is null or undefined
358
- *
359
- * @param {*} payload
360
- * @returns {(payload is null | undefined)}
361
- */
362
- exports.isNullOrUndefined = isOneOf(isNull, isUndefined);
363
- function isOneOf(a, b, c, d, e) {
364
- return function (value) {
365
- return a(value) ||
366
- b(value) ||
367
- (!!c && c(value)) ||
368
- (!!d && d(value)) ||
369
- (!!e && e(value));
370
- };
371
- }
372
- exports.isOneOf = isOneOf;
373
- /**
374
- * Does a generic check to check that the given payload is of a given type.
375
- * In cases like Number, it will return true for NaN as NaN is a Number (thanks javascript!);
376
- * It will, however, differentiate between object and null
377
- *
378
- * @template T
379
- * @param {*} payload
380
- * @param {T} type
381
- * @throws {TypeError} Will throw type error if type is an invalid type
382
- * @returns {payload is T}
383
- */
384
- function isType(payload, type) {
385
- if (!(type instanceof Function)) {
386
- throw new TypeError("Type must be a function");
387
- }
388
- if (!Object.prototype.hasOwnProperty.call(type, "prototype")) {
389
- throw new TypeError("Type is not a class");
390
- }
391
- // Classes usually have names (as functions usually have names)
392
- var name = type.name;
393
- return (getType(payload) === name ||
394
- Boolean(payload && payload.constructor === type));
395
- }
396
- exports.isType = isType;
397
- /**
398
- * Returns whether the payload is a FormData
399
- */
400
- function isFormData(payload) {
401
- return getType(payload) === "FormData";
402
- }
403
- exports.isFormData = isFormData;
404
- /**
405
- * Returns whether the payload is an integer number
406
- */
407
- function isInt(payload) {
408
- return isNumber(payload) && payload % 1 === 0;
409
- }
410
- exports.isInt = isInt;
411
- /**
412
- * Returns whether the payload is a float number
413
- */
414
- function isFloat(payload) {
415
- return isNumber(payload) && payload % 1 !== 0;
416
- }
417
- exports.isFloat = isFloat;
package/node/security.js DELETED
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.decode = exports.encode = exports.getNonce = void 0;
4
- var is_1 = require("./is");
5
- /**
6
- * @see https://github.com/styled-components/styled-components/blob/main/packages/styled-components/src/utils/nonce.ts
7
- */
8
- function getNonce() {
9
- return (0, is_1.isUndefined)(__webpack_nonce__) ? null : __webpack_nonce__;
10
- }
11
- exports.getNonce = getNonce;
12
- /**
13
- * @see https://stackoverflow.com/a/22405578/9122820
14
- */
15
- function encode(str) {
16
- return str.replace(/./g, function (c) {
17
- return ("00" + c.charCodeAt(0)).slice(-3);
18
- });
19
- }
20
- exports.encode = encode;
21
- /**
22
- * @see https://stackoverflow.com/a/22405578/9122820
23
- */
24
- function decode(str) {
25
- return str.replace(/.{3}/g, function (c) {
26
- return String.fromCharCode(parseInt(c, 10));
27
- });
28
- }
29
- exports.decode = decode;
package/node/text.js DELETED
@@ -1,70 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.slugify = exports.removeAccents = void 0;
4
- /**
5
- * Accent sets
6
- *
7
- * @see https://gist.github.com/mathewbyrne/1280286#gistcomment-3498021
8
- * @see https://gist.github.com/eek/9c4887e80b3ede05c0e39fee4dce3747 for usage
9
- * of [normalize](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize)
10
- */
11
- var ACCENTS_SETS = [
12
- ["a", "ÀÁÂÃÅÆĀĂĄẠẢẤẦẨẪẬẮẰẲẴẶ"],
13
- ["ae", "Ä"],
14
- ["c", "ÇĆĈČ"],
15
- ["d", "ÐĎĐÞ"],
16
- ["e", "ÈÉÊËĒĔĖĘĚẸẺẼẾỀỂỄỆ"],
17
- ["g", "ĜĞĢǴ"],
18
- ["h", "ĤḦ"],
19
- ["i", "ÌÍÎÏĨĪĮİỈỊ"],
20
- ["j", "Ĵ"],
21
- ["ij", "IJ"],
22
- ["k", "Ķ"],
23
- ["l", "ĹĻĽŁ"],
24
- ["m", "Ḿ"],
25
- ["n", "ÑŃŅŇ"],
26
- ["o", "ÒÓÔÕØŌŎŐỌỎỐỒỔỖỘỚỜỞỠỢǪǬƠ"],
27
- ["oe", "΅"],
28
- ["p", "ṕ"],
29
- ["r", "ŔŖŘ"],
30
- ["s", "ŚŜŞŠ"],
31
- ["ss", "ß"],
32
- ["t", "ŢŤ"],
33
- ["u", "ÙÚÛŨŪŬŮŰŲỤỦỨỪỬỮỰƯ"],
34
- ["ue", "Ü"],
35
- ["w", "ẂŴẀẄ"],
36
- ["x", "ẍ"],
37
- ["y", "ÝŶŸỲỴỶỸ"],
38
- ["z", "ŹŻŽ"],
39
- ];
40
- function removeAccents(text, sets) {
41
- if (text === void 0) { text = ""; }
42
- if (sets === void 0) { sets = ACCENTS_SETS; }
43
- var len = sets.length;
44
- while (len--) {
45
- var _a = sets[len], to = _a[0], from = _a[1];
46
- text = text.replace(new RegExp("[".concat(from, "]"), "gi"), to);
47
- }
48
- return text;
49
- }
50
- exports.removeAccents = removeAccents;
51
- /**
52
- * Slugify a text
53
- *
54
- * - replaces the accented letters
55
- * - replaces the punctuation with dashes
56
- *
57
- * @see https://gist.github.com/mathewbyrne/1280286#gistcomment-3498021
58
- */
59
- function slugify(text, separator) {
60
- if (separator === void 0) { separator = "-"; }
61
- return removeAccents(text.toString().toLowerCase().trim(), ACCENTS_SETS.concat([["-", "[·/_,:;']"]]))
62
- .replace(/\s+/g, "-") // replace spaces with -
63
- .replace(/&/g, "-and-") // replace & with 'and'
64
- .replace(/[^\w-]+/g, "") // remove all non-word chars
65
- .replace(/--+/g, "-") // replace multiple - with single -
66
- .replace(/^-+/, "") // trim - from start of text
67
- .replace(/-+$/, "") // trim - from end of text
68
- .replace(/-/g, separator);
69
- }
70
- exports.slugify = slugify;
package/objects.d.ts DELETED
@@ -1,22 +0,0 @@
1
- /**
2
- * Type safe replacement for `Object.keys(myObject)` to iterate over a record
3
- * without loosing the key's types in simple `string`s.
4
- *
5
- * @see https://stackoverflow.com/a/59459000/1938970
6
- */
7
- export declare const getKeys: <T extends object>(obj: T) => (keyof T)[];
8
- /**
9
- * Merge two or more objects together. It mutates the target object.
10
- *
11
- * @see https://stackoverflow.com/a/46973278/1938970
12
- */
13
- export declare const mergeObjects: <T extends object = object>(target: T, ...sources: T[]) => T;
14
- /**
15
- * Swap object map key/value
16
- */
17
- export declare function swapMap<T extends Record<string, string | number | symbol> = Record<string, string | number | symbol>>(map?: T): Record<T[keyof T], keyof T>;
18
- /**
19
- * Whitelist an object properties by selecting only the given keys, it returns a
20
- * new object.
21
- */
22
- export declare function whitelistObject<T extends object, Keys extends (keyof T)[]>(object: T, keys: Keys): Pick<T, Keys[number]>;
package/security.d.ts DELETED
@@ -1,12 +0,0 @@
1
- /**
2
- * @see https://github.com/styled-components/styled-components/blob/main/packages/styled-components/src/utils/nonce.ts
3
- */
4
- export declare function getNonce(): string | null;
5
- /**
6
- * @see https://stackoverflow.com/a/22405578/9122820
7
- */
8
- export declare function encode(str: string): string;
9
- /**
10
- * @see https://stackoverflow.com/a/22405578/9122820
11
- */
12
- export declare function decode(str: string): string;
package/security.js DELETED
@@ -1,23 +0,0 @@
1
- import { isUndefined } from "./is";
2
- /**
3
- * @see https://github.com/styled-components/styled-components/blob/main/packages/styled-components/src/utils/nonce.ts
4
- */
5
- export function getNonce() {
6
- return isUndefined(__webpack_nonce__) ? null : __webpack_nonce__;
7
- }
8
- /**
9
- * @see https://stackoverflow.com/a/22405578/9122820
10
- */
11
- export function encode(str) {
12
- return str.replace(/./g, function (c) {
13
- return ("00" + c.charCodeAt(0)).slice(-3);
14
- });
15
- }
16
- /**
17
- * @see https://stackoverflow.com/a/22405578/9122820
18
- */
19
- export function decode(str) {
20
- return str.replace(/.{3}/g, function (c) {
21
- return String.fromCharCode(parseInt(c, 10));
22
- });
23
- }
package/ssr.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export declare const isBrowser: boolean;
2
- export declare const isServer: boolean;
package/text.js DELETED
@@ -1,65 +0,0 @@
1
- /**
2
- * Accent sets
3
- *
4
- * @see https://gist.github.com/mathewbyrne/1280286#gistcomment-3498021
5
- * @see https://gist.github.com/eek/9c4887e80b3ede05c0e39fee4dce3747 for usage
6
- * of [normalize](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize)
7
- */
8
- var ACCENTS_SETS = [
9
- ["a", "ÀÁÂÃÅÆĀĂĄẠẢẤẦẨẪẬẮẰẲẴẶ"],
10
- ["ae", "Ä"],
11
- ["c", "ÇĆĈČ"],
12
- ["d", "ÐĎĐÞ"],
13
- ["e", "ÈÉÊËĒĔĖĘĚẸẺẼẾỀỂỄỆ"],
14
- ["g", "ĜĞĢǴ"],
15
- ["h", "ĤḦ"],
16
- ["i", "ÌÍÎÏĨĪĮİỈỊ"],
17
- ["j", "Ĵ"],
18
- ["ij", "IJ"],
19
- ["k", "Ķ"],
20
- ["l", "ĹĻĽŁ"],
21
- ["m", "Ḿ"],
22
- ["n", "ÑŃŅŇ"],
23
- ["o", "ÒÓÔÕØŌŎŐỌỎỐỒỔỖỘỚỜỞỠỢǪǬƠ"],
24
- ["oe", "΅"],
25
- ["p", "ṕ"],
26
- ["r", "ŔŖŘ"],
27
- ["s", "ŚŜŞŠ"],
28
- ["ss", "ß"],
29
- ["t", "ŢŤ"],
30
- ["u", "ÙÚÛŨŪŬŮŰŲỤỦỨỪỬỮỰƯ"],
31
- ["ue", "Ü"],
32
- ["w", "ẂŴẀẄ"],
33
- ["x", "ẍ"],
34
- ["y", "ÝŶŸỲỴỶỸ"],
35
- ["z", "ŹŻŽ"],
36
- ];
37
- export function removeAccents(text, sets) {
38
- if (text === void 0) { text = ""; }
39
- if (sets === void 0) { sets = ACCENTS_SETS; }
40
- var len = sets.length;
41
- while (len--) {
42
- var _a = sets[len], to = _a[0], from = _a[1];
43
- text = text.replace(new RegExp("[".concat(from, "]"), "gi"), to);
44
- }
45
- return text;
46
- }
47
- /**
48
- * Slugify a text
49
- *
50
- * - replaces the accented letters
51
- * - replaces the punctuation with dashes
52
- *
53
- * @see https://gist.github.com/mathewbyrne/1280286#gistcomment-3498021
54
- */
55
- export function slugify(text, separator) {
56
- if (separator === void 0) { separator = "-"; }
57
- return removeAccents(text.toString().toLowerCase().trim(), ACCENTS_SETS.concat([["-", "[·/_,:;']"]]))
58
- .replace(/\s+/g, "-") // replace spaces with -
59
- .replace(/&/g, "-and-") // replace & with 'and'
60
- .replace(/[^\w-]+/g, "") // remove all non-word chars
61
- .replace(/--+/g, "-") // replace multiple - with single -
62
- .replace(/^-+/, "") // trim - from start of text
63
- .replace(/-+$/, "") // trim - from end of text
64
- .replace(/-/g, separator);
65
- }