@bitfiber/utils 1.0.1 → 1.0.3

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 (509) hide show
  1. package/LICENSE.txt +1 -1
  2. package/README.md +1 -1
  3. package/dist/arr/at/at.js.map +1 -0
  4. package/{arr → dist/arr}/cnd/cnd.d.ts +63 -1
  5. package/{arr → dist/arr}/cnd/cnd.js +1 -1
  6. package/dist/arr/cnd/cnd.js.map +1 -0
  7. package/dist/arr/diff-arr/diff-arr.d.ts +30 -0
  8. package/dist/arr/diff-arr/diff-arr.js.map +1 -0
  9. package/dist/arr/fill/fill.js.map +1 -0
  10. package/{arr → dist/arr}/for-each-arr/for-each-arr.d.ts +1 -1
  11. package/{arr → dist/arr}/for-each-arr/for-each-arr.js +1 -1
  12. package/dist/arr/for-each-arr/for-each-arr.js.map +1 -0
  13. package/{arr → dist/arr}/index-by/index-by.d.ts +1 -1
  14. package/{arr → dist/arr}/index-by/index-by.js +1 -1
  15. package/dist/arr/index-by/index-by.js.map +1 -0
  16. package/dist/arr/index.d.ts +8 -0
  17. package/dist/arr/index.js +9 -0
  18. package/dist/arr/index.js.map +1 -0
  19. package/{arr → dist/arr}/pluck/pluck.d.ts +1 -1
  20. package/dist/arr/pluck/pluck.js.map +1 -0
  21. package/dist/arr/within/within.js.map +1 -0
  22. package/dist/common/copy/copy.js.map +1 -0
  23. package/dist/common/equals/equals.js.map +1 -0
  24. package/{common → dist/common}/error.d.ts +7 -1
  25. package/dist/common/error.js.map +1 -0
  26. package/dist/common/for-each/for-each.js.map +1 -0
  27. package/dist/common/get-unique-num-id/get-unique-num-id.js.map +1 -0
  28. package/{common → dist/common}/get-unique-str-id/get-unique-str-id.js +1 -1
  29. package/dist/common/get-unique-str-id/get-unique-str-id.js.map +1 -0
  30. package/dist/common/has-iterator/has-iterator.js.map +1 -0
  31. package/dist/common/index.d.ts +17 -0
  32. package/dist/common/index.js +17 -0
  33. package/dist/common/index.js.map +1 -0
  34. package/dist/common/interrupt.d.ts +4 -0
  35. package/dist/common/interrupt.js +5 -0
  36. package/dist/common/interrupt.js.map +1 -0
  37. package/dist/common/is/is.js.map +1 -0
  38. package/dist/common/is-empty/is-empty.js.map +1 -0
  39. package/dist/common/random/random.js.map +1 -0
  40. package/dist/common/same/same.js.map +1 -0
  41. package/dist/common/stub/stub.js.map +1 -0
  42. package/dist/common/to-float/to-float.js.map +1 -0
  43. package/dist/common/to-int/to-int.js.map +1 -0
  44. package/dist/common/to-sorted-string/to-sorted-string.js.map +1 -0
  45. package/{common → dist/common}/types.d.ts +0 -11
  46. package/{arr → dist/common}/types.js.map +1 -1
  47. package/dist/dom/closest/closest.js.map +1 -0
  48. package/{dom → dist/dom}/document/document.js +1 -1
  49. package/dist/dom/document/document.js.map +1 -0
  50. package/{dom → dist/dom}/download-file/download-file.js +1 -1
  51. package/dist/dom/download-file/download-file.js.map +1 -0
  52. package/{dom → dist/dom}/for-each-elements/for-each-elements.js +1 -1
  53. package/dist/dom/for-each-elements/for-each-elements.js.map +1 -0
  54. package/{dom → dist/dom}/for-each-nodes/for-each-nodes.js +1 -1
  55. package/dist/dom/for-each-nodes/for-each-nodes.js.map +1 -0
  56. package/dist/dom/get-all-styles/get-all-styles.js.map +1 -0
  57. package/dist/dom/get-body/get-body.js.map +1 -0
  58. package/dist/dom/get-html/get-html.js.map +1 -0
  59. package/dist/dom/get-non-static-parent/get-non-static-parent.js.map +1 -0
  60. package/dist/dom/get-offset-from-doc/get-offset-from-doc.js.map +1 -0
  61. package/{dom → dist/dom}/get-offset-from-parent/get-offset-from-parent.js +1 -1
  62. package/dist/dom/get-offset-from-parent/get-offset-from-parent.js.map +1 -0
  63. package/dist/dom/get-offset-from-win/get-offset-from-win.js.map +1 -0
  64. package/dist/dom/get-scroll-width/get-scroll-width.js.map +1 -0
  65. package/dist/dom/get-style/get-style.js.map +1 -0
  66. package/{dom → dist/dom}/get-styles/get-styles.d.ts +1 -1
  67. package/dist/dom/get-styles/get-styles.js.map +1 -0
  68. package/{dom → dist/dom}/get-valid-style-name/get-valid-style-name.js +1 -1
  69. package/dist/dom/get-valid-style-name/get-valid-style-name.js.map +1 -0
  70. package/{dom → dist/dom}/get-window/get-window.js +1 -1
  71. package/dist/dom/get-window/get-window.js.map +1 -0
  72. package/dist/dom/has-name/has-name.js.map +1 -0
  73. package/dist/dom/index.d.ts +25 -0
  74. package/dist/dom/index.js +25 -0
  75. package/dist/dom/index.js.map +1 -0
  76. package/dist/dom/is-comment/is-comment.js.map +1 -0
  77. package/dist/dom/is-element/is-element.js.map +1 -0
  78. package/dist/dom/is-text/is-text.js.map +1 -0
  79. package/{dom → dist/dom}/set-offset-from-parent/set-offset-from-parent.js +1 -1
  80. package/dist/dom/set-offset-from-parent/set-offset-from-parent.js.map +1 -0
  81. package/dist/dom/set-style/set-style.js.map +1 -0
  82. package/{dom → dist/dom}/set-styles/set-styles.d.ts +1 -1
  83. package/dist/dom/set-styles/set-styles.js.map +1 -0
  84. package/{num → dist/dom}/types.js.map +1 -1
  85. package/{env → dist/env}/get-browser/get-browser.js +1 -1
  86. package/dist/env/get-browser/get-browser.js.map +1 -0
  87. package/{env → dist/env}/get-engine/get-engine.js +1 -1
  88. package/dist/env/get-engine/get-engine.js.map +1 -0
  89. package/{env → dist/env}/get-os/get-os.js +1 -1
  90. package/dist/env/get-os/get-os.js.map +1 -0
  91. package/{env → dist/env}/get-platform/get-platform.js +1 -1
  92. package/dist/env/get-platform/get-platform.js.map +1 -0
  93. package/dist/env/index.d.ts +21 -0
  94. package/dist/env/index.js +21 -0
  95. package/dist/env/index.js.map +1 -0
  96. package/dist/env/is-browser/is-browser.js.map +1 -0
  97. package/dist/env/is-chrome-like/is-chrome-like.js.map +1 -0
  98. package/dist/env/is-desktop/is-desktop.js.map +1 -0
  99. package/dist/env/is-engine/is-engine.js.map +1 -0
  100. package/dist/env/is-firefox-like/is-firefox-like.js.map +1 -0
  101. package/dist/env/is-mobile/is-mobile.js.map +1 -0
  102. package/dist/env/is-os/is-os.js.map +1 -0
  103. package/dist/env/is-portable/is-portable.js.map +1 -0
  104. package/dist/env/is-safari-like/is-safari-like.js.map +1 -0
  105. package/dist/env/is-stationary/is-stationary.js.map +1 -0
  106. package/dist/env/is-tablet/is-tablet.js.map +1 -0
  107. package/dist/env/is-tv/is-tv.js.map +1 -0
  108. package/{env → dist/env}/matches/matches.js +1 -1
  109. package/dist/env/matches/matches.js.map +1 -0
  110. package/{env → dist/env}/matches-with-browsers/matches-with-browsers.js +1 -1
  111. package/dist/env/matches-with-browsers/matches-with-browsers.js.map +1 -0
  112. package/{env → dist/env}/matches-with-version/matches-with-version.js +1 -1
  113. package/dist/env/matches-with-version/matches-with-version.js.map +1 -0
  114. package/{env → dist/env}/private/private.d.ts +1 -1
  115. package/{env → dist/env}/private/private.js +4 -4
  116. package/dist/env/private/private.js.map +1 -0
  117. package/{dom → dist/env}/types.js.map +1 -1
  118. package/{env → dist/env}/user-agent/user-agent.js +4 -1
  119. package/dist/env/user-agent/user-agent.js.map +1 -0
  120. package/dist/index.d.ts +7 -0
  121. package/dist/index.js +8 -0
  122. package/dist/index.js.map +1 -0
  123. package/{num/types.d.ts → dist/num/in-range/in-range.d.ts} +7 -0
  124. package/{num → dist/num}/in-range/in-range.js +1 -1
  125. package/dist/num/in-range/in-range.js.map +1 -0
  126. package/dist/num/index.d.ts +2 -0
  127. package/dist/num/index.js +3 -0
  128. package/dist/num/index.js.map +1 -0
  129. package/dist/num/round/round.js.map +1 -0
  130. package/{obj → dist/obj}/constant/constant.d.ts +1 -1
  131. package/dist/obj/constant/constant.js.map +1 -0
  132. package/{obj → dist/obj}/deep-constant/deep-constant.d.ts +1 -1
  133. package/{obj → dist/obj}/deep-constant/deep-constant.js +1 -1
  134. package/dist/obj/deep-constant/deep-constant.js.map +1 -0
  135. package/{obj/types.d.ts → dist/obj/diff-obj/diff-obj.d.ts} +8 -1
  136. package/{obj → dist/obj}/diff-obj/diff-obj.js +1 -1
  137. package/dist/obj/diff-obj/diff-obj.js.map +1 -0
  138. package/{obj → dist/obj}/exclude/exclude.d.ts +1 -1
  139. package/{obj → dist/obj}/exclude/exclude.js +1 -1
  140. package/dist/obj/exclude/exclude.js.map +1 -0
  141. package/{obj → dist/obj}/extend/extend.d.ts +1 -1
  142. package/{obj → dist/obj}/extend/extend.js +1 -1
  143. package/dist/obj/extend/extend.js.map +1 -0
  144. package/{obj → dist/obj}/for-each-obj/for-each-obj.d.ts +1 -1
  145. package/{obj → dist/obj}/for-each-obj/for-each-obj.js +1 -1
  146. package/dist/obj/for-each-obj/for-each-obj.js.map +1 -0
  147. package/{obj → dist/obj}/has-own/has-own.d.ts +1 -1
  148. package/dist/obj/has-own/has-own.js.map +1 -0
  149. package/{obj → dist/obj}/include/include.d.ts +1 -1
  150. package/{obj → dist/obj}/include/include.js +1 -1
  151. package/dist/obj/include/include.js.map +1 -0
  152. package/dist/obj/index.d.ts +12 -0
  153. package/dist/obj/index.js +13 -0
  154. package/dist/obj/index.js.map +1 -0
  155. package/{obj → dist/obj}/keys/keys.d.ts +1 -1
  156. package/dist/obj/keys/keys.js.map +1 -0
  157. package/{obj → dist/obj}/map-obj/map-obj.d.ts +1 -1
  158. package/dist/obj/map-obj/map-obj.js.map +1 -0
  159. package/{obj → dist/obj}/map-obj-to-arr/map-obj-to-arr.d.ts +1 -1
  160. package/dist/obj/map-obj-to-arr/map-obj-to-arr.js.map +1 -0
  161. package/{obj → dist/obj}/values/values.d.ts +1 -1
  162. package/dist/obj/values/values.js.map +1 -0
  163. package/dist/str/index.d.ts +3 -0
  164. package/dist/str/index.js +4 -0
  165. package/dist/str/index.js.map +1 -0
  166. package/dist/str/to-camel-case/to-camel-case.js.map +1 -0
  167. package/dist/str/to-hash/to-hash.js.map +1 -0
  168. package/dist/str/with-capital/with-capital.js.map +1 -0
  169. package/package.json +71 -73
  170. package/src/arr/at/at.ts +10 -0
  171. package/src/arr/cnd/cnd.ts +188 -0
  172. package/src/arr/diff-arr/diff-arr.ts +66 -0
  173. package/src/arr/fill/fill.ts +10 -0
  174. package/src/arr/for-each-arr/for-each-arr.ts +25 -0
  175. package/src/arr/index-by/index-by.ts +19 -0
  176. package/src/arr/index.ts +11 -0
  177. package/src/arr/pluck/pluck.ts +14 -0
  178. package/src/arr/within/within.ts +14 -0
  179. package/src/common/copy/copy.ts +89 -0
  180. package/src/common/equals/equals.ts +142 -0
  181. package/src/common/error.ts +34 -0
  182. package/src/common/for-each/for-each.ts +36 -0
  183. package/src/common/get-unique-num-id/get-unique-num-id.ts +8 -0
  184. package/src/common/get-unique-str-id/get-unique-str-id.ts +18 -0
  185. package/src/common/has-iterator/has-iterator.ts +7 -0
  186. package/src/common/index.ts +23 -0
  187. package/{common/types.js → src/common/interrupt.ts} +0 -1
  188. package/src/common/is/is.ts +244 -0
  189. package/src/common/is-empty/is-empty.ts +26 -0
  190. package/src/common/random/random.ts +8 -0
  191. package/src/common/same/same.ts +8 -0
  192. package/src/common/stub/stub.ts +7 -0
  193. package/src/common/to-float/to-float.ts +10 -0
  194. package/src/common/to-int/to-int.ts +10 -0
  195. package/src/common/to-sorted-string/to-sorted-string.ts +58 -0
  196. package/src/common/types.ts +66 -0
  197. package/src/dom/closest/closest.ts +24 -0
  198. package/src/dom/document/document.ts +25 -0
  199. package/src/dom/download-file/download-file.ts +31 -0
  200. package/src/dom/for-each-elements/for-each-elements.ts +17 -0
  201. package/src/dom/for-each-nodes/for-each-nodes.ts +15 -0
  202. package/src/dom/get-all-styles/get-all-styles.ts +10 -0
  203. package/src/dom/get-body/get-body.ts +9 -0
  204. package/src/dom/get-html/get-html.ts +9 -0
  205. package/src/dom/get-non-static-parent/get-non-static-parent.ts +9 -0
  206. package/src/dom/get-offset-from-doc/get-offset-from-doc.ts +18 -0
  207. package/src/dom/get-offset-from-parent/get-offset-from-parent.ts +48 -0
  208. package/src/dom/get-offset-from-win/get-offset-from-win.ts +9 -0
  209. package/src/dom/get-scroll-width/get-scroll-width.ts +33 -0
  210. package/src/dom/get-style/get-style.ts +25 -0
  211. package/src/dom/get-styles/get-styles.ts +14 -0
  212. package/src/dom/get-valid-style-name/get-valid-style-name.ts +45 -0
  213. package/src/dom/get-window/get-window.ts +17 -0
  214. package/src/dom/has-name/has-name.ts +8 -0
  215. package/src/dom/index.ts +25 -0
  216. package/src/dom/is-comment/is-comment.ts +7 -0
  217. package/src/dom/is-element/is-element.ts +7 -0
  218. package/src/dom/is-text/is-text.ts +7 -0
  219. package/src/dom/set-offset-from-parent/set-offset-from-parent.ts +46 -0
  220. package/src/dom/set-style/set-style.ts +14 -0
  221. package/src/dom/set-styles/set-styles.ts +17 -0
  222. package/src/dom/types.ts +20 -0
  223. package/src/env/get-browser/get-browser.ts +38 -0
  224. package/src/env/get-engine/get-engine.ts +27 -0
  225. package/src/env/get-os/get-os.ts +31 -0
  226. package/src/env/get-platform/get-platform.ts +34 -0
  227. package/src/env/index.ts +24 -0
  228. package/src/env/is-browser/is-browser.ts +15 -0
  229. package/src/env/is-chrome-like/is-chrome-like.ts +9 -0
  230. package/src/env/is-desktop/is-desktop.ts +9 -0
  231. package/src/env/is-engine/is-engine.ts +12 -0
  232. package/src/env/is-firefox-like/is-firefox-like.ts +9 -0
  233. package/src/env/is-mobile/is-mobile.ts +9 -0
  234. package/src/env/is-os/is-os.ts +13 -0
  235. package/src/env/is-portable/is-portable.ts +8 -0
  236. package/src/env/is-safari-like/is-safari-like.ts +9 -0
  237. package/src/env/is-stationary/is-stationary.ts +8 -0
  238. package/src/env/is-tablet/is-tablet.ts +9 -0
  239. package/src/env/is-tv/is-tv.ts +9 -0
  240. package/src/env/matches/matches.ts +55 -0
  241. package/src/env/matches-with-browsers/matches-with-browsers.ts +55 -0
  242. package/src/env/matches-with-version/matches-with-version.ts +44 -0
  243. package/src/env/private/private.ts +82 -0
  244. package/src/env/types.ts +146 -0
  245. package/src/env/user-agent/user-agent.ts +29 -0
  246. package/src/index.ts +7 -0
  247. package/src/num/in-range/in-range.ts +54 -0
  248. package/src/num/index.ts +2 -0
  249. package/src/num/round/round.ts +10 -0
  250. package/src/obj/constant/constant.ts +9 -0
  251. package/src/obj/deep-constant/deep-constant.ts +20 -0
  252. package/src/obj/diff-obj/diff-obj.ts +87 -0
  253. package/src/obj/exclude/exclude.ts +18 -0
  254. package/src/obj/extend/extend.ts +54 -0
  255. package/src/obj/for-each-obj/for-each-obj.ts +17 -0
  256. package/src/obj/has-own/has-own.ts +12 -0
  257. package/src/obj/include/include.ts +17 -0
  258. package/src/obj/index.ts +12 -0
  259. package/src/obj/keys/keys.ts +9 -0
  260. package/src/obj/map-obj/map-obj.ts +14 -0
  261. package/src/obj/map-obj-to-arr/map-obj-to-arr.ts +14 -0
  262. package/src/obj/values/values.ts +12 -0
  263. package/src/str/index.ts +3 -0
  264. package/src/str/to-camel-case/to-camel-case.ts +17 -0
  265. package/src/str/to-hash/to-hash.ts +21 -0
  266. package/src/str/with-capital/with-capital.ts +8 -0
  267. package/arr/at/at.js.map +0 -1
  268. package/arr/cnd/cnd.js.map +0 -1
  269. package/arr/diff-arr/diff-arr.d.ts +0 -10
  270. package/arr/diff-arr/diff-arr.js.map +0 -1
  271. package/arr/fill/fill.js.map +0 -1
  272. package/arr/for-each-arr/for-each-arr.js.map +0 -1
  273. package/arr/index-by/index-by.js.map +0 -1
  274. package/arr/index.d.ts +0 -9
  275. package/arr/index.js +0 -10
  276. package/arr/index.js.map +0 -1
  277. package/arr/pluck/pluck.js.map +0 -1
  278. package/arr/types.d.ts +0 -84
  279. package/arr/within/within.js.map +0 -1
  280. package/common/copy/copy.js.map +0 -1
  281. package/common/equals/equals.js.map +0 -1
  282. package/common/error.js.map +0 -1
  283. package/common/for-each/for-each.js.map +0 -1
  284. package/common/get-unique-num-id/get-unique-num-id.js.map +0 -1
  285. package/common/get-unique-str-id/get-unique-str-id.js.map +0 -1
  286. package/common/has-iterator/has-iterator.js.map +0 -1
  287. package/common/index.d.ts +0 -16
  288. package/common/index.js +0 -17
  289. package/common/index.js.map +0 -1
  290. package/common/is/is.js.map +0 -1
  291. package/common/is-empty/is-empty.js.map +0 -1
  292. package/common/random/random.js.map +0 -1
  293. package/common/same/same.js.map +0 -1
  294. package/common/stub/stub.js.map +0 -1
  295. package/common/to-float/to-float.js.map +0 -1
  296. package/common/to-int/to-int.js.map +0 -1
  297. package/common/to-sorted-string/to-sorted-string.js.map +0 -1
  298. package/common/types.js.map +0 -1
  299. package/dom/closest/closest.js.map +0 -1
  300. package/dom/document/document.js.map +0 -1
  301. package/dom/download-file/download-file.js.map +0 -1
  302. package/dom/for-each-elements/for-each-elements.js.map +0 -1
  303. package/dom/for-each-nodes/for-each-nodes.js.map +0 -1
  304. package/dom/get-all-styles/get-all-styles.js.map +0 -1
  305. package/dom/get-body/get-body.js.map +0 -1
  306. package/dom/get-html/get-html.js.map +0 -1
  307. package/dom/get-non-static-parent/get-non-static-parent.js.map +0 -1
  308. package/dom/get-offset-from-doc/get-offset-from-doc.js.map +0 -1
  309. package/dom/get-offset-from-parent/get-offset-from-parent.js.map +0 -1
  310. package/dom/get-offset-from-win/get-offset-from-win.js.map +0 -1
  311. package/dom/get-scroll-width/get-scroll-width.js.map +0 -1
  312. package/dom/get-style/get-style.js.map +0 -1
  313. package/dom/get-styles/get-styles.js.map +0 -1
  314. package/dom/get-valid-style-name/get-valid-style-name.js.map +0 -1
  315. package/dom/get-window/get-window.js.map +0 -1
  316. package/dom/has-name/has-name.js.map +0 -1
  317. package/dom/index.d.ts +0 -25
  318. package/dom/index.js +0 -26
  319. package/dom/index.js.map +0 -1
  320. package/dom/is-comment/is-comment.js.map +0 -1
  321. package/dom/is-element/is-element.js.map +0 -1
  322. package/dom/is-text/is-text.js.map +0 -1
  323. package/dom/set-offset-from-parent/set-offset-from-parent.js.map +0 -1
  324. package/dom/set-style/set-style.js.map +0 -1
  325. package/dom/set-styles/set-styles.js.map +0 -1
  326. package/env/get-browser/get-browser.js.map +0 -1
  327. package/env/get-engine/get-engine.js.map +0 -1
  328. package/env/get-os/get-os.js.map +0 -1
  329. package/env/get-platform/get-platform.js.map +0 -1
  330. package/env/index.d.ts +0 -21
  331. package/env/index.js +0 -22
  332. package/env/index.js.map +0 -1
  333. package/env/is-browser/is-browser.js.map +0 -1
  334. package/env/is-chrome-like/is-chrome-like.js.map +0 -1
  335. package/env/is-desktop/is-desktop.js.map +0 -1
  336. package/env/is-engine/is-engine.js.map +0 -1
  337. package/env/is-firefox-like/is-firefox-like.js.map +0 -1
  338. package/env/is-mobile/is-mobile.js.map +0 -1
  339. package/env/is-os/is-os.js.map +0 -1
  340. package/env/is-portable/is-portable.js.map +0 -1
  341. package/env/is-safari-like/is-safari-like.js.map +0 -1
  342. package/env/is-stationary/is-stationary.js.map +0 -1
  343. package/env/is-tablet/is-tablet.js.map +0 -1
  344. package/env/is-tv/is-tv.js.map +0 -1
  345. package/env/matches/matches.js.map +0 -1
  346. package/env/matches-with-browsers/matches-with-browsers.js.map +0 -1
  347. package/env/matches-with-version/matches-with-version.js.map +0 -1
  348. package/env/private/private.js.map +0 -1
  349. package/env/types.js.map +0 -1
  350. package/env/user-agent/user-agent.js.map +0 -1
  351. package/index.d.ts +0 -7
  352. package/index.js +0 -8
  353. package/index.js.map +0 -1
  354. package/num/in-range/in-range.d.ts +0 -8
  355. package/num/in-range/in-range.js.map +0 -1
  356. package/num/index.d.ts +0 -3
  357. package/num/index.js +0 -4
  358. package/num/index.js.map +0 -1
  359. package/num/round/round.js.map +0 -1
  360. package/num/types.js +0 -2
  361. package/obj/constant/constant.js.map +0 -1
  362. package/obj/deep-constant/deep-constant.js.map +0 -1
  363. package/obj/diff-obj/diff-obj.d.ts +0 -9
  364. package/obj/diff-obj/diff-obj.js.map +0 -1
  365. package/obj/exclude/exclude.js.map +0 -1
  366. package/obj/extend/extend.js.map +0 -1
  367. package/obj/for-each-obj/for-each-obj.js.map +0 -1
  368. package/obj/has-own/has-own.js.map +0 -1
  369. package/obj/include/include.js.map +0 -1
  370. package/obj/index.d.ts +0 -13
  371. package/obj/index.js +0 -14
  372. package/obj/index.js.map +0 -1
  373. package/obj/keys/keys.js.map +0 -1
  374. package/obj/map-obj/map-obj.js.map +0 -1
  375. package/obj/map-obj-to-arr/map-obj-to-arr.js.map +0 -1
  376. package/obj/types.js +0 -2
  377. package/obj/types.js.map +0 -1
  378. package/obj/values/values.js.map +0 -1
  379. package/str/index.d.ts +0 -3
  380. package/str/index.js +0 -4
  381. package/str/index.js.map +0 -1
  382. package/str/to-camel-case/to-camel-case.js.map +0 -1
  383. package/str/to-hash/to-hash.js.map +0 -1
  384. package/str/with-capital/with-capital.js.map +0 -1
  385. /package/{arr → dist/arr}/at/at.d.ts +0 -0
  386. /package/{arr → dist/arr}/at/at.js +0 -0
  387. /package/{arr → dist/arr}/diff-arr/diff-arr.js +0 -0
  388. /package/{arr → dist/arr}/fill/fill.d.ts +0 -0
  389. /package/{arr → dist/arr}/fill/fill.js +0 -0
  390. /package/{arr → dist/arr}/pluck/pluck.js +0 -0
  391. /package/{arr → dist/arr}/within/within.d.ts +0 -0
  392. /package/{arr → dist/arr}/within/within.js +0 -0
  393. /package/{common → dist/common}/copy/copy.d.ts +0 -0
  394. /package/{common → dist/common}/copy/copy.js +0 -0
  395. /package/{common → dist/common}/equals/equals.d.ts +0 -0
  396. /package/{common → dist/common}/equals/equals.js +0 -0
  397. /package/{common → dist/common}/error.js +0 -0
  398. /package/{common → dist/common}/for-each/for-each.d.ts +0 -0
  399. /package/{common → dist/common}/for-each/for-each.js +0 -0
  400. /package/{common → dist/common}/get-unique-num-id/get-unique-num-id.d.ts +0 -0
  401. /package/{common → dist/common}/get-unique-num-id/get-unique-num-id.js +0 -0
  402. /package/{common → dist/common}/get-unique-str-id/get-unique-str-id.d.ts +0 -0
  403. /package/{common → dist/common}/has-iterator/has-iterator.d.ts +0 -0
  404. /package/{common → dist/common}/has-iterator/has-iterator.js +0 -0
  405. /package/{common → dist/common}/is/is.d.ts +0 -0
  406. /package/{common → dist/common}/is/is.js +0 -0
  407. /package/{common → dist/common}/is-empty/is-empty.d.ts +0 -0
  408. /package/{common → dist/common}/is-empty/is-empty.js +0 -0
  409. /package/{common → dist/common}/random/random.d.ts +0 -0
  410. /package/{common → dist/common}/random/random.js +0 -0
  411. /package/{common → dist/common}/same/same.d.ts +0 -0
  412. /package/{common → dist/common}/same/same.js +0 -0
  413. /package/{common → dist/common}/stub/stub.d.ts +0 -0
  414. /package/{common → dist/common}/stub/stub.js +0 -0
  415. /package/{common → dist/common}/to-float/to-float.d.ts +0 -0
  416. /package/{common → dist/common}/to-float/to-float.js +0 -0
  417. /package/{common → dist/common}/to-int/to-int.d.ts +0 -0
  418. /package/{common → dist/common}/to-int/to-int.js +0 -0
  419. /package/{common → dist/common}/to-sorted-string/to-sorted-string.d.ts +0 -0
  420. /package/{common → dist/common}/to-sorted-string/to-sorted-string.js +0 -0
  421. /package/{arr → dist/common}/types.js +0 -0
  422. /package/{dom → dist/dom}/closest/closest.d.ts +0 -0
  423. /package/{dom → dist/dom}/closest/closest.js +0 -0
  424. /package/{dom → dist/dom}/document/document.d.ts +0 -0
  425. /package/{dom → dist/dom}/download-file/download-file.d.ts +0 -0
  426. /package/{dom → dist/dom}/for-each-elements/for-each-elements.d.ts +0 -0
  427. /package/{dom → dist/dom}/for-each-nodes/for-each-nodes.d.ts +0 -0
  428. /package/{dom → dist/dom}/get-all-styles/get-all-styles.d.ts +0 -0
  429. /package/{dom → dist/dom}/get-all-styles/get-all-styles.js +0 -0
  430. /package/{dom → dist/dom}/get-body/get-body.d.ts +0 -0
  431. /package/{dom → dist/dom}/get-body/get-body.js +0 -0
  432. /package/{dom → dist/dom}/get-html/get-html.d.ts +0 -0
  433. /package/{dom → dist/dom}/get-html/get-html.js +0 -0
  434. /package/{dom → dist/dom}/get-non-static-parent/get-non-static-parent.d.ts +0 -0
  435. /package/{dom → dist/dom}/get-non-static-parent/get-non-static-parent.js +0 -0
  436. /package/{dom → dist/dom}/get-offset-from-doc/get-offset-from-doc.d.ts +0 -0
  437. /package/{dom → dist/dom}/get-offset-from-doc/get-offset-from-doc.js +0 -0
  438. /package/{dom → dist/dom}/get-offset-from-parent/get-offset-from-parent.d.ts +0 -0
  439. /package/{dom → dist/dom}/get-offset-from-win/get-offset-from-win.d.ts +0 -0
  440. /package/{dom → dist/dom}/get-offset-from-win/get-offset-from-win.js +0 -0
  441. /package/{dom → dist/dom}/get-scroll-width/get-scroll-width.d.ts +0 -0
  442. /package/{dom → dist/dom}/get-scroll-width/get-scroll-width.js +0 -0
  443. /package/{dom → dist/dom}/get-style/get-style.d.ts +0 -0
  444. /package/{dom → dist/dom}/get-style/get-style.js +0 -0
  445. /package/{dom → dist/dom}/get-styles/get-styles.js +0 -0
  446. /package/{dom → dist/dom}/get-valid-style-name/get-valid-style-name.d.ts +0 -0
  447. /package/{dom → dist/dom}/get-window/get-window.d.ts +0 -0
  448. /package/{dom → dist/dom}/has-name/has-name.d.ts +0 -0
  449. /package/{dom → dist/dom}/has-name/has-name.js +0 -0
  450. /package/{dom → dist/dom}/is-comment/is-comment.d.ts +0 -0
  451. /package/{dom → dist/dom}/is-comment/is-comment.js +0 -0
  452. /package/{dom → dist/dom}/is-element/is-element.d.ts +0 -0
  453. /package/{dom → dist/dom}/is-element/is-element.js +0 -0
  454. /package/{dom → dist/dom}/is-text/is-text.d.ts +0 -0
  455. /package/{dom → dist/dom}/is-text/is-text.js +0 -0
  456. /package/{dom → dist/dom}/set-offset-from-parent/set-offset-from-parent.d.ts +0 -0
  457. /package/{dom → dist/dom}/set-style/set-style.d.ts +0 -0
  458. /package/{dom → dist/dom}/set-style/set-style.js +0 -0
  459. /package/{dom → dist/dom}/set-styles/set-styles.js +0 -0
  460. /package/{dom → dist/dom}/types.d.ts +0 -0
  461. /package/{dom → dist/dom}/types.js +0 -0
  462. /package/{env → dist/env}/get-browser/get-browser.d.ts +0 -0
  463. /package/{env → dist/env}/get-engine/get-engine.d.ts +0 -0
  464. /package/{env → dist/env}/get-os/get-os.d.ts +0 -0
  465. /package/{env → dist/env}/get-platform/get-platform.d.ts +0 -0
  466. /package/{env → dist/env}/is-browser/is-browser.d.ts +0 -0
  467. /package/{env → dist/env}/is-browser/is-browser.js +0 -0
  468. /package/{env → dist/env}/is-chrome-like/is-chrome-like.d.ts +0 -0
  469. /package/{env → dist/env}/is-chrome-like/is-chrome-like.js +0 -0
  470. /package/{env → dist/env}/is-desktop/is-desktop.d.ts +0 -0
  471. /package/{env → dist/env}/is-desktop/is-desktop.js +0 -0
  472. /package/{env → dist/env}/is-engine/is-engine.d.ts +0 -0
  473. /package/{env → dist/env}/is-engine/is-engine.js +0 -0
  474. /package/{env → dist/env}/is-firefox-like/is-firefox-like.d.ts +0 -0
  475. /package/{env → dist/env}/is-firefox-like/is-firefox-like.js +0 -0
  476. /package/{env → dist/env}/is-mobile/is-mobile.d.ts +0 -0
  477. /package/{env → dist/env}/is-mobile/is-mobile.js +0 -0
  478. /package/{env → dist/env}/is-os/is-os.d.ts +0 -0
  479. /package/{env → dist/env}/is-os/is-os.js +0 -0
  480. /package/{env → dist/env}/is-portable/is-portable.d.ts +0 -0
  481. /package/{env → dist/env}/is-portable/is-portable.js +0 -0
  482. /package/{env → dist/env}/is-safari-like/is-safari-like.d.ts +0 -0
  483. /package/{env → dist/env}/is-safari-like/is-safari-like.js +0 -0
  484. /package/{env → dist/env}/is-stationary/is-stationary.d.ts +0 -0
  485. /package/{env → dist/env}/is-stationary/is-stationary.js +0 -0
  486. /package/{env → dist/env}/is-tablet/is-tablet.d.ts +0 -0
  487. /package/{env → dist/env}/is-tablet/is-tablet.js +0 -0
  488. /package/{env → dist/env}/is-tv/is-tv.d.ts +0 -0
  489. /package/{env → dist/env}/is-tv/is-tv.js +0 -0
  490. /package/{env → dist/env}/matches/matches.d.ts +0 -0
  491. /package/{env → dist/env}/matches-with-browsers/matches-with-browsers.d.ts +0 -0
  492. /package/{env → dist/env}/matches-with-version/matches-with-version.d.ts +0 -0
  493. /package/{env → dist/env}/types.d.ts +0 -0
  494. /package/{env → dist/env}/types.js +0 -0
  495. /package/{env → dist/env}/user-agent/user-agent.d.ts +0 -0
  496. /package/{num → dist/num}/round/round.d.ts +0 -0
  497. /package/{num → dist/num}/round/round.js +0 -0
  498. /package/{obj → dist/obj}/constant/constant.js +0 -0
  499. /package/{obj → dist/obj}/has-own/has-own.js +0 -0
  500. /package/{obj → dist/obj}/keys/keys.js +0 -0
  501. /package/{obj → dist/obj}/map-obj/map-obj.js +0 -0
  502. /package/{obj → dist/obj}/map-obj-to-arr/map-obj-to-arr.js +0 -0
  503. /package/{obj → dist/obj}/values/values.js +0 -0
  504. /package/{str → dist/str}/to-camel-case/to-camel-case.d.ts +0 -0
  505. /package/{str → dist/str}/to-camel-case/to-camel-case.js +0 -0
  506. /package/{str → dist/str}/to-hash/to-hash.d.ts +0 -0
  507. /package/{str → dist/str}/to-hash/to-hash.js +0 -0
  508. /package/{str → dist/str}/with-capital/with-capital.d.ts +0 -0
  509. /package/{str → dist/str}/with-capital/with-capital.js +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/obj/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAC,UAAU,EAAC,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAC,IAAI,EAAC,MAAM,aAAa,CAAC;AACjC,OAAO,EAAC,MAAM,EAAC,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAC,OAAO,EAAC,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAC,OAAO,EAAC,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAC,QAAQ,EAAC,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAC,YAAY,EAAC,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAC,MAAM,EAAC,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAC,WAAW,EAAC,MAAM,iCAAiC,CAAC;AAC5D,OAAO,EAAC,OAAO,EAAU,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAC,MAAM,EAAE,SAAS,EAAC,MAAM,iBAAiB,CAAC"}
@@ -1,4 +1,4 @@
1
- import { Obj } from '../../';
1
+ import { Obj } from '../../common';
2
2
  /**
3
3
  * Returns an array of the object's own enumerable property names
4
4
  * @param obj - any object
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keys.js","sourceRoot":"","sources":["../../../src/obj/keys/keys.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,UAAU,IAAI,CAAgB,GAAM;IACxC,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC1B,CAAC"}
@@ -1,4 +1,4 @@
1
- import { Obj, ValueUnion } from '../../';
1
+ import { Obj, ValueUnion } from '../../common';
2
2
  /**
3
3
  * Returns a new object, which has the mapped values of object fields
4
4
  * @param obj - any object
@@ -0,0 +1 @@
1
+ {"version":3,"file":"map-obj.js","sourceRoot":"","sources":["../../../src/obj/map-obj/map-obj.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,UAAU,EAAC,MAAM,KAAK,CAAC;AAE/B;;;;GAIG;AACH,MAAM,UAAU,MAAM,CAAsC,GAAM,EAChE,OAAoD;IACpD,MAAM,MAAM,GAAiB,EAAE,CAAC;IAChC,UAAU,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC,MAAM,CAAI,GAAG,CAAC,GAAG,OAAO,CAAC,KAAK,EAAK,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;IAC9E,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -1,4 +1,4 @@
1
- import { Obj, ValueUnion } from '../../';
1
+ import { Obj, ValueUnion } from '../../common';
2
2
  /**
3
3
  * Returns an array, which has the mapped values of object fields
4
4
  * @param obj - any object
@@ -0,0 +1 @@
1
+ {"version":3,"file":"map-obj-to-arr.js","sourceRoot":"","sources":["../../../src/obj/map-obj-to-arr/map-obj-to-arr.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,UAAU,EAAC,MAAM,KAAK,CAAC;AAE/B;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAsC,GAAM,EACrE,OAAoD;IACpD,MAAM,MAAM,GAAQ,EAAE,CAAC;IACvB,UAAU,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAK,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;IAC1E,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -1,4 +1,4 @@
1
- import { Obj } from '../../';
1
+ import { Obj } from '../../common';
2
2
  /**
3
3
  * Returns an array of values for each object's own enumerable property
4
4
  * @param obj - any object
@@ -0,0 +1 @@
1
+ {"version":3,"file":"values.js","sourceRoot":"","sources":["../../../src/obj/values/values.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,UAAU,EAAC,MAAM,KAAK,CAAC;AAE/B;;;GAGG;AACH,MAAM,UAAU,MAAM,CAAI,GAAW;IACnC,MAAM,MAAM,GAAQ,EAAE,CAAC;IACvB,UAAU,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAC7C,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { withCapital } from './with-capital/with-capital';
2
+ export { toCamelCase } from './to-camel-case/to-camel-case';
3
+ export { toHash } from './to-hash/to-hash';
@@ -0,0 +1,4 @@
1
+ export { withCapital } from './with-capital/with-capital';
2
+ export { toCamelCase } from './to-camel-case/to-camel-case';
3
+ export { toHash } from './to-hash/to-hash';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/str/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,6BAA6B,CAAC;AACxD,OAAO,EAAC,WAAW,EAAC,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EAAC,MAAM,EAAC,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"to-camel-case.js","sourceRoot":"","sources":["../../../src/str/to-camel-case/to-camel-case.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,UAAU,WAAW,CAAC,GAAW,EAAE,aAAuB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;IAC7E,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC,GAAW,EAAE,SAAiB,EAAE,EAAE;QAC1D,MAAM,GAAG,GAAG,IAAI,MAAM,CAAC,SAAS,GAAG,YAAY,EAAE,IAAI,CAAC,CAAC;QACvD,OAAO,GAAG,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,GAAW,EAAE,MAAc,EAAE,EAAE;YACtD,OAAO,MAAM,CAAC,WAAW,EAAE,CAAC;QAC9B,CAAC,CAAC,CAAC;IACL,CAAC,EAAE,GAAG,CAAC,CAAC;AACV,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"to-hash.js","sourceRoot":"","sources":["../../../src/str/to-hash/to-hash.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,UAAU,MAAM,CAAC,GAAW;IAChC,IAAI,GAAG,EAAE;QACP,IAAI,IAAI,GAAG,CAAC,CAAC;QAEb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACnC,MAAM,IAAI,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;YAC/B,IAAI,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC;YACnC,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;SACpB;QAED,OAAO,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC;KACvD;SAAM;QACL,OAAO,EAAE,CAAC;KACX;AACH,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with-capital.js","sourceRoot":"","sources":["../../../src/str/with-capital/with-capital.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,GAAW;IACrC,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;AACxD,CAAC"}
package/package.json CHANGED
@@ -1,73 +1,71 @@
1
- {
2
- "name": "@bitfiber/utils",
3
- "description": "Collection of versatile utility functions for Javascript",
4
- "version": "1.0.1",
5
- "type": "module",
6
- "module": "./src/index.js",
7
- "main": "./index.js",
8
- "types": "./index.d.ts",
9
- "typesVersions": {
10
- ">=4.8.2": {
11
- "*": [
12
- "*.d.ts"
13
- ]
14
- }
15
- },
16
- "sideEffects": false,
17
- "exports": {
18
- ".": {
19
- "types": "./index.d.ts",
20
- "default": "./index.js"
21
- },
22
- "./arr": {
23
- "types": "./arr/index.d.ts",
24
- "default": "./arr/index.js"
25
- },
26
- "./obj": {
27
- "types": "./obj/index.d.ts",
28
- "default": "./obj/index.js"
29
- },
30
- "./str": {
31
- "types": "./str/index.d.ts",
32
- "default": "./str/index.js"
33
- },
34
- "./num": {
35
- "types": "./num/index.d.ts",
36
- "default": "./num/index.js"
37
- },
38
- "./dom": {
39
- "types": "./dom/index.d.ts",
40
- "default": "./dom/index.js"
41
- },
42
- "./env": {
43
- "types": "./env/index.d.ts",
44
- "default": "./env/index.js"
45
- },
46
- "./package.json": "./package.json"
47
- },
48
- "repository": {
49
- "type": "git",
50
- "url": "https://github.com/bitfiber/utils.git",
51
- "directory": "utils"
52
- },
53
- "keywords": [
54
- "Javascript",
55
- "Typescript",
56
- "Utils",
57
- "Utilities",
58
- "Helpers"
59
- ],
60
- "author": {
61
- "name": "Zmanovskyi Oleksandr",
62
- "email": "bitfiber.web@gmail.com"
63
- },
64
- "license": "Apache 2.0",
65
- "bugs": {
66
- "url": "https://github.com/bitfiber/utils/issues"
67
- },
68
- "homepage": "https://github.com/bitfiber/utils",
69
- "dependencies": {
70
- "tslib": "^2.3.0"
71
- },
72
- "peerDependencies": {}
73
- }
1
+ {
2
+ "name": "@bitfiber/utils",
3
+ "description": "Collection of versatile utility functions for Javascript",
4
+ "version": "1.0.3",
5
+ "type": "module",
6
+ "module": "./dist/index.js",
7
+ "main": "./dist/index.js",
8
+ "types": "index.d.ts",
9
+ "typesVersions": {
10
+ ">=4.8.2": {
11
+ "*": ["dist/*"]
12
+ }
13
+ },
14
+ "sideEffects": false,
15
+ "exports": {
16
+ ".": {
17
+ "types": "./dist/index.d.ts",
18
+ "default": "./dist/index.js"
19
+ },
20
+ "./arr": {
21
+ "types": "./dist/arr/index.d.ts",
22
+ "default": "./dist/arr/index.js"
23
+ },
24
+ "./obj": {
25
+ "types": "./dist/obj/index.d.ts",
26
+ "default": "./dist/obj/index.js"
27
+ },
28
+ "./str": {
29
+ "types": "./dist/str/index.d.ts",
30
+ "default": "./dist/str/index.js"
31
+ },
32
+ "./num": {
33
+ "types": "./dist/num/index.d.ts",
34
+ "default": "./dist/num/index.js"
35
+ },
36
+ "./dom": {
37
+ "types": "./dist/dom/index.d.ts",
38
+ "default": "./dist/dom/index.js"
39
+ },
40
+ "./env": {
41
+ "types": "./dist/env/index.d.ts",
42
+ "default": "./dist/env/index.js"
43
+ },
44
+ "./package.json": "./package.json"
45
+ },
46
+ "repository": {
47
+ "type": "git",
48
+ "url": "https://github.com/bitfiber/utils.git",
49
+ "directory": "utils"
50
+ },
51
+ "keywords": [
52
+ "Javascript",
53
+ "Typescript",
54
+ "Utils",
55
+ "Utilities",
56
+ "Helpers"
57
+ ],
58
+ "author": {
59
+ "name": "Oleksandr Zmanovskyi",
60
+ "email": "bitfiber.web@gmail.com"
61
+ },
62
+ "license": "Apache 2.0",
63
+ "bugs": {
64
+ "url": "https://github.com/bitfiber/utils/issues"
65
+ },
66
+ "homepage": "https://github.com/bitfiber/utils",
67
+ "dependencies": {
68
+ "tslib": "^2.3.0"
69
+ },
70
+ "peerDependencies": {}
71
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Returns the array item at index, or undefined if there is no index.
3
+ * For negative indexes, returns items from the end
4
+ * @param arr - any array
5
+ * @param index - item index
6
+ */
7
+ export function at<T>(arr: T[], index: number): T | undefined {
8
+ // todo: change on 'Array.at' with ES2022
9
+ return index < 0 ? arr[arr.length + index] : arr[index];
10
+ }
@@ -0,0 +1,188 @@
1
+ import {BfError, isFunction, isObject, isRegExp, isString, same, equals, isArray} from '../../common';
2
+ import {hasOwn} from '../../obj';
3
+
4
+ /**
5
+ * Represents a condition that is true if the function returns true
6
+ * Used for the cnd function
7
+ */
8
+ export type MatchConditionFn = (value: any) => boolean;
9
+
10
+ /**
11
+ * Represents a condition that is true if the value is the same as the condition
12
+ * Used for the cnd function
13
+ */
14
+ export type MatchConditionIs = {is: any};
15
+
16
+ /**
17
+ * Represents a condition that is true if the value is the same for at least one part of the condition
18
+ * Used for the cnd function
19
+ */
20
+ export type MatchConditionOr = {or: any[]};
21
+
22
+ /**
23
+ * Represents a condition that is true if the value is not the same for each part of the condition
24
+ * Used for the cnd function
25
+ */
26
+ export type MatchConditionNot = {not: any[]};
27
+
28
+ /**
29
+ * Represents a condition that is true if the value is equal to the condition
30
+ * Used for the cnd function
31
+ */
32
+ export type MatchConditionEqual = {equal: any};
33
+
34
+ /**
35
+ * Represents a condition that is true if the value is equal to at least one part of the condition
36
+ * Used for the cnd function
37
+ */
38
+ export type MatchConditionOrEqual = {orEqual: any[]};
39
+
40
+ /**
41
+ * Represents a condition that is true if the value is not equal to each part of the condition
42
+ * Used for the cnd function
43
+ */
44
+ export type MatchConditionNotEqual = {notEqual: any[]};
45
+
46
+ /**
47
+ * Represents a group of all object condition types
48
+ * Used for the cnd function
49
+ */
50
+ export type MatchConditionObj = MatchConditionIs | MatchConditionOr | MatchConditionNot | MatchConditionEqual
51
+ | MatchConditionOrEqual | MatchConditionNotEqual;
52
+
53
+ /**
54
+ * Represents a condition that is true if the value of each field matches each field condition
55
+ * Used for the cnd function
56
+ */
57
+ export type MatchConditionsByFields = {
58
+ [field: string]: MatchConditionObj | RegExp;
59
+ };
60
+
61
+ /**
62
+ * Represents all condition types for the cnd function
63
+ */
64
+ export type MatchConditions = MatchConditionFn | MatchConditionObj | MatchConditionsByFields;
65
+
66
+ /**
67
+ * Returns a function that checks if a value matches the conditions
68
+ * @example
69
+ * import {cnd} from '@bitfiber/utils/arr';
70
+ *
71
+ * const obj1 = {name: 'Alex'};
72
+ * const obj2 = {name: 'Mary'};
73
+ * const obj3 = {name: 'Jack'};
74
+ * const arr = [obj1, obj2, obj3];
75
+ * const strArr = ['Alex', 'Mary', 'Jack'];
76
+ *
77
+ * // Handler for comparison
78
+ * arr.filter(cnd(obj => obj.name === 'Alex')); // [{name: 'Alex'}]
79
+ *
80
+ * // Strict value comparison
81
+ * arr.filter(cnd({is: obj1})); // [{name: 'Alex'}]
82
+ * arr.filter(cnd({is: {name: 'Alex'}})); // []
83
+ * arr.filter(cnd({or: [obj1, obj2]})); // [{name: 'Alex'}, {name: 'Mary'}]
84
+ * arr.filter(cnd({or: [{name: 'Alex'}, obj2]})); // [{name: 'Mary'}]
85
+ * arr.filter(cnd({not: [obj1, obj2]})); // [{name: 'Jack'}]
86
+ * arr.filter(cnd({not: [{name: 'Alex'}, obj2]})); // [{name: 'Alex'}, {name: 'Jack'}]
87
+ *
88
+ * // Value equivalence comparison
89
+ * arr.filter(cnd({equal: obj1})); // [{name: 'Alex'}]
90
+ * arr.filter(cnd({equal: {name: 'Alex'}})); // [{name: 'Alex'}]
91
+ * arr.filter(cnd({orEqual: [obj1, obj2]})); // [{name: 'Alex'}, {name: 'Mary'}]
92
+ * arr.filter(cnd({orEqual: [{name: 'Alex'}, obj2]})); // [{name: 'Alex'}, {name: 'Mary'}]
93
+ * arr.filter(cnd({notEqual: [obj1, obj2]})); // [{name: 'Jack'}]
94
+ * arr.filter(cnd({notEqual: [{name: 'Alex'}, obj2]})); // [{name: 'Jack'}]
95
+ *
96
+ * // String value RegExp comparison
97
+ * strArr.filter(cnd({equal: /^Alex$/})); // ['Alex']
98
+ * strArr.filter(cnd({orEqual: [/^Alex$/, /^Mary$/]})); // ['Alex', 'Mary']
99
+ * strArr.filter(cnd({notEqual: [/^Alex$/, /^Mary$/]})); // ['Jack']
100
+ *
101
+ * // Strict comparison of field value in objects
102
+ * arr.filter(cnd({name: {is: 'Alex'}})); // [{name: 'Alex'}]
103
+ * arr.filter(cnd({name: {or: ['Alex', 'Mary']}})); // [{name: 'Alex'}, {name: 'Mary'}]
104
+ * arr.filter(cnd({name: {not: ['Alex', 'Mary']}})); // [{name: 'Jack'}]
105
+ *
106
+ * // Comparison of field value equivalence in objects
107
+ * arr.filter(cnd({name: {equal: 'Alex'}})); // [{name: 'Alex'}]
108
+ * arr.filter(cnd({name: {orEqual: ['Alex', 'Mary']}})); // [{name: 'Alex'}, {name: 'Mary'}]
109
+ * arr.filter(cnd({name: {notEqual: ['Alex', 'Mary']}})); // [{name: 'Jack'}]
110
+ *
111
+ * // Comparing string fields in objects using RegExp
112
+ * arr.filter(cnd({name: /^Alex$/})); // [{name: 'Alex'}]
113
+ * arr.filter(cnd({name: {equal: /^Alex$/}})); // [{name: 'Alex'}]
114
+ * arr.filter(cnd({name: {orEqual: [/^Alex$/, /^Mary$/]}})); // [{name: 'Alex'}, {name: 'Mary'}]
115
+ * arr.filter(cnd({name: {notEqual: [/^Alex$/, /^Mary$/]}})); // [{name: 'Jack'}]
116
+ *
117
+ * @param conditions
118
+ */
119
+ export function cnd(conditions: MatchConditions): MatchConditionFn {
120
+ if (isFunction(conditions)) {
121
+ return conditions;
122
+ } else if ('is' in conditions) {
123
+ return value => same(conditions.is, value);
124
+ } else if ('or' in conditions) {
125
+ return value => (isArray(conditions.or) ? conditions.or.some(item => same(item, value)) : cndErr());
126
+ } else if ('not' in conditions) {
127
+ return value => (isArray(conditions.not) ? !conditions.not.some(item => same(item, value)) : cndErr());
128
+ } else if ('equal' in conditions) {
129
+ return value => fit(conditions.equal, value);
130
+ } else if ('orEqual' in conditions) {
131
+ return value => (isArray(conditions.orEqual) ? conditions.orEqual.some(item => fit(item, value)) : cndErr());
132
+ } else if ('notEqual' in conditions) {
133
+ return value => (isArray(conditions.notEqual) ? !conditions.notEqual.some(item => fit(item, value)) : cndErr());
134
+ } else {
135
+ return obj => {
136
+ if (isObject(obj)) {
137
+ for (const key in conditions) {
138
+ if (hasOwn(conditions, key)) {
139
+ const value = obj[key];
140
+ const condition = conditions[key];
141
+
142
+ if (isRegExp(condition)) {
143
+ if (!fit(condition, value)) {
144
+ return false;
145
+ }
146
+ } else if ('is' in condition) {
147
+ if (!same(condition.is, value)) {
148
+ return false;
149
+ }
150
+ } else if ('or' in condition) {
151
+ if (!condition.or.some(item => same(item, value))) {
152
+ return false;
153
+ }
154
+ } else if ('not' in condition) {
155
+ if (condition.not.some(item => same(item, value))) {
156
+ return false;
157
+ }
158
+ } else if ('equal' in condition) {
159
+ if (!fit(condition.equal, value)) {
160
+ return false;
161
+ }
162
+ } else if ('orEqual' in condition) {
163
+ if (!condition.orEqual.some(item => fit(item, value))) {
164
+ return false;
165
+ }
166
+ } else if ('notEqual' in condition) {
167
+ if (condition.notEqual.some(item => fit(item, value))) {
168
+ return false;
169
+ }
170
+ }
171
+ }
172
+ }
173
+
174
+ return true;
175
+ } else {
176
+ return false;
177
+ }
178
+ };
179
+ }
180
+ }
181
+
182
+ function fit(condition: any, value: any): boolean {
183
+ return isRegExp(condition) ? isString(value) && condition.test(value) : equals(condition, value);
184
+ }
185
+
186
+ function cndErr(): never {
187
+ throw new BfError('"or", "not", "orEqual" and "notEqual" must be an array', {code: 'bf_utils_arr_cnd_1'});
188
+ }
@@ -0,0 +1,66 @@
1
+ import {NumStr} from '../../common';
2
+
3
+ /**
4
+ * Represents response of the diffArr function
5
+ */
6
+ export interface ArrDiff<T> {
7
+
8
+ /**
9
+ * Contains items that are only in array 1
10
+ */
11
+ only1: T[];
12
+
13
+ /**
14
+ * Contains items that are only in array 2
15
+ */
16
+ only2: T[];
17
+
18
+ /**
19
+ * Contains items that are in both arrays
20
+ */
21
+ equal: T[];
22
+
23
+ /**
24
+ * True if only1 and only2 are empty, otherwise false
25
+ */
26
+ isEqual: boolean;
27
+ }
28
+
29
+ /**
30
+ * Returns the difference between two arrays
31
+ * Strict comparison of array items is applied
32
+ * The order doesn't matter
33
+ * @param arr1 - array 1
34
+ * @param arr2 - array 2
35
+ */
36
+ export function diffArr<T extends NumStr>(arr1: T[], arr2: T[]): ArrDiff<T> {
37
+ let isEqual = true;
38
+ const only1: T[] = [];
39
+ const only2: T[] = [];
40
+ const equal: T[] = [];
41
+ const map1 = new Map(arr1.map(value => [value, true]));
42
+ const map2 = new Map(arr2.map(value => [value, true]));
43
+
44
+ for (const value of map1.keys()) {
45
+ if (!map2.has(value)) {
46
+ isEqual = false;
47
+ only1.push(value);
48
+ } else {
49
+ equal.push(value);
50
+ }
51
+ }
52
+
53
+ for (const value of map2.keys()) {
54
+ if (!map1.has(value)) {
55
+ isEqual = false;
56
+ only2.push(value);
57
+ }
58
+ }
59
+
60
+ return {
61
+ only1,
62
+ only2,
63
+ equal,
64
+ isEqual,
65
+ };
66
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Fills a new array with items that will be returned by the handler,
3
+ * which will be called a certain number of times
4
+ * @param quantity - number of array items
5
+ * @param handler - a function that should return a new array item
6
+ * @param offset - offset for the index, which is passed to the handler
7
+ */
8
+ export function fill<T>(quantity: number, handler: (offsetIndex: number, index: number) => T, offset = 1): T[] {
9
+ return Array(quantity).fill(null).map((item, index) => handler(index + offset, index));
10
+ }
@@ -0,0 +1,25 @@
1
+ import {Arr, INTERRUPT, ValueUnion} from '../../common';
2
+
3
+ /**
4
+ * Iterates through all the items of an array and calls a handler for each item
5
+ * If the handler returns INTERRUPT, the loop will be interrupted
6
+ * @param arr - an array or any typed array
7
+ * @param handler - function called for each item
8
+ * @param reverse - iterates in reverse order if true
9
+ */
10
+ export function forEachArr<T extends Arr, V extends ValueUnion<T>>(arr: T,
11
+ handler: (value: V, index: number, arr: T) => any, reverse?: boolean): void {
12
+ if (reverse) {
13
+ for (let i = arr.length - 1; i >= 0; i--) {
14
+ if (handler(arr[i], i, arr) === INTERRUPT) {
15
+ return;
16
+ }
17
+ }
18
+ } else {
19
+ for (let i = 0; i < arr.length; i++) {
20
+ if (handler(arr[i], i, arr) === INTERRUPT) {
21
+ return;
22
+ }
23
+ }
24
+ }
25
+ }
@@ -0,0 +1,19 @@
1
+ import {isFunction, Obj, Index} from '../../common';
2
+
3
+ /**
4
+ * Returns an object indexed by the values from a specific field of each item
5
+ * or from a function that is executed on each item
6
+ * @param arr - array of objects
7
+ * @param fieldOrFn - the name of the field from which the index value should be taken,
8
+ * or the function that should return the index value
9
+ */
10
+ export function indexBy<T extends Obj>(arr: T[], fieldOrFn: string | ((item: T) => string)): Index<T> {
11
+ const result: Index<T> = {};
12
+ arr.forEach(item => {
13
+ const key = isFunction(fieldOrFn) ? fieldOrFn(item) : item[fieldOrFn];
14
+ if (key) {
15
+ result[key] = item;
16
+ }
17
+ });
18
+ return result;
19
+ }
@@ -0,0 +1,11 @@
1
+ export {at} from './at/at';
2
+ export {within} from './within/within';
3
+ export {pluck} from './pluck/pluck';
4
+ export {indexBy} from './index-by/index-by';
5
+ export {fill} from './fill/fill';
6
+ export {diffArr, ArrDiff} from './diff-arr/diff-arr';
7
+ export {forEachArr} from './for-each-arr/for-each-arr';
8
+ export {
9
+ cnd, MatchConditionFn, MatchConditionIs, MatchConditionOr, MatchConditionNot, MatchConditionEqual,
10
+ MatchConditionOrEqual, MatchConditionNotEqual, MatchConditionObj, MatchConditionsByFields, MatchConditions,
11
+ } from './cnd/cnd';
@@ -0,0 +1,14 @@
1
+ import {Obj} from '../../common';
2
+
3
+ /**
4
+ * Returns an array with values, each of which corresponds to the value of a certain array item field
5
+ * @param arr - array of objects
6
+ * @param fieldName - name of the array item field from which the value is to be taken
7
+ */
8
+ export function pluck<T extends Obj, F extends keyof T>(arr: T[], fieldName: F): (T[F])[] {
9
+ const result: (T[F])[] = [];
10
+ arr.forEach(item => {
11
+ result.push(item[fieldName]);
12
+ });
13
+ return result;
14
+ }
@@ -0,0 +1,14 @@
1
+ import {at} from '../';
2
+
3
+ /**
4
+ * Returns an array item by index.
5
+ * If the index is greater than the array length,
6
+ * then the array item will be obtained like remainder of division the index by the array length.
7
+ * For negative indexes, returns items from the end
8
+ * @param arr - any array
9
+ * @param index - an array item index
10
+ */
11
+ export function within<T>(arr: T[], index: number): T | undefined {
12
+ const max = arr.length;
13
+ return at(arr, ((index + 1) % max || max) - 1);
14
+ }