@wener/utils 1.0.0-alpha.8 → 1.1.0

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 (360) hide show
  1. package/LICENSE.md +7 -0
  2. package/README.md +28 -0
  3. package/dist/utils.cjs +497 -0
  4. package/dist/utils.cjs.map +7 -0
  5. package/dist/utils.js +445 -0
  6. package/dist/utils.js.map +7 -0
  7. package/dist/utils.mjs +475 -0
  8. package/dist/utils.mjs.map +7 -0
  9. package/jest.config.js +8 -6
  10. package/lib/{arrays → cjs/arrays}/MaybeArray.d.ts +1 -0
  11. package/lib/{arrays → cjs/arrays}/MaybeArray.js +8 -0
  12. package/lib/cjs/arrays/MaybeArray.js.map +1 -0
  13. package/lib/{arrays → cjs/arrays}/index.d.ts +0 -0
  14. package/lib/cjs/arrays/index.js +5 -0
  15. package/lib/cjs/arrays/index.js.map +1 -0
  16. package/lib/{asyncs → cjs/asyncs}/AsyncInterval.d.ts +0 -0
  17. package/lib/{asyncs → cjs/asyncs}/AsyncInterval.js +2 -1
  18. package/lib/cjs/asyncs/AsyncInterval.js.map +1 -0
  19. package/lib/{asyncs → cjs/asyncs}/LazyPromise.d.ts +0 -0
  20. package/lib/cjs/asyncs/LazyPromise.js +26 -0
  21. package/lib/cjs/asyncs/LazyPromise.js.map +1 -0
  22. package/lib/cjs/asyncs/MaybePromise.d.ts +1 -0
  23. package/lib/cjs/asyncs/MaybePromise.js +3 -0
  24. package/lib/cjs/asyncs/MaybePromise.js.map +1 -0
  25. package/lib/cjs/asyncs/generatorOfStream.d.ts +1 -0
  26. package/lib/cjs/asyncs/generatorOfStream.js +18 -0
  27. package/lib/cjs/asyncs/generatorOfStream.js.map +1 -0
  28. package/lib/cjs/asyncs/index.d.ts +7 -0
  29. package/lib/cjs/asyncs/index.js +11 -0
  30. package/lib/cjs/asyncs/index.js.map +1 -0
  31. package/lib/cjs/asyncs/isPromise.d.ts +1 -0
  32. package/lib/cjs/asyncs/isPromise.js +8 -0
  33. package/lib/cjs/asyncs/isPromise.js.map +1 -0
  34. package/lib/cjs/asyncs/promiseOfCallback.d.ts +1 -0
  35. package/lib/cjs/asyncs/promiseOfCallback.js +22 -0
  36. package/lib/cjs/asyncs/promiseOfCallback.js.map +1 -0
  37. package/lib/{asyncs → cjs/asyncs}/sleep.d.ts +0 -0
  38. package/lib/cjs/asyncs/sleep.js +6 -0
  39. package/lib/cjs/asyncs/sleep.js.map +1 -0
  40. package/lib/cjs/asyncs/timeout.d.ts +4 -0
  41. package/lib/cjs/asyncs/timeout.js +27 -0
  42. package/lib/cjs/asyncs/timeout.js.map +1 -0
  43. package/lib/{browsers/clipboard.d.ts → cjs/browsers/copy.d.ts} +0 -0
  44. package/lib/{browsers/clipboard.js → cjs/browsers/copy.js} +3 -3
  45. package/lib/cjs/browsers/copy.js.map +1 -0
  46. package/lib/{browsers → cjs/browsers}/download.d.ts +0 -0
  47. package/lib/{browsers → cjs/browsers}/download.js +1 -0
  48. package/lib/cjs/browsers/download.js.map +1 -0
  49. package/lib/cjs/browsers/getFileFromDataTransfer.d.ts +4 -0
  50. package/lib/{browsers/transfers.js → cjs/browsers/getFileFromDataTransfer.js} +15 -11
  51. package/lib/cjs/browsers/getFileFromDataTransfer.js.map +1 -0
  52. package/lib/cjs/browsers/index.d.ts +4 -0
  53. package/lib/cjs/browsers/index.js +8 -0
  54. package/lib/cjs/browsers/index.js.map +1 -0
  55. package/lib/{browsers → cjs/browsers}/loaders.d.ts +0 -0
  56. package/lib/{browsers → cjs/browsers}/loaders.js +2 -1
  57. package/lib/cjs/browsers/loaders.js.map +1 -0
  58. package/lib/cjs/formats/formatBytes.d.ts +11 -0
  59. package/lib/cjs/formats/formatBytes.js +31 -0
  60. package/lib/cjs/formats/formatBytes.js.map +1 -0
  61. package/lib/cjs/index.d.ts +9 -0
  62. package/lib/cjs/index.js +15 -0
  63. package/lib/cjs/index.js.map +1 -0
  64. package/lib/{io → cjs/io}/index.d.ts +0 -0
  65. package/lib/cjs/io/index.js +5 -0
  66. package/lib/{io → cjs/io}/index.js.map +1 -1
  67. package/lib/{io → cjs/io}/isBuffer.d.ts +0 -0
  68. package/lib/{io → cjs/io}/isBuffer.js +1 -0
  69. package/lib/cjs/io/isBuffer.js.map +1 -0
  70. package/lib/{isomorphics → cjs/isomorphics}/getGlobalThis.d.ts +1 -1
  71. package/lib/{isomorphics → cjs/isomorphics}/getGlobalThis.js +5 -6
  72. package/lib/cjs/isomorphics/getGlobalThis.js.map +1 -0
  73. package/lib/{isomorphics → cjs/isomorphics}/index.d.ts +0 -0
  74. package/lib/cjs/isomorphics/index.js +5 -0
  75. package/lib/cjs/isomorphics/index.js.map +1 -0
  76. package/lib/{maths → cjs/maths}/index.d.ts +0 -0
  77. package/lib/cjs/maths/index.js +5 -0
  78. package/lib/{arrays → cjs/maths}/index.js.map +1 -1
  79. package/lib/cjs/maths/random.d.ts +3 -0
  80. package/lib/{maths → cjs/maths}/random.js +6 -5
  81. package/lib/cjs/maths/random.js.map +1 -0
  82. package/lib/{strings → cjs/strings}/camelCase.d.ts +0 -0
  83. package/lib/{strings → cjs/strings}/camelCase.js +2 -1
  84. package/lib/cjs/strings/camelCase.js.map +1 -0
  85. package/lib/{strings → cjs/strings}/index.d.ts +1 -0
  86. package/lib/cjs/strings/index.js +7 -0
  87. package/lib/cjs/strings/index.js.map +1 -0
  88. package/lib/{strings → cjs/strings}/templates.d.ts +1 -1
  89. package/lib/{strings → cjs/strings}/templates.js +3 -3
  90. package/lib/cjs/strings/templates.js.map +1 -0
  91. package/lib/cjs/strings/urljoin.d.ts +2 -0
  92. package/lib/cjs/strings/urljoin.js +69 -0
  93. package/lib/cjs/strings/urljoin.js.map +1 -0
  94. package/lib/cjs/strings/urljoin.test.d.ts +1 -0
  95. package/lib/cjs/strings/urljoin.test.js +7 -0
  96. package/lib/cjs/strings/urljoin.test.js.map +1 -0
  97. package/lib/{validations → cjs/validations}/asserts.d.ts +0 -0
  98. package/lib/{validations → cjs/validations}/asserts.js +1 -0
  99. package/lib/cjs/validations/asserts.js.map +1 -0
  100. package/lib/cjs/validations/index.d.ts +4 -0
  101. package/lib/cjs/validations/index.js +8 -0
  102. package/lib/cjs/validations/index.js.map +1 -0
  103. package/lib/cjs/validations/isClass.d.ts +1 -0
  104. package/lib/cjs/validations/isClass.js +8 -0
  105. package/lib/cjs/validations/isClass.js.map +1 -0
  106. package/lib/cjs/validations/isDefined.d.ts +1 -0
  107. package/lib/cjs/validations/isDefined.js +8 -0
  108. package/lib/cjs/validations/isDefined.js.map +1 -0
  109. package/lib/cjs/validations/isEmptyObject.d.ts +1 -0
  110. package/lib/cjs/validations/isEmptyObject.js +11 -0
  111. package/lib/cjs/validations/isEmptyObject.js.map +1 -0
  112. package/lib/esm/arrays/MaybeArray.d.ts +5 -0
  113. package/lib/esm/arrays/MaybeArray.js +33 -0
  114. package/lib/esm/arrays/index.d.ts +1 -0
  115. package/lib/esm/arrays/index.js +1 -0
  116. package/lib/esm/asyncs/AsyncInterval.d.ts +3 -0
  117. package/lib/esm/asyncs/AsyncInterval.js +16 -0
  118. package/lib/esm/asyncs/LazyPromise.d.ts +5 -0
  119. package/lib/esm/asyncs/LazyPromise.js +24 -0
  120. package/lib/esm/asyncs/MaybePromise.d.ts +1 -0
  121. package/lib/esm/asyncs/MaybePromise.js +0 -0
  122. package/lib/esm/asyncs/generatorOfStream.d.ts +1 -0
  123. package/lib/esm/asyncs/generatorOfStream.js +16 -0
  124. package/lib/esm/asyncs/index.d.ts +7 -0
  125. package/lib/esm/asyncs/index.js +7 -0
  126. package/lib/esm/asyncs/isPromise.d.ts +1 -0
  127. package/lib/esm/asyncs/isPromise.js +6 -0
  128. package/lib/esm/asyncs/promiseOfCallback.d.ts +1 -0
  129. package/lib/esm/asyncs/promiseOfCallback.js +18 -0
  130. package/lib/esm/asyncs/sleep.d.ts +1 -0
  131. package/lib/esm/asyncs/sleep.js +4 -0
  132. package/lib/esm/asyncs/timeout.d.ts +4 -0
  133. package/lib/esm/asyncs/timeout.js +25 -0
  134. package/lib/esm/browsers/copy.d.ts +1 -0
  135. package/lib/esm/browsers/copy.js +52 -0
  136. package/lib/esm/browsers/download.d.ts +4 -0
  137. package/lib/esm/browsers/download.js +28 -0
  138. package/lib/esm/browsers/getFileFromDataTransfer.d.ts +4 -0
  139. package/lib/esm/browsers/getFileFromDataTransfer.js +29 -0
  140. package/lib/esm/browsers/index.d.ts +4 -0
  141. package/lib/esm/browsers/index.js +4 -0
  142. package/lib/esm/browsers/loaders.d.ts +6 -0
  143. package/lib/esm/browsers/loaders.js +35 -0
  144. package/lib/esm/formats/formatBytes.d.ts +11 -0
  145. package/lib/esm/formats/formatBytes.js +17 -0
  146. package/lib/esm/index.d.ts +9 -0
  147. package/lib/esm/index.js +12 -0
  148. package/lib/esm/io/index.d.ts +1 -0
  149. package/lib/esm/io/index.js +1 -0
  150. package/lib/esm/io/isBuffer.d.ts +2 -0
  151. package/lib/esm/io/isBuffer.js +6 -0
  152. package/lib/esm/isomorphics/getGlobalThis.d.ts +9 -0
  153. package/lib/esm/isomorphics/getGlobalThis.js +14 -0
  154. package/lib/esm/isomorphics/index.d.ts +1 -0
  155. package/lib/esm/isomorphics/index.js +1 -0
  156. package/lib/esm/maths/index.d.ts +1 -0
  157. package/lib/esm/maths/index.js +1 -0
  158. package/lib/esm/maths/random.d.ts +3 -0
  159. package/lib/esm/maths/random.js +17 -0
  160. package/lib/esm/strings/camelCase.d.ts +4 -0
  161. package/lib/esm/strings/camelCase.js +57 -0
  162. package/lib/esm/strings/index.d.ts +3 -0
  163. package/lib/esm/strings/index.js +3 -0
  164. package/lib/esm/strings/templates.d.ts +7 -0
  165. package/lib/esm/strings/templates.js +8 -0
  166. package/lib/esm/strings/urljoin.d.ts +2 -0
  167. package/lib/esm/strings/urljoin.js +53 -0
  168. package/lib/esm/strings/urljoin.test.d.ts +1 -0
  169. package/lib/esm/strings/urljoin.test.js +4 -0
  170. package/lib/esm/validations/asserts.d.ts +2 -0
  171. package/lib/esm/validations/asserts.js +10 -0
  172. package/lib/esm/validations/index.d.ts +4 -0
  173. package/lib/esm/validations/index.js +4 -0
  174. package/lib/esm/validations/isClass.d.ts +1 -0
  175. package/lib/esm/validations/isClass.js +6 -0
  176. package/lib/esm/validations/isDefined.d.ts +1 -0
  177. package/lib/esm/validations/isDefined.js +6 -0
  178. package/lib/esm/validations/isEmptyObject.d.ts +1 -0
  179. package/lib/esm/validations/isEmptyObject.js +9 -0
  180. package/lib/esnext/arrays/MaybeArray.d.ts +5 -0
  181. package/lib/esnext/arrays/MaybeArray.js +28 -0
  182. package/lib/esnext/arrays/MaybeArray.js.map +1 -0
  183. package/lib/esnext/arrays/index.d.ts +1 -0
  184. package/lib/esnext/arrays/index.js +2 -0
  185. package/lib/esnext/arrays/index.js.map +1 -0
  186. package/lib/esnext/asyncs/AsyncInterval.d.ts +3 -0
  187. package/lib/esnext/asyncs/AsyncInterval.js +13 -0
  188. package/lib/esnext/asyncs/AsyncInterval.js.map +1 -0
  189. package/lib/esnext/asyncs/LazyPromise.d.ts +5 -0
  190. package/lib/esnext/asyncs/LazyPromise.js +22 -0
  191. package/lib/esnext/asyncs/LazyPromise.js.map +1 -0
  192. package/lib/esnext/asyncs/MaybePromise.d.ts +1 -0
  193. package/lib/esnext/asyncs/MaybePromise.js +2 -0
  194. package/lib/esnext/asyncs/MaybePromise.js.map +1 -0
  195. package/lib/esnext/asyncs/generatorOfStream.d.ts +1 -0
  196. package/lib/esnext/asyncs/generatorOfStream.js +14 -0
  197. package/lib/esnext/asyncs/generatorOfStream.js.map +1 -0
  198. package/lib/esnext/asyncs/index.d.ts +7 -0
  199. package/lib/esnext/asyncs/index.js +8 -0
  200. package/lib/esnext/asyncs/index.js.map +1 -0
  201. package/lib/esnext/asyncs/isPromise.d.ts +1 -0
  202. package/lib/esnext/asyncs/isPromise.js +4 -0
  203. package/lib/esnext/asyncs/isPromise.js.map +1 -0
  204. package/lib/esnext/asyncs/promiseOfCallback.d.ts +1 -0
  205. package/lib/esnext/asyncs/promiseOfCallback.js +18 -0
  206. package/lib/esnext/asyncs/promiseOfCallback.js.map +1 -0
  207. package/lib/esnext/asyncs/sleep.d.ts +1 -0
  208. package/lib/esnext/asyncs/sleep.js +2 -0
  209. package/lib/esnext/asyncs/sleep.js.map +1 -0
  210. package/lib/esnext/asyncs/timeout.d.ts +4 -0
  211. package/lib/esnext/asyncs/timeout.js +22 -0
  212. package/lib/esnext/asyncs/timeout.js.map +1 -0
  213. package/lib/esnext/browsers/copy.d.ts +1 -0
  214. package/lib/esnext/browsers/copy.js +51 -0
  215. package/lib/esnext/browsers/copy.js.map +1 -0
  216. package/lib/esnext/browsers/download.d.ts +4 -0
  217. package/lib/esnext/browsers/download.js +31 -0
  218. package/lib/esnext/browsers/download.js.map +1 -0
  219. package/lib/esnext/browsers/getFileFromDataTransfer.d.ts +4 -0
  220. package/lib/esnext/browsers/getFileFromDataTransfer.js +37 -0
  221. package/lib/esnext/browsers/getFileFromDataTransfer.js.map +1 -0
  222. package/lib/esnext/browsers/index.d.ts +4 -0
  223. package/lib/esnext/browsers/index.js +5 -0
  224. package/lib/esnext/browsers/index.js.map +1 -0
  225. package/lib/esnext/browsers/loaders.d.ts +6 -0
  226. package/lib/esnext/browsers/loaders.js +33 -0
  227. package/lib/esnext/browsers/loaders.js.map +1 -0
  228. package/lib/esnext/formats/formatBytes.d.ts +11 -0
  229. package/lib/esnext/formats/formatBytes.js +27 -0
  230. package/lib/esnext/formats/formatBytes.js.map +1 -0
  231. package/lib/esnext/index.d.ts +9 -0
  232. package/lib/esnext/index.js +10 -0
  233. package/lib/esnext/index.js.map +1 -0
  234. package/lib/esnext/io/index.d.ts +1 -0
  235. package/lib/esnext/io/index.js +2 -0
  236. package/lib/esnext/io/index.js.map +1 -0
  237. package/lib/esnext/io/isBuffer.d.ts +2 -0
  238. package/lib/esnext/io/isBuffer.js +8 -0
  239. package/lib/esnext/io/isBuffer.js.map +1 -0
  240. package/lib/esnext/isomorphics/getGlobalThis.d.ts +9 -0
  241. package/lib/esnext/isomorphics/getGlobalThis.js +21 -0
  242. package/lib/esnext/isomorphics/getGlobalThis.js.map +1 -0
  243. package/lib/esnext/isomorphics/index.d.ts +1 -0
  244. package/lib/esnext/isomorphics/index.js +2 -0
  245. package/lib/esnext/isomorphics/index.js.map +1 -0
  246. package/lib/esnext/maths/index.d.ts +1 -0
  247. package/lib/esnext/maths/index.js +2 -0
  248. package/lib/esnext/maths/index.js.map +1 -0
  249. package/lib/esnext/maths/random.d.ts +3 -0
  250. package/lib/esnext/maths/random.js +16 -0
  251. package/lib/esnext/maths/random.js.map +1 -0
  252. package/lib/esnext/strings/camelCase.d.ts +4 -0
  253. package/lib/esnext/strings/camelCase.js +68 -0
  254. package/lib/esnext/strings/camelCase.js.map +1 -0
  255. package/lib/esnext/strings/index.d.ts +3 -0
  256. package/lib/esnext/strings/index.js +4 -0
  257. package/lib/esnext/strings/index.js.map +1 -0
  258. package/lib/esnext/strings/templates.d.ts +7 -0
  259. package/lib/esnext/strings/templates.js +14 -0
  260. package/lib/esnext/strings/templates.js.map +1 -0
  261. package/lib/esnext/strings/urljoin.d.ts +2 -0
  262. package/lib/esnext/strings/urljoin.js +65 -0
  263. package/lib/esnext/strings/urljoin.js.map +1 -0
  264. package/lib/esnext/strings/urljoin.test.d.ts +1 -0
  265. package/lib/esnext/strings/urljoin.test.js +5 -0
  266. package/lib/esnext/strings/urljoin.test.js.map +1 -0
  267. package/lib/esnext/validations/asserts.d.ts +2 -0
  268. package/lib/esnext/validations/asserts.js +13 -0
  269. package/lib/esnext/validations/asserts.js.map +1 -0
  270. package/lib/esnext/validations/index.d.ts +4 -0
  271. package/lib/esnext/validations/index.js +5 -0
  272. package/lib/esnext/validations/index.js.map +1 -0
  273. package/lib/esnext/validations/isClass.d.ts +1 -0
  274. package/lib/esnext/validations/isClass.js +4 -0
  275. package/lib/esnext/validations/isClass.js.map +1 -0
  276. package/lib/esnext/validations/isDefined.d.ts +1 -0
  277. package/lib/esnext/validations/isDefined.js +4 -0
  278. package/lib/esnext/validations/isDefined.js.map +1 -0
  279. package/lib/esnext/validations/isEmptyObject.d.ts +1 -0
  280. package/lib/esnext/validations/isEmptyObject.js +7 -0
  281. package/lib/esnext/validations/isEmptyObject.js.map +1 -0
  282. package/package.json +36 -32
  283. package/src/arrays/MaybeArray.ts +13 -0
  284. package/src/asyncs/LazyPromise.ts +16 -9
  285. package/src/asyncs/MaybePromise.ts +1 -0
  286. package/src/asyncs/generatorOfStream.ts +13 -0
  287. package/src/asyncs/index.ts +8 -3
  288. package/src/asyncs/isPromise.ts +3 -0
  289. package/src/asyncs/promiseOfCallback.ts +15 -0
  290. package/src/asyncs/timeout.ts +25 -0
  291. package/src/browsers/{clipboard.ts → copy.ts} +0 -0
  292. package/src/browsers/{transfers.ts → getFileFromDataTransfer.ts} +13 -8
  293. package/src/browsers/index.ts +4 -4
  294. package/src/browsers/loaders.ts +7 -2
  295. package/src/formats/formatBytes.ts +30 -0
  296. package/src/index.ts +5 -3
  297. package/src/isomorphics/getGlobalThis.ts +2 -4
  298. package/src/maths/random.ts +5 -5
  299. package/src/strings/camelCase.ts +2 -2
  300. package/src/strings/index.ts +1 -0
  301. package/src/strings/templates.ts +2 -4
  302. package/src/strings/urljoin.test.ts +5 -0
  303. package/src/strings/urljoin.ts +79 -0
  304. package/src/validations/index.ts +3 -0
  305. package/src/validations/isClass.ts +3 -0
  306. package/src/validations/isDefined.ts +3 -0
  307. package/src/validations/isEmptyObject.ts +6 -0
  308. package/tsconfig.json +26 -6
  309. package/dist/utils.es5.js +0 -1759
  310. package/dist/utils.es5.js.map +0 -1
  311. package/dist/utils.umd.js +0 -1769
  312. package/dist/utils.umd.js.map +0 -1
  313. package/lib/arrays/MaybeArray.js.map +0 -1
  314. package/lib/arrays/index.js +0 -7
  315. package/lib/asyncs/AsyncInterval.js.map +0 -1
  316. package/lib/asyncs/LazyPromise.js +0 -18
  317. package/lib/asyncs/LazyPromise.js.map +0 -1
  318. package/lib/asyncs/index.d.ts +0 -3
  319. package/lib/asyncs/index.js +0 -9
  320. package/lib/asyncs/index.js.map +0 -1
  321. package/lib/asyncs/sleep.js +0 -4
  322. package/lib/asyncs/sleep.js.map +0 -1
  323. package/lib/browsers/clipboard.js.map +0 -1
  324. package/lib/browsers/download.js.map +0 -1
  325. package/lib/browsers/index.d.ts +0 -4
  326. package/lib/browsers/index.js +0 -10
  327. package/lib/browsers/index.js.map +0 -1
  328. package/lib/browsers/loaders.js.map +0 -1
  329. package/lib/browsers/transfers.d.ts +0 -4
  330. package/lib/browsers/transfers.js.map +0 -1
  331. package/lib/envs/index.d.ts +0 -1
  332. package/lib/envs/index.js +0 -7
  333. package/lib/envs/index.js.map +0 -1
  334. package/lib/envs/isDev.d.ts +0 -1
  335. package/lib/envs/isDev.js +0 -4
  336. package/lib/envs/isDev.js.map +0 -1
  337. package/lib/index.d.ts +0 -8
  338. package/lib/index.js +0 -14
  339. package/lib/index.js.map +0 -1
  340. package/lib/io/index.js +0 -7
  341. package/lib/io/isBuffer.js.map +0 -1
  342. package/lib/isomorphics/getGlobalThis.js.map +0 -1
  343. package/lib/isomorphics/index.js +0 -7
  344. package/lib/isomorphics/index.js.map +0 -1
  345. package/lib/maths/index.js +0 -7
  346. package/lib/maths/index.js.map +0 -1
  347. package/lib/maths/random.d.ts +0 -3
  348. package/lib/maths/random.js.map +0 -1
  349. package/lib/strings/camelCase.js.map +0 -1
  350. package/lib/strings/index.js +0 -8
  351. package/lib/strings/index.js.map +0 -1
  352. package/lib/strings/templates.js.map +0 -1
  353. package/lib/validations/asserts.js.map +0 -1
  354. package/lib/validations/index.d.ts +0 -1
  355. package/lib/validations/index.js +0 -7
  356. package/lib/validations/index.js.map +0 -1
  357. package/rollup.config.ts +0 -34
  358. package/src/envs/index.ts +0 -1
  359. package/src/envs/isDev.ts +0 -1
  360. package/tsconfig.rollup.json +0 -9
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.urljoin = void 0;
4
+ /**
5
+ * @see {@link https://github.com/jfromaniello/url-join}
6
+ */
7
+ function urljoin(...args) {
8
+ let input;
9
+ if (typeof args[0] === 'object') {
10
+ input = args[0];
11
+ }
12
+ else {
13
+ input = args;
14
+ }
15
+ return normalize(input);
16
+ }
17
+ exports.urljoin = urljoin;
18
+ function normalize(strArray) {
19
+ const resultArray = [];
20
+ if (strArray.length === 0) {
21
+ return '';
22
+ }
23
+ if (typeof strArray[0] !== 'string') {
24
+ throw new TypeError('Url must be a string. Received ' + strArray[0]);
25
+ }
26
+ // If the first part is a plain protocol, we combine it with the next part.
27
+ if (strArray[0].match(/^[^/:]+:\/*$/) && strArray.length > 1) {
28
+ const first = strArray.shift();
29
+ strArray[0] = first + strArray[0];
30
+ }
31
+ // There must be two or three slashes in the file protocol, two slashes in anything else.
32
+ if (strArray[0].match(/^file:\/\/\//)) {
33
+ strArray[0] = strArray[0].replace(/^([^/:]+):\/*/, '$1:///');
34
+ }
35
+ else {
36
+ strArray[0] = strArray[0].replace(/^([^/:]+):\/*/, '$1://');
37
+ }
38
+ for (let i = 0; i < strArray.length; i++) {
39
+ let component = strArray[i];
40
+ if (typeof component !== 'string') {
41
+ throw new TypeError('Url must be a string. Received ' + component);
42
+ }
43
+ if (component === '') {
44
+ continue;
45
+ }
46
+ if (i > 0) {
47
+ // Removing the starting slashes for each component but the first.
48
+ component = component.replace(/^[\/]+/, '');
49
+ }
50
+ if (i < strArray.length - 1) {
51
+ // Removing the ending slashes for each component but the last.
52
+ component = component.replace(/[\/]+$/, '');
53
+ }
54
+ else {
55
+ // For the last component we will combine multiple slashes to a single one.
56
+ component = component.replace(/[\/]+$/, '/');
57
+ }
58
+ resultArray.push(component);
59
+ }
60
+ let str = resultArray.join('/');
61
+ // Each input component is now separated by a single slash except the possible first plain protocol part.
62
+ // remove trailing slash before parameters or hash
63
+ str = str.replace(/\/(\?|&|#[^!])/g, '$1');
64
+ // replace ? in parameters with &
65
+ const parts = str.split('?');
66
+ str = parts.shift() + (parts.length > 0 ? '?' : '') + parts.join('&');
67
+ return str;
68
+ }
69
+ //# sourceMappingURL=urljoin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"urljoin.js","sourceRoot":"","sources":["../../../src/strings/urljoin.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const urljoin_1 = require("./urljoin");
4
+ test('join ext', () => {
5
+ expect((0, urljoin_1.urljoin)('http://wener.me/sub/', '/a/', '/hello.js')).toBe('http://wener.me/sub/a/hello.js');
6
+ });
7
+ //# sourceMappingURL=urljoin.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"urljoin.test.js","sourceRoot":"","sources":["../../../src/strings/urljoin.test.ts"],"names":[],"mappings":";;AAAA,uCAAoC;AAEpC,IAAI,CAAC,UAAU,EAAE,GAAG,EAAE;IACpB,MAAM,CAAC,IAAA,iBAAO,EAAC,sBAAsB,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,gCAAgC,CAAC,CAAC;AACrG,CAAC,CAAC,CAAC"}
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.assertIsDefined = exports.assert = void 0;
3
4
  function assert(condition, msg) {
4
5
  // if (!condition) {
5
6
  // throw new AssertionError(msg);
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asserts.js","sourceRoot":"","sources":["../../../src/validations/asserts.ts"],"names":[],"mappings":";;;AAAA,SAAgB,MAAM,CAAC,SAAc,EAAE,GAAY;IACjD,oBAAoB;IACpB,mCAAmC;IACnC,IAAI;IACJ,OAAO,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;AAClC,CAAC;AALD,wBAKC;AAED,SAAgB,eAAe,CAAI,GAAM;IACvC,2CAA2C;IAC3C,mFAAmF;IACnF,IAAI;IACJ,OAAO,CAAC,MAAM,CAAC,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,IAAI,EAAE,kBAAkB,CAAC,CAAC;AACxE,CAAC;AALD,0CAKC"}
@@ -0,0 +1,4 @@
1
+ export * from './asserts';
2
+ export * from './isDefined';
3
+ export * from './isEmptyObject';
4
+ export * from './isClass';
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./asserts"), exports);
5
+ tslib_1.__exportStar(require("./isDefined"), exports);
6
+ tslib_1.__exportStar(require("./isEmptyObject"), exports);
7
+ tslib_1.__exportStar(require("./isClass"), exports);
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/validations/index.ts"],"names":[],"mappings":";;;AAAA,oDAA0B;AAC1B,sDAA4B;AAC5B,0DAAgC;AAChC,oDAA0B"}
@@ -0,0 +1 @@
1
+ export declare function isClass(func: any): boolean;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isClass = void 0;
4
+ function isClass(func) {
5
+ return typeof func === 'function' && /^class\s/.test(Function.prototype.toString.call(func));
6
+ }
7
+ exports.isClass = isClass;
8
+ //# sourceMappingURL=isClass.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isClass.js","sourceRoot":"","sources":["../../../src/validations/isClass.ts"],"names":[],"mappings":";;;AAAA,SAAgB,OAAO,CAAC,IAAS;IAC/B,OAAO,OAAO,IAAI,KAAK,UAAU,IAAI,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AAC/F,CAAC;AAFD,0BAEC"}
@@ -0,0 +1 @@
1
+ export declare function isDefined<T = any>(v: T): v is NonNullable<T>;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isDefined = void 0;
4
+ function isDefined(v) {
5
+ return v !== null && v !== undefined;
6
+ }
7
+ exports.isDefined = isDefined;
8
+ //# sourceMappingURL=isDefined.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isDefined.js","sourceRoot":"","sources":["../../../src/validations/isDefined.ts"],"names":[],"mappings":";;;AAAA,SAAgB,SAAS,CAAU,CAAI;IACrC,OAAO,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,SAAS,CAAC;AACvC,CAAC;AAFD,8BAEC"}
@@ -0,0 +1 @@
1
+ export declare function isEmptyObject(o: any): boolean;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isEmptyObject = void 0;
4
+ function isEmptyObject(o) {
5
+ if (o === null || o === undefined) {
6
+ return true;
7
+ }
8
+ return o.constructor === Object && Object.keys(o).length === 0;
9
+ }
10
+ exports.isEmptyObject = isEmptyObject;
11
+ //# sourceMappingURL=isEmptyObject.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isEmptyObject.js","sourceRoot":"","sources":["../../../src/validations/isEmptyObject.ts"],"names":[],"mappings":";;;AAAA,SAAgB,aAAa,CAAC,CAAM;IAClC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,SAAS,EAAE;QACjC,OAAO,IAAI,CAAC;KACb;IACD,OAAO,CAAC,CAAC,WAAW,KAAK,MAAM,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC;AACjE,CAAC;AALD,sCAKC"}
@@ -0,0 +1,5 @@
1
+ export declare type MaybeArray<T> = T | T[];
2
+ export declare function objectOfMaybeArray<T = any>(o: Record<string, MaybeArray<T>>, keys?: string[] | null, picker?: typeof firstOfMaybeArray): Record<string, T>;
3
+ export declare function firstOfMaybeArray<T>(v: MaybeArray<T>): T;
4
+ export declare function lastOfMaybeArray<T>(v: MaybeArray<T>): T;
5
+ export declare function arrayOfMaybeArray<T>(v: MaybeArray<T>): T[];
@@ -0,0 +1,33 @@
1
+ function objectOfMaybeArray(o, keys = null, picker = firstOfMaybeArray) {
2
+ if (keys === null) {
3
+ return Object.fromEntries(Object.entries(o).map(([k, v]) => [k, picker(v)]));
4
+ }
5
+ return Object.fromEntries(keys.map((v) => [v, picker(v)]));
6
+ }
7
+ function firstOfMaybeArray(v) {
8
+ if (Array.isArray(v)) {
9
+ return v[0];
10
+ }
11
+ return v;
12
+ }
13
+ function lastOfMaybeArray(v) {
14
+ if (Array.isArray(v)) {
15
+ return v[v.length - 1];
16
+ }
17
+ return v;
18
+ }
19
+ function arrayOfMaybeArray(v) {
20
+ if (Array.isArray(v)) {
21
+ return v;
22
+ }
23
+ if (v === null || v === void 0) {
24
+ return [];
25
+ }
26
+ return [v];
27
+ }
28
+ export {
29
+ arrayOfMaybeArray,
30
+ firstOfMaybeArray,
31
+ lastOfMaybeArray,
32
+ objectOfMaybeArray
33
+ };
@@ -0,0 +1 @@
1
+ export * from './MaybeArray';
@@ -0,0 +1 @@
1
+ export * from "./MaybeArray";
@@ -0,0 +1,3 @@
1
+ export declare type AsyncIntervalIdentifier = any;
2
+ export declare function setAsyncInterval(cb: () => void, interval: number, initial?: number): AsyncIntervalIdentifier;
3
+ export declare function clearAsyncInterval(v: AsyncIntervalIdentifier): void;
@@ -0,0 +1,16 @@
1
+ function setAsyncInterval(cb, interval, initial = interval) {
2
+ let id;
3
+ const handler = async () => {
4
+ await cb();
5
+ id = setTimeout(handler, interval);
6
+ };
7
+ id = setTimeout(handler, initial);
8
+ return () => id;
9
+ }
10
+ function clearAsyncInterval(v) {
11
+ clearTimeout(v == null ? void 0 : v());
12
+ }
13
+ export {
14
+ clearAsyncInterval,
15
+ setAsyncInterval
16
+ };
@@ -0,0 +1,5 @@
1
+ export declare type LazyPromise<T> = Promise<T> & {
2
+ reject(e: any): void;
3
+ resolve(v?: T | PromiseLike<T>): void;
4
+ };
5
+ export declare function createLazyPromise<T = any>(): LazyPromise<T>;
@@ -0,0 +1,24 @@
1
+ function createLazyPromise() {
2
+ const holder = {
3
+ resolve(_) {
4
+ throw new Error("pending resolve");
5
+ },
6
+ reject(_) {
7
+ throw new Error("pending reject");
8
+ }
9
+ };
10
+ return Object.assign(new Promise((resolve, reject) => {
11
+ holder.reject = reject;
12
+ holder.resolve = resolve;
13
+ }), {
14
+ resolve(v) {
15
+ holder.resolve(v);
16
+ },
17
+ reject(v) {
18
+ holder.resolve(v);
19
+ }
20
+ });
21
+ }
22
+ export {
23
+ createLazyPromise
24
+ };
@@ -0,0 +1 @@
1
+ export declare type MaybePromise<T> = Promise<T> | T;
File without changes
@@ -0,0 +1 @@
1
+ export declare function generatorOfStream<T = any>(stream: any): IterableIterator<Promise<T>>;
@@ -0,0 +1,16 @@
1
+ function* generatorOfStream(stream) {
2
+ let done = false;
3
+ stream.on("end", () => {
4
+ done = true;
5
+ });
6
+ while (!done) {
7
+ yield new Promise((resolve, reject) => {
8
+ stream.once("data", resolve);
9
+ stream.once("end", resolve);
10
+ stream.once("error", reject);
11
+ });
12
+ }
13
+ }
14
+ export {
15
+ generatorOfStream
16
+ };
@@ -0,0 +1,7 @@
1
+ export * from './LazyPromise';
2
+ export * from './AsyncInterval';
3
+ export * from './MaybePromise';
4
+ export * from './sleep';
5
+ export * from './timeout';
6
+ export * from './isPromise';
7
+ export * from './promiseOfCallback';
@@ -0,0 +1,7 @@
1
+ export * from "./LazyPromise";
2
+ export * from "./AsyncInterval";
3
+ export * from "./MaybePromise";
4
+ export * from "./sleep";
5
+ export * from "./timeout";
6
+ export * from "./isPromise";
7
+ export * from "./promiseOfCallback";
@@ -0,0 +1 @@
1
+ export declare function isPromise<T>(v: any): v is Promise<T>;
@@ -0,0 +1,6 @@
1
+ function isPromise(v) {
2
+ return v && (v instanceof Promise || v.then && v.catch);
3
+ }
4
+ export {
5
+ isPromise
6
+ };
@@ -0,0 +1 @@
1
+ export declare function promiseOfCallback<T>(fun: (cb: (err: any, val?: T) => void) => void): Promise<T>;
@@ -0,0 +1,18 @@
1
+ function promiseOfCallback(fun) {
2
+ return new Promise((resolve, reject) => {
3
+ try {
4
+ fun((e, v) => {
5
+ if (e) {
6
+ reject(e);
7
+ } else {
8
+ resolve(v);
9
+ }
10
+ });
11
+ } catch (e) {
12
+ reject(e);
13
+ }
14
+ });
15
+ }
16
+ export {
17
+ promiseOfCallback
18
+ };
@@ -0,0 +1 @@
1
+ export declare const sleep: (ms: number) => Promise<unknown>;
@@ -0,0 +1,4 @@
1
+ const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
2
+ export {
3
+ sleep
4
+ };
@@ -0,0 +1,4 @@
1
+ export declare function timeout<T = any>(v: Promise<T>, ms: number): Promise<T>;
2
+ export declare class TimeoutError extends Error {
3
+ constructor();
4
+ }
@@ -0,0 +1,25 @@
1
+ function timeout(v, ms) {
2
+ const error = new TimeoutError();
3
+ let timeout2;
4
+ return Promise.race([
5
+ v,
6
+ new Promise((_, reject) => {
7
+ timeout2 = setTimeout(() => reject(error), ms);
8
+ })
9
+ ]).then((v2) => {
10
+ clearTimeout(timeout2);
11
+ return v2;
12
+ }, (e) => {
13
+ clearTimeout(timeout2);
14
+ throw e;
15
+ });
16
+ }
17
+ class TimeoutError extends Error {
18
+ constructor() {
19
+ super("TimeoutError");
20
+ }
21
+ }
22
+ export {
23
+ TimeoutError,
24
+ timeout
25
+ };
@@ -0,0 +1 @@
1
+ export declare function copy(text: string): void;
@@ -0,0 +1,52 @@
1
+ let _copy;
2
+ function initCopy() {
3
+ let textArea;
4
+ function isIOS() {
5
+ return navigator.userAgent.match(/ipad|iphone/i);
6
+ }
7
+ function createTextArea(text) {
8
+ textArea = document.createElement("textArea");
9
+ textArea.value = text;
10
+ document.body.appendChild(textArea);
11
+ }
12
+ function selectText() {
13
+ let range, selection;
14
+ if (isIOS()) {
15
+ range = document.createRange();
16
+ range.selectNodeContents(textArea);
17
+ selection = window.getSelection();
18
+ if (selection === null) {
19
+ console.error(`no selection`);
20
+ return;
21
+ }
22
+ selection.removeAllRanges();
23
+ selection.addRange(range);
24
+ textArea.setSelectionRange(0, 999999);
25
+ } else {
26
+ textArea.select();
27
+ }
28
+ }
29
+ function copyToClipboard() {
30
+ document.execCommand("copy");
31
+ document.body.removeChild(textArea);
32
+ }
33
+ _copy = (text) => {
34
+ createTextArea(text);
35
+ selectText();
36
+ copyToClipboard();
37
+ };
38
+ }
39
+ function copy(text) {
40
+ var _a, _b;
41
+ if ((_b = (_a = window.navigator) == null ? void 0 : _a.clipboard) == null ? void 0 : _b.writeText) {
42
+ window.navigator.clipboard.writeText(text);
43
+ return;
44
+ }
45
+ if (!_copy) {
46
+ initCopy();
47
+ }
48
+ _copy(text);
49
+ }
50
+ export {
51
+ copy
52
+ };
@@ -0,0 +1,4 @@
1
+ export declare function download(filename: string, data: any, { type, raw }?: {
2
+ type?: string | undefined;
3
+ raw?: boolean | undefined;
4
+ }): void;
@@ -0,0 +1,28 @@
1
+ function download(filename, data, { type = "application/octet-stream", raw = false } = {}) {
2
+ const a = document.createElement("a");
3
+ let closer = () => null;
4
+ try {
5
+ a.download = filename;
6
+ if (typeof data === "string" && /^(https?:|data:)/.test(data) && !raw) {
7
+ a.href = data;
8
+ } else if (typeof data === "string") {
9
+ data = new TextEncoder().encode(data);
10
+ }
11
+ if (data instanceof Uint8Array) {
12
+ data = new Blob([data], { type });
13
+ }
14
+ if (data instanceof File || data instanceof Blob || data instanceof MediaSource) {
15
+ a.href = URL.createObjectURL(data);
16
+ closer = () => URL.revokeObjectURL(a.href);
17
+ } else {
18
+ console.error(`invalid download data`, data);
19
+ throw new Error(`can not download ${Object.getPrototypeOf(data)}`);
20
+ }
21
+ a.click();
22
+ } finally {
23
+ closer();
24
+ }
25
+ }
26
+ export {
27
+ download
28
+ };
@@ -0,0 +1,4 @@
1
+ export declare function getFileFromDataTransfer(dataTransfer?: DataTransfer | null): {
2
+ file?: File;
3
+ name?: string;
4
+ };
@@ -0,0 +1,29 @@
1
+ function getFileFromDataTransfer(dataTransfer) {
2
+ var _a;
3
+ if (!dataTransfer) {
4
+ return {};
5
+ }
6
+ const items = dataTransfer.items ?? [];
7
+ if (items.length >= 2 && items[0].kind === "string" && items[1].kind === "file") {
8
+ const text = dataTransfer.getData("text");
9
+ const file = items[1].getAsFile() ?? ((_a = dataTransfer.files) == null ? void 0 : _a.item(0));
10
+ if (!file) {
11
+ console.error(`no file ${text}`, items[1]);
12
+ return {};
13
+ }
14
+ return { file, name: text };
15
+ } else if (items[0].kind === "file") {
16
+ const file = items[0].getAsFile();
17
+ if (!file) {
18
+ console.error(`no file`, items[0]);
19
+ return {};
20
+ }
21
+ return { file, name: file.name };
22
+ } else {
23
+ console.debug(`file item not match`, Array.from(items).map((v) => ({ type: v.type, kind: v.kind })));
24
+ }
25
+ return {};
26
+ }
27
+ export {
28
+ getFileFromDataTransfer
29
+ };
@@ -0,0 +1,4 @@
1
+ export * from './copy';
2
+ export * from './download';
3
+ export * from './loaders';
4
+ export * from './getFileFromDataTransfer';
@@ -0,0 +1,4 @@
1
+ export * from "./copy";
2
+ export * from "./download";
3
+ export * from "./loaders";
4
+ export * from "./getFileFromDataTransfer";
@@ -0,0 +1,6 @@
1
+ export declare function loadScripts(src: string, options?: {
2
+ attributes: Record<string, string>;
3
+ }): Promise<unknown>;
4
+ export declare function loadStyles(href: string, options?: {
5
+ attributes: Record<string, string>;
6
+ }): Promise<unknown>;
@@ -0,0 +1,35 @@
1
+ function load(el, resolve, reject, options) {
2
+ el.onload = resolve;
3
+ el.onerror = (e) => {
4
+ el.remove();
5
+ reject(e);
6
+ };
7
+ const { attributes = {} } = options || {};
8
+ Object.entries(attributes).forEach(([k, v]) => el.setAttribute(k, v));
9
+ document.head.appendChild(el);
10
+ }
11
+ function loadScripts(src, options) {
12
+ if (document.querySelector(`script[src="${src}"]`)) {
13
+ return Promise.resolve();
14
+ }
15
+ return new Promise((resolve, reject) => {
16
+ const el = document.createElement("script");
17
+ el.src = src;
18
+ load(el, resolve, reject, options);
19
+ });
20
+ }
21
+ function loadStyles(href, options) {
22
+ if (document.querySelector(`link[href="${href}"]`)) {
23
+ return Promise.resolve();
24
+ }
25
+ return new Promise((resolve, reject) => {
26
+ const el = document.createElement("link");
27
+ el.rel = "stylesheet";
28
+ el.href = href;
29
+ load(el, resolve, reject, options);
30
+ });
31
+ }
32
+ export {
33
+ loadScripts,
34
+ loadStyles
35
+ };
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Format bytes as human-readable text.
3
+ *
4
+ * @param bytes Number of bytes.
5
+ * @param si True to use metric (SI) units, aka powers of 1000. False to use
6
+ * binary (IEC), aka powers of 1024.
7
+ * @param dp Number of decimal places to display.
8
+ *
9
+ * @return Formatted string.
10
+ */
11
+ export declare function formatBytes(bytes: number, si?: boolean, dp?: number): string;
@@ -0,0 +1,17 @@
1
+ function formatBytes(bytes, si = false, dp = 1) {
2
+ const thresh = si ? 1e3 : 1024;
3
+ if (Math.abs(bytes) < thresh) {
4
+ return bytes + " B";
5
+ }
6
+ const units = si ? ["kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"] : ["KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"];
7
+ let u = -1;
8
+ const r = 10 ** dp;
9
+ do {
10
+ bytes /= thresh;
11
+ ++u;
12
+ } while (Math.round(Math.abs(bytes) * r) / r >= thresh && u < units.length - 1);
13
+ return bytes.toFixed(dp) + " " + units[u];
14
+ }
15
+ export {
16
+ formatBytes
17
+ };
@@ -0,0 +1,9 @@
1
+ export * from './arrays/index';
2
+ export * from './asyncs';
3
+ export * from './validations';
4
+ export * from './strings';
5
+ export * from './maths';
6
+ export * from './io';
7
+ export * from './browsers';
8
+ export * from './isomorphics';
9
+ export { formatBytes } from './formats/formatBytes';
@@ -0,0 +1,12 @@
1
+ export * from "./arrays/index";
2
+ export * from "./asyncs";
3
+ export * from "./validations";
4
+ export * from "./strings";
5
+ export * from "./maths";
6
+ export * from "./io";
7
+ export * from "./browsers";
8
+ export * from "./isomorphics";
9
+ import { formatBytes } from "./formats/formatBytes";
10
+ export {
11
+ formatBytes
12
+ };
@@ -0,0 +1 @@
1
+ export * from './isBuffer';