@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,38 @@
1
+ import {BrowserData} from '../';
2
+ import {EnvCondition} from '../types';
3
+ import {getBot, getEnvData} from '../private/private';
4
+
5
+ let browser: BrowserData | null = null;
6
+
7
+ const browserConditions: EnvCondition[] = [
8
+ ['opera', '(?:opera|opr\\/|opios)'], ['operaCoast', 'coast\\/'], ['operaTouch', 'opt\\/'],
9
+ ['samsung', 'SamsungBrowser'], ['mz', 'MZBrowser'], ['yandex', 'YaBrowser'], ['uc', 'UcBrowser'],
10
+ ['maxthon', '(?:Maxthon|mxios)'], ['kmeleon', 'k-meleon'], ['wechat', 'MicroMessenger'], ['qqLite', 'qqBrowserLite'],
11
+ ['qq', 'qqBrowser'], ['edge', 'edg(?:[ea/]|ios)'], ['sailfish', 'sailfish\\s?(?:browser)?'],
12
+ ['webOS', 'w(?:eb)?[o0]sbrowser'], ['tizen', 'tizen\\s?(?:browser)?'], ['miui', 'MiuiBrowser'], 'silk', 'phantomjs',
13
+ 'slimerjs', 'qupzilla', 'electron', 'whale', 'focus', 'swing', 'epiphany', 'puffin', 'sleipnir', 'vivaldi',
14
+ 'seamonkey', ['playstation4', 'playstation 4'], ['playstation5', 'playstation 5'], ['googleSearch', 'GSA'],
15
+ ['firefox', '(?:firefox|FxiOS)'], ['chrome', '(?:chrome|chromium|crios|crmo)'], 'android',
16
+ ['safari', '(?:safari|AppleWebKit)'],
17
+ ];
18
+
19
+ /**
20
+ * Returns information about the browser.
21
+ * Possible browser names: opera | operaCoast | operaTouch | samsung | mz | yandex | uc | maxthon | kmeleon
22
+ * | wechat | qqLite | qq | edge | sailfish | webOS | tizen | miui | silk | phantomjs | slimerjs | qupzilla
23
+ * | electron | whale | focus | swing | epiphany | puffin | sleipnir | vivaldi | seamonkey | playstation4
24
+ * | playstation5 | googleSearch | firefox | chrome | android | safari | unknown | BotNames
25
+ */
26
+ export function getBrowser(): BrowserData {
27
+ const bot = getBot();
28
+ browser ??= bot.name !== 'unknown' ? {...bot} : <BrowserData>getEnvData(browserConditions, true);
29
+ return <BrowserData>browser;
30
+ }
31
+
32
+ /*
33
+ * @internal
34
+ * For internal use
35
+ */
36
+ export function resetBrowser(): void {
37
+ browser = null;
38
+ }
@@ -0,0 +1,27 @@
1
+ import {EngineData} from '../';
2
+ import {EnvCondition} from '../types';
3
+ import {getBot, getEnvData} from '../private/private';
4
+
5
+ let engine: EngineData | null = null;
6
+
7
+ const engineConditions: EnvCondition[] = [
8
+ ['gecko', 'firefox'], ['blink', 'chrome'], ['webkit', '(?:safari|AppleWebKit)'],
9
+ ];
10
+
11
+ /**
12
+ * Returns information about the browser engine.
13
+ * Possible engine names: blink (Chrome like) | webkit (Safari like) | gecko (Firefox like) | unknown | BotNames
14
+ */
15
+ export function getEngine(): EngineData {
16
+ const bot = getBot();
17
+ engine ??= bot.name !== 'unknown' ? {...bot} : <EngineData>getEnvData(engineConditions, true);
18
+ return engine;
19
+ }
20
+
21
+ /*
22
+ * @internal
23
+ * For internal use
24
+ */
25
+ export function resetEngine(): void {
26
+ engine = null;
27
+ }
@@ -0,0 +1,31 @@
1
+ import {OSData} from '../';
2
+ import {EnvCondition} from '../types';
3
+ import {getBot, getEnvData} from '../private/private';
4
+
5
+ let os: OSData | null = null;
6
+
7
+ const osConditions: EnvCondition[] = [
8
+ 'xbox', ['windows', 'Windows (?:NT|XP)'], ['ios', '(?:iphone|ipad|FxiOS)', 'OS'], ['macOS', 'Macintosh', 'Mac OS X'],
9
+ ['webOS', '(?:web|hpw)[o0]s'], 'tizen', ['appleTV', 'apple[\\s_-]?TV', 'OS'], ['roku', 'Roku[\\w]{0,8}/DVP'],
10
+ ['chromeOS', 'CrOS(?: x86_64)?'], ['playstation4', 'PlayStation 4'], ['playstation5', 'PlayStation 5'],
11
+ ['nintendoSwitch', 'Nintendo Switch'], ['likeAndroid', 'like android'], 'android', ['linux', 'linux', 'rv:'],
12
+ ];
13
+
14
+ /**
15
+ * Returns information about the OS
16
+ * Possible OS names: xbox | windows | ios | macOS | webOS | tizen | appleTV | roku | chromeOS
17
+ * | playstation4 | playstation5 | nintendoSwitch | likeAndroid | android | linux | unknown | BotNames
18
+ */
19
+ export function getOS(): OSData {
20
+ const bot = getBot();
21
+ os ??= bot.name !== 'unknown' ? {...bot} : <OSData>getEnvData(osConditions, true);
22
+ return os;
23
+ }
24
+
25
+ /*
26
+ * @internal
27
+ * For internal use
28
+ */
29
+ export function resetOS(): void {
30
+ os = null;
31
+ }
@@ -0,0 +1,34 @@
1
+ import {getOS, PlatformNames} from '../';
2
+ import {EnvCondition} from '../types';
3
+ import {getBot, getEnvData} from '../private/private';
4
+
5
+ let platform: PlatformNames | null = null;
6
+
7
+ const platformConditions: EnvCondition[] = [
8
+ [
9
+ 'tv', [
10
+ () => ['tizen', 'webOS', 'appleTV', 'roku', 'xbox', 'playstation4', 'playstation5'].includes(getOS().name),
11
+ '(?:smart|web|google|hbb)[\\s:_/-]?tv', 'bravia',
12
+ ],
13
+ ], ['desktop', [() => ['macOS', 'chromeOS', 'windows', 'linux'].includes(getOS().name)]],
14
+ ['tablet', [() => ['nintendoSwitch'].includes(getOS().name), 'ipad', 'silk', 'tablet']],
15
+ ['mobile', ['iphone', 'android.*?mobi(?:le)?']], ['tablet', 'android'],
16
+ ];
17
+
18
+ /**
19
+ * Returns the name of the platform
20
+ * @returns tv | desktop | tablet | mobile | unknown | BotNames
21
+ */
22
+ export function getPlatform(): PlatformNames {
23
+ const bot = getBot();
24
+ platform ??= bot.name !== 'unknown' ? bot.name : <PlatformNames>getEnvData(platformConditions).name;
25
+ return <PlatformNames>platform;
26
+ }
27
+
28
+ /*
29
+ * @internal
30
+ * For internal use
31
+ */
32
+ export function resetPlatform(): void {
33
+ platform = null;
34
+ }
@@ -0,0 +1,24 @@
1
+ export {
2
+ BotNames, PlatformNames, OSNames, EngineNames, BrowserNames, VersionData, OSData, EngineData, BrowserData,
3
+ EnginesCondition, BrowsersCondition, OSBrowsersCondition, OSCondition, PlatformsCondition,
4
+ } from './types';
5
+ export {getUserAgent, setUserAgent} from './user-agent/user-agent';
6
+ export {getOS} from './get-os/get-os';
7
+ export {getEngine} from './get-engine/get-engine';
8
+ export {getPlatform} from './get-platform/get-platform';
9
+ export {getBrowser} from './get-browser/get-browser';
10
+ export {matchesWithVersion} from './matches-with-version/matches-with-version';
11
+ export {isTV} from './is-tv/is-tv';
12
+ export {isDesktop} from './is-desktop/is-desktop';
13
+ export {isTablet} from './is-tablet/is-tablet';
14
+ export {isMobile} from './is-mobile/is-mobile';
15
+ export {isPortable} from './is-portable/is-portable';
16
+ export {isStationary} from './is-stationary/is-stationary';
17
+ export {isChromeLike} from './is-chrome-like/is-chrome-like';
18
+ export {isFirefoxLike} from './is-firefox-like/is-firefox-like';
19
+ export {isSafariLike} from './is-safari-like/is-safari-like';
20
+ export {isOS} from './is-os/is-os';
21
+ export {isEngine} from './is-engine/is-engine';
22
+ export {isBrowser} from './is-browser/is-browser';
23
+ export {matchesWithBrowsers} from './matches-with-browsers/matches-with-browsers';
24
+ export {matches} from './matches/matches';
@@ -0,0 +1,15 @@
1
+ import {BrowserNames, getBrowser, matchesWithVersion} from '../';
2
+
3
+ /**
4
+ * Returns true if the name matches the browser name and the version matches the browser version, otherwise false
5
+ * @param name - one of the browser names:
6
+ * opera | operaCoast | operaTouch | samsung | mz | yandex | uc | maxthon | kmeleon
7
+ * | wechat | qqLite | qq | edge | sailfish | webOS | tizen | miui | silk | phantomjs | slimerjs | qupzilla
8
+ * | electron | whale | focus | swing | epiphany | puffin | sleipnir | vivaldi | seamonkey | playstation4
9
+ * | playstation5 | googleSearch | firefox | chrome | android | safari | unknown | BotNames
10
+ * @param version - string condition in the format: x.x...x | [~ >= > <= <]x.x...x
11
+ */
12
+ export function isBrowser(name: BrowserNames, version?: string): boolean {
13
+ const browser = getBrowser();
14
+ return browser.name === name && (!version || matchesWithVersion(browser.version, version));
15
+ }
@@ -0,0 +1,9 @@
1
+ import {getEngine} from '../';
2
+
3
+ /**
4
+ * Returns true if the browser uses the Blink engine like Chrome, false otherwise
5
+ */
6
+ export function isChromeLike(): boolean {
7
+ const name = getEngine().name;
8
+ return name === 'blink';
9
+ }
@@ -0,0 +1,9 @@
1
+ import {getPlatform} from '../';
2
+
3
+ /**
4
+ * Returns true if the platform is desktop, otherwise false
5
+ */
6
+ export function isDesktop(): boolean {
7
+ const name = getPlatform();
8
+ return name === 'desktop';
9
+ }
@@ -0,0 +1,12 @@
1
+ import {EngineNames, getEngine, matchesWithVersion} from '../';
2
+
3
+ /**
4
+ * Returns true if the name matches the engine name and the version matches the engine version, otherwise false
5
+ * @param name - one of the engine names:
6
+ * blink (Chrome like) | webkit (Safari like) | gecko (Firefox like) | unknown | BotNames
7
+ * @param version - string condition in the format: x.x...x | [~ >= > <= <]x.x...x
8
+ */
9
+ export function isEngine(name: EngineNames, version?: string): boolean {
10
+ const engine = getEngine();
11
+ return engine.name === name && (!version || matchesWithVersion(engine.version, version));
12
+ }
@@ -0,0 +1,9 @@
1
+ import {getEngine} from '../';
2
+
3
+ /**
4
+ * Returns true if the browser uses the Gecko engine like FireFox, false otherwise
5
+ */
6
+ export function isFirefoxLike(): boolean {
7
+ const name = getEngine().name;
8
+ return name === 'gecko';
9
+ }
@@ -0,0 +1,9 @@
1
+ import {getPlatform} from '../';
2
+
3
+ /**
4
+ * Returns true if the platform is mobile, otherwise false
5
+ */
6
+ export function isMobile(): boolean {
7
+ const name = getPlatform();
8
+ return name === 'mobile';
9
+ }
@@ -0,0 +1,13 @@
1
+ import {getOS, matchesWithVersion, OSNames} from '../';
2
+
3
+ /**
4
+ * Returns true if the name matches the OS name and the version matches the OS version, otherwise false
5
+ * @param name - one of the OS names:
6
+ * xbox | windows | ios | macOS | webOS | tizen | appleTV | roku | chromeOS
7
+ * | playstation4 | playstation5 | nintendoSwitch | likeAndroid | android | linux | unknown | BotNames
8
+ * @param version - string condition in the format: x.x...x | [~ >= > <= <]x.x...x
9
+ */
10
+ export function isOS(name: OSNames, version?: string): boolean {
11
+ const os = getOS();
12
+ return os.name === name && (!version || matchesWithVersion(os.version, version));
13
+ }
@@ -0,0 +1,8 @@
1
+ import {isMobile, isTablet} from '../';
2
+
3
+ /**
4
+ * Returns true if the platform is mobile or tablet, otherwise false
5
+ */
6
+ export function isPortable(): boolean {
7
+ return isMobile() || isTablet();
8
+ }
@@ -0,0 +1,9 @@
1
+ import {getEngine} from '../';
2
+
3
+ /**
4
+ * Returns true if the browser uses the WebKit engine like Safari, false otherwise
5
+ */
6
+ export function isSafariLike(): boolean {
7
+ const name = getEngine().name;
8
+ return name === 'webkit';
9
+ }
@@ -0,0 +1,8 @@
1
+ import {isDesktop, isTV} from '../';
2
+
3
+ /**
4
+ * Returns true if the platform is desktop or TV, otherwise false
5
+ */
6
+ export function isStationary(): boolean {
7
+ return isTV() || isDesktop();
8
+ }
@@ -0,0 +1,9 @@
1
+ import {getPlatform} from '../';
2
+
3
+ /**
4
+ * Returns true if the platform is tablet, otherwise false
5
+ */
6
+ export function isTablet(): boolean {
7
+ const name = getPlatform();
8
+ return name === 'tablet';
9
+ }
@@ -0,0 +1,9 @@
1
+ import {getPlatform} from '../';
2
+
3
+ /**
4
+ * Returns true if the platform is TV, otherwise false
5
+ */
6
+ export function isTV(): boolean {
7
+ const name = getPlatform();
8
+ return name === 'tv';
9
+ }
@@ -0,0 +1,55 @@
1
+ import {INTERRUPT} from '../../common';
2
+ import {exclude, forEachObj} from '../../obj';
3
+ import {getPlatform, isOS, matchesWithBrowsers, PlatformsCondition} from '../';
4
+
5
+ /**
6
+ * Checks if a current browser matches a specific set of conditions
7
+ *
8
+ * Condition structure:
9
+ * {
10
+ * [platformName | anyPlatform]: {
11
+ * [osName | anyOS]: {
12
+ * osVersion?: versionCondition(x.x...x | [~ >= > <= <]x.x...x),
13
+ * browserName?: versionCondition(x.x...x | [~ >= > <= <]x.x...x),
14
+ * engines?: engineName | {
15
+ * engineName: versionCondition(x.x...x | [~ >= > <= <]x.x...x)
16
+ * ...
17
+ * }
18
+ * ...
19
+ * }
20
+ * ...
21
+ * }
22
+ * ...
23
+ * }
24
+ *
25
+ * @example
26
+ * matches({anyPlatform: {anyOS: {chrome: ''}}});
27
+ * matches({desktop: {windows: {chrome: '96.0.4664.110'}}});
28
+ * matches({desktop: {windows: {osVersion: '~10', engines: 'blink'}}});
29
+ * matches({desktop: {anyOS: {engines: {blink: '>90.5', gecko: '<=100'}}}});
30
+ * matches({anyPlatform: {ios: {chrome: '~96.1', safari: '>80'}}});
31
+ *
32
+ * @param condition - an object that has keys corresponding to platform names
33
+ * and values corresponding to objects that have keys corresponding to OS names
34
+ * and values corresponding to objects that have keys corresponding to browser names
35
+ * and values corresponding to browser versions
36
+ */
37
+ export function matches(condition: PlatformsCondition): boolean {
38
+ let result = false;
39
+
40
+ forEachObj(condition, (oss, platform) => {
41
+ if (oss && (platform === 'anyPlatform' || platform === getPlatform())) {
42
+ forEachObj(oss, (browsers, osName) => {
43
+ const osVersion = browsers?.osVersion;
44
+ if (browsers && (osName === 'anyOS' || isOS(osName, osVersion))) {
45
+ result = matchesWithBrowsers(exclude(browsers, 'osVersion'));
46
+ }
47
+ return result && INTERRUPT;
48
+ });
49
+ }
50
+
51
+ return result && INTERRUPT;
52
+ });
53
+
54
+ return result;
55
+ }
@@ -0,0 +1,55 @@
1
+ import {INTERRUPT, isObject, isString} from '../../common';
2
+ import {forEachObj} from '../../obj';
3
+ import {BrowsersCondition, getEngine, isBrowser, isEngine} from '../';
4
+
5
+ /**
6
+ * Checks if a current browser matches a specific set of browsers
7
+ *
8
+ * Condition structure:
9
+ * {
10
+ * browserName?: versionCondition(x.x...x | [~ >= > <= <]x.x...x),
11
+ * engines?: engineName | {
12
+ * engineNane: versionCondition(x.x...x | [~ >= > <= <]x.x...x)
13
+ * ...
14
+ * }
15
+ * ...
16
+ * }
17
+ *
18
+ * @example
19
+ * matchesWithBrowsers({firefox: '>=95.5', chrome: '~96.0.4664'});
20
+ * matchesWithBrowsers({engines: 'gecko', firefox: '>100.1'});
21
+ * matchesWithBrowsers({engines: {blink: '~96', gecko: '110.5.0'}, firefox: '>100.1'});
22
+ *
23
+ * @param condition - an object that has keys corresponding to browser names
24
+ * and values corresponding to browser version conditions
25
+ */
26
+ export function matchesWithBrowsers(condition: BrowsersCondition): boolean {
27
+ let result = false;
28
+
29
+ forEachObj(condition, (enginesOrVer, browser) => {
30
+ if (browser === 'engines') {
31
+ const {name} = getEngine();
32
+ const engines = enginesOrVer;
33
+
34
+ if (isObject(engines)) {
35
+ forEachObj(engines, (version, engine) => {
36
+ if (isEngine(engine, version)) {
37
+ result = true;
38
+ }
39
+ return result && INTERRUPT;
40
+ });
41
+ } else if (isString(engines) && engines === name) {
42
+ result = true;
43
+ }
44
+ } else {
45
+ const version = <string>enginesOrVer;
46
+ if (isBrowser(browser, version)) {
47
+ result = true;
48
+ }
49
+ }
50
+
51
+ return result && INTERRUPT;
52
+ });
53
+
54
+ return result;
55
+ }
@@ -0,0 +1,44 @@
1
+ import {INTERRUPT} from '../../common';
2
+ import {forEachArr} from '../../arr';
3
+
4
+ /**
5
+ * Checks if a specific version matches a version condition
6
+ * @param version - any browser or OS version, for example: x.x...x
7
+ * @param condition - version condition in the format: x.x...x | [~ >= > <= <]x.x...x
8
+ */
9
+ export function matchesWithVersion(version: string, condition: string): boolean {
10
+ let result = 0;
11
+ const versionParts = version.split('.');
12
+ const conditionParts = condition.split('.');
13
+ const matches = conditionParts[0].match(/^([~><=]*)(\d+)$/i);
14
+ const operator = matches && matches.length ? matches[1] : '';
15
+ conditionParts[0] = matches && matches.length ? matches[2] : '0';
16
+
17
+ forEachArr(conditionParts, (part: string, index: number) => {
18
+ const a = Number(versionParts[index]);
19
+ const b = Number(part);
20
+
21
+ switch (operator) {
22
+ case '~':
23
+ result = a === b ? 1 : -1;
24
+ return result !== -1 || INTERRUPT;
25
+ case '>':
26
+ result = a === b ? 0 : (a > b ? 1 : -1);
27
+ return result === 0 || INTERRUPT;
28
+ case '>=':
29
+ result = a === b || a > b ? 1 : -1;
30
+ return (result !== -1 && !(a > b)) || INTERRUPT;
31
+ case '<':
32
+ result = a === b ? 0 : (a < b ? 1 : -1);
33
+ return result === 0 || INTERRUPT;
34
+ case '<=':
35
+ result = a === b || a < b ? 1 : -1;
36
+ return (result !== -1 && !(a < b)) || INTERRUPT;
37
+ default:
38
+ result = a === b && versionParts.length === conditionParts.length ? 1 : -1;
39
+ return result !== -1 || INTERRUPT;
40
+ }
41
+ });
42
+
43
+ return result === 1;
44
+ }
@@ -0,0 +1,82 @@
1
+ import {isArray, isFunction, isRegExp, isString, isUndefined} from '../../common';
2
+ import {getUserAgent} from '../';
3
+ import {BotData, EnvCondition, EnvData} from '../types';
4
+
5
+ /*
6
+ * Functions for internal use
7
+ */
8
+
9
+ let bot: BotData | null = null;
10
+
11
+ const botConditions: EnvCondition[] = ['googlebot', 'bingbot', 'yandexbot', 'slurp'];
12
+
13
+ /*
14
+ * @internal
15
+ * For internal use
16
+ */
17
+ export function getBot(): BotData {
18
+ return bot ??= <BotData>getEnvData(botConditions);
19
+ }
20
+
21
+ /*
22
+ * @internal
23
+ * For internal use
24
+ */
25
+ export function resetBot(): void {
26
+ bot = null;
27
+ }
28
+
29
+ /*
30
+ * @internal
31
+ * For internal use
32
+ */
33
+ export function getEnvData(conditions: EnvCondition[], needVersion = false): EnvData {
34
+ const agent = getUserAgent();
35
+ const result: EnvData = {
36
+ name: 'unknown',
37
+ version: '',
38
+ major: '',
39
+ };
40
+
41
+ for (const condition of conditions) {
42
+ // eslint-disable-next-line prefer-const
43
+ let [name, test, ver] = isString(condition) ? [condition] : condition;
44
+ const tests = isArray(test) ? test : (isUndefined(test) ? [name] : [test]);
45
+
46
+ if (needVersion) {
47
+ ver = isUndefined(ver) ? getVerRegExp(isString(test) ? test : name) : (isString(ver) ? getVerRegExp(ver) : ver);
48
+ }
49
+
50
+ for (let test of tests) {
51
+ if (isString(test)) {
52
+ test = getTestRegExp(test);
53
+ }
54
+ if ((isFunction(test) && test()) || (isRegExp(test) && agent.search(test) > -1)) {
55
+ result.name = <any>name;
56
+
57
+ if (needVersion && isRegExp(ver)) {
58
+ const matches = agent.match(ver);
59
+ result.version = (matches && matches.length > 1 && matches[1]) || '';
60
+ result.version = result.version.trim().replace(/[\s_-]+/g, '.');
61
+
62
+ if (result.version) {
63
+ result.major = result.version.split('.')[0];
64
+ return result;
65
+ }
66
+ }
67
+
68
+ return result;
69
+ }
70
+ }
71
+ }
72
+
73
+ return result;
74
+ }
75
+
76
+ function getTestRegExp(name: string): RegExp {
77
+ return new RegExp(name, 'i');
78
+ }
79
+
80
+ function getVerRegExp(name: string): RegExp {
81
+ return new RegExp(`${name}(?:[\\s:;/-]?ver(?:sion)?)?[\\s:/-]?(\\d+(?:[_.-]\\d+)*)`, 'i');
82
+ }