@bitfiber/utils 1.1.1 → 1.1.2
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.
- package/CONTRIBUTING.md +26 -17
- package/LICENSE.txt +1 -1
- package/README.md +46 -36
- package/dist/cjs/arr/at/at.js +7 -7
- package/dist/cjs/arr/at/at.js.map +1 -1
- package/dist/cjs/arr/cnd/cnd.js +94 -94
- package/dist/cjs/arr/cnd/cnd.js.map +1 -1
- package/dist/cjs/arr/diff-arr/diff-arr.js +33 -33
- package/dist/cjs/arr/diff-arr/diff-arr.js.map +1 -1
- package/dist/cjs/arr/fill/fill.js +7 -7
- package/dist/cjs/arr/for-each-arr/for-each-arr.js +21 -21
- package/dist/cjs/arr/for-each-arr/for-each-arr.js.map +1 -1
- package/dist/cjs/arr/index-by/index-by.js +15 -15
- package/dist/cjs/arr/index-by/index-by.js.map +1 -1
- package/dist/cjs/arr/index.js +19 -19
- package/dist/cjs/arr/pluck/pluck.js +11 -11
- package/dist/cjs/arr/within/within.js +9 -9
- package/dist/cjs/common/copy/copy.js +83 -83
- package/dist/cjs/common/copy/copy.js.map +1 -1
- package/dist/cjs/common/equals/equals.js +119 -119
- package/dist/cjs/common/equals/equals.js.map +1 -1
- package/dist/cjs/common/error.js +13 -13
- package/dist/cjs/common/error.js.map +1 -1
- package/dist/cjs/common/for-each/for-each.js +36 -36
- package/dist/cjs/common/for-each/for-each.js.map +1 -1
- package/dist/cjs/common/get-unique-num-id/get-unique-num-id.js +8 -8
- package/dist/cjs/common/get-unique-str-id/get-unique-str-id.js +10 -10
- package/dist/cjs/common/get-unique-str-id/get-unique-str-id.js.map +1 -1
- package/dist/cjs/common/has-iterator/has-iterator.js +7 -7
- package/dist/cjs/common/index.js +61 -61
- package/dist/cjs/common/interrupt.js +4 -4
- package/dist/cjs/common/is/is.js +130 -128
- package/dist/cjs/common/is/is.js.map +1 -1
- package/dist/cjs/common/is-empty/is-empty.js +28 -28
- package/dist/cjs/common/is-empty/is-empty.js.map +1 -1
- package/dist/cjs/common/random/random.js +9 -8
- package/dist/cjs/common/random/random.js.map +1 -1
- package/dist/cjs/common/same/same.js +7 -7
- package/dist/cjs/common/stub/stub.js +7 -7
- package/dist/cjs/common/to-float/to-float.js +9 -9
- package/dist/cjs/common/to-int/to-int.js +9 -9
- package/dist/cjs/common/to-sorted-string/to-sorted-string.js +52 -52
- package/dist/cjs/common/to-sorted-string/to-sorted-string.js.map +1 -1
- package/dist/cjs/common/types.js +2 -2
- package/dist/cjs/dom/closest/closest.js +20 -24
- package/dist/cjs/dom/closest/closest.js.map +1 -1
- package/dist/cjs/dom/document/document.js +18 -18
- package/dist/cjs/dom/document/document.js.map +1 -1
- package/dist/cjs/dom/download-file/download-file.js +27 -29
- package/dist/cjs/dom/download-file/download-file.js.map +1 -1
- package/dist/cjs/dom/for-each-elements/for-each-elements.js +12 -12
- package/dist/cjs/dom/for-each-elements/for-each-elements.js.map +1 -1
- package/dist/cjs/dom/for-each-nodes/for-each-nodes.js +12 -12
- package/dist/cjs/dom/for-each-nodes/for-each-nodes.js.map +1 -1
- package/dist/cjs/dom/get-all-styles/get-all-styles.js +9 -9
- package/dist/cjs/dom/get-body/get-body.js +9 -9
- package/dist/cjs/dom/get-html/get-html.js +9 -9
- package/dist/cjs/dom/get-non-static-parent/get-non-static-parent.js +8 -8
- package/dist/cjs/dom/get-offset-from-doc/get-offset-from-doc.js +17 -17
- package/dist/cjs/dom/get-offset-from-parent/get-offset-from-parent.js +41 -41
- package/dist/cjs/dom/get-offset-from-parent/get-offset-from-parent.js.map +1 -1
- package/dist/cjs/dom/get-offset-from-win/get-offset-from-win.js +7 -7
- package/dist/cjs/dom/get-scroll-width/get-scroll-width.js +28 -27
- package/dist/cjs/dom/get-scroll-width/get-scroll-width.js.map +1 -1
- package/dist/cjs/dom/get-style/get-style.js +21 -21
- package/dist/cjs/dom/get-style/get-style.js.map +1 -1
- package/dist/cjs/dom/get-styles/get-styles.js +10 -10
- package/dist/cjs/dom/get-valid-style-name/get-valid-style-name.js +39 -39
- package/dist/cjs/dom/get-valid-style-name/get-valid-style-name.js.map +1 -1
- package/dist/cjs/dom/get-window/get-window.js +17 -17
- package/dist/cjs/dom/get-window/get-window.js.map +1 -1
- package/dist/cjs/dom/has-name/has-name.js +7 -7
- package/dist/cjs/dom/index.js +52 -52
- package/dist/cjs/dom/is-comment/is-comment.js +7 -7
- package/dist/cjs/dom/is-element/is-element.js +7 -7
- package/dist/cjs/dom/is-text/is-text.js +7 -7
- package/dist/cjs/dom/set-offset-from-parent/set-offset-from-parent.js +38 -38
- package/dist/cjs/dom/set-offset-from-parent/set-offset-from-parent.js.map +1 -1
- package/dist/cjs/dom/set-style/set-style.js +10 -10
- package/dist/cjs/dom/set-styles/set-styles.js +13 -13
- package/dist/cjs/dom/types.js +2 -2
- package/dist/cjs/env/get-browser/get-browser.js +54 -54
- package/dist/cjs/env/get-browser/get-browser.js.map +1 -1
- package/dist/cjs/env/get-engine/get-engine.js +18 -18
- package/dist/cjs/env/get-engine/get-engine.js.map +1 -1
- package/dist/cjs/env/get-os/get-os.js +32 -32
- package/dist/cjs/env/get-os/get-os.js.map +1 -1
- package/dist/cjs/env/get-platform/get-platform.js +32 -32
- package/dist/cjs/env/get-platform/get-platform.js.map +1 -1
- package/dist/cjs/env/index.js +44 -44
- package/dist/cjs/env/is-browser/is-browser.js +9 -9
- package/dist/cjs/env/is-chrome-like/is-chrome-like.js +9 -9
- package/dist/cjs/env/is-desktop/is-desktop.js +9 -9
- package/dist/cjs/env/is-engine/is-engine.js +9 -9
- package/dist/cjs/env/is-firefox-like/is-firefox-like.js +9 -9
- package/dist/cjs/env/is-mobile/is-mobile.js +9 -9
- package/dist/cjs/env/is-os/is-os.js +9 -9
- package/dist/cjs/env/is-portable/is-portable.js +8 -8
- package/dist/cjs/env/is-safari-like/is-safari-like.js +9 -9
- package/dist/cjs/env/is-stationary/is-stationary.js +8 -8
- package/dist/cjs/env/is-tablet/is-tablet.js +9 -9
- package/dist/cjs/env/is-tv/is-tv.js +9 -9
- package/dist/cjs/env/matches/matches.js +23 -23
- package/dist/cjs/env/matches/matches.js.map +1 -1
- package/dist/cjs/env/matches-with-browsers/matches-with-browsers.js +35 -35
- package/dist/cjs/env/matches-with-browsers/matches-with-browsers.js.map +1 -1
- package/dist/cjs/env/matches-with-version/matches-with-version.js +39 -39
- package/dist/cjs/env/matches-with-version/matches-with-version.js.map +1 -1
- package/dist/cjs/env/private/private.js +58 -58
- package/dist/cjs/env/private/private.js.map +1 -1
- package/dist/cjs/env/types.js +2 -2
- package/dist/cjs/env/user-agent/user-agent.js +24 -24
- package/dist/cjs/env/user-agent/user-agent.js.map +1 -1
- package/dist/cjs/index.js +10 -10
- package/dist/cjs/num/in-range/in-range.js +27 -25
- package/dist/cjs/num/in-range/in-range.js.map +1 -1
- package/dist/cjs/num/index.js +7 -7
- package/dist/cjs/num/round/round.js +8 -8
- package/dist/cjs/obj/constant/constant.js +7 -7
- package/dist/cjs/obj/deep-constant/deep-constant.js +22 -15
- package/dist/cjs/obj/deep-constant/deep-constant.js.map +1 -1
- package/dist/cjs/obj/diff-obj/diff-obj.js +45 -45
- package/dist/cjs/obj/diff-obj/diff-obj.js.map +1 -1
- package/dist/cjs/obj/exclude/exclude.js +15 -15
- package/dist/cjs/obj/exclude/exclude.js.map +1 -1
- package/dist/cjs/obj/extend/extend.js +44 -40
- package/dist/cjs/obj/extend/extend.js.map +1 -1
- package/dist/cjs/obj/for-each-obj/for-each-obj.js +13 -13
- package/dist/cjs/obj/for-each-obj/for-each-obj.js.map +1 -1
- package/dist/cjs/obj/has-own/has-own.js +7 -7
- package/dist/cjs/obj/has-own/has-own.js.map +1 -1
- package/dist/cjs/obj/include/include.js +15 -15
- package/dist/cjs/obj/include/include.js.map +1 -1
- package/dist/cjs/obj/index.js +28 -28
- package/dist/cjs/obj/keys/keys.js +7 -7
- package/dist/cjs/obj/map-obj/map-obj.js +10 -10
- package/dist/cjs/obj/map-obj-to-arr/map-obj-to-arr.js +10 -10
- package/dist/cjs/obj/values/values.js +10 -10
- package/dist/cjs/str/index.js +9 -9
- package/dist/cjs/str/to-camel-case/to-camel-case.js +16 -12
- package/dist/cjs/str/to-camel-case/to-camel-case.js.map +1 -1
- package/dist/cjs/str/to-hash/to-hash.js +17 -18
- package/dist/cjs/str/to-hash/to-hash.js.map +1 -1
- package/dist/cjs/str/with-capital/with-capital.js +7 -7
- package/dist/esm/arr/at/at.js +3 -3
- package/dist/esm/arr/at/at.js.map +1 -1
- package/dist/esm/arr/cnd/cnd.js +90 -90
- package/dist/esm/arr/cnd/cnd.js.map +1 -1
- package/dist/esm/arr/diff-arr/diff-arr.js +29 -29
- package/dist/esm/arr/diff-arr/diff-arr.js.map +1 -1
- package/dist/esm/arr/fill/fill.js +3 -3
- package/dist/esm/arr/for-each-arr/for-each-arr.js +17 -17
- package/dist/esm/arr/for-each-arr/for-each-arr.js.map +1 -1
- package/dist/esm/arr/index-by/index-by.js +11 -11
- package/dist/esm/arr/index-by/index-by.js.map +1 -1
- package/dist/esm/arr/index.js +8 -8
- package/dist/esm/arr/pluck/pluck.js +7 -7
- package/dist/esm/arr/within/within.js +5 -5
- package/dist/esm/common/copy/copy.js +79 -79
- package/dist/esm/common/copy/copy.js.map +1 -1
- package/dist/esm/common/equals/equals.js +115 -115
- package/dist/esm/common/equals/equals.js.map +1 -1
- package/dist/esm/common/error.js +9 -9
- package/dist/esm/common/error.js.map +1 -1
- package/dist/esm/common/for-each/for-each.js +32 -32
- package/dist/esm/common/for-each/for-each.js.map +1 -1
- package/dist/esm/common/get-unique-num-id/get-unique-num-id.js +4 -4
- package/dist/esm/common/get-unique-str-id/get-unique-str-id.js +6 -6
- package/dist/esm/common/get-unique-str-id/get-unique-str-id.js.map +1 -1
- package/dist/esm/common/has-iterator/has-iterator.js +3 -3
- package/dist/esm/common/index.js +16 -16
- package/dist/esm/common/interrupt.js +1 -1
- package/dist/esm/common/is/is.js +100 -98
- package/dist/esm/common/is/is.js.map +1 -1
- package/dist/esm/common/is-empty/is-empty.js +24 -24
- package/dist/esm/common/is-empty/is-empty.js.map +1 -1
- package/dist/esm/common/random/random.js +5 -4
- package/dist/esm/common/random/random.js.map +1 -1
- package/dist/esm/common/same/same.js +3 -3
- package/dist/esm/common/stub/stub.js +3 -3
- package/dist/esm/common/to-float/to-float.js +5 -5
- package/dist/esm/common/to-int/to-int.js +5 -5
- package/dist/esm/common/to-sorted-string/to-sorted-string.js +48 -48
- package/dist/esm/common/to-sorted-string/to-sorted-string.js.map +1 -1
- package/dist/esm/common/types.js +1 -1
- package/dist/esm/dom/closest/closest.js +16 -20
- package/dist/esm/dom/closest/closest.js.map +1 -1
- package/dist/esm/dom/document/document.js +13 -13
- package/dist/esm/dom/document/document.js.map +1 -1
- package/dist/esm/dom/download-file/download-file.js +23 -25
- package/dist/esm/dom/download-file/download-file.js.map +1 -1
- package/dist/esm/dom/for-each-elements/for-each-elements.js +8 -8
- package/dist/esm/dom/for-each-elements/for-each-elements.js.map +1 -1
- package/dist/esm/dom/for-each-nodes/for-each-nodes.js +8 -8
- package/dist/esm/dom/for-each-nodes/for-each-nodes.js.map +1 -1
- package/dist/esm/dom/get-all-styles/get-all-styles.js +5 -5
- package/dist/esm/dom/get-body/get-body.js +5 -5
- package/dist/esm/dom/get-html/get-html.js +5 -5
- package/dist/esm/dom/get-non-static-parent/get-non-static-parent.js +4 -4
- package/dist/esm/dom/get-offset-from-doc/get-offset-from-doc.js +13 -13
- package/dist/esm/dom/get-offset-from-parent/get-offset-from-parent.js +37 -37
- package/dist/esm/dom/get-offset-from-parent/get-offset-from-parent.js.map +1 -1
- package/dist/esm/dom/get-offset-from-win/get-offset-from-win.js +3 -3
- package/dist/esm/dom/get-scroll-width/get-scroll-width.js +24 -23
- package/dist/esm/dom/get-scroll-width/get-scroll-width.js.map +1 -1
- package/dist/esm/dom/get-style/get-style.js +17 -17
- package/dist/esm/dom/get-style/get-style.js.map +1 -1
- package/dist/esm/dom/get-styles/get-styles.js +6 -6
- package/dist/esm/dom/get-valid-style-name/get-valid-style-name.js +35 -35
- package/dist/esm/dom/get-valid-style-name/get-valid-style-name.js.map +1 -1
- package/dist/esm/dom/get-window/get-window.js +13 -13
- package/dist/esm/dom/get-window/get-window.js.map +1 -1
- package/dist/esm/dom/has-name/has-name.js +3 -3
- package/dist/esm/dom/index.js +24 -24
- package/dist/esm/dom/is-comment/is-comment.js +3 -3
- package/dist/esm/dom/is-element/is-element.js +3 -3
- package/dist/esm/dom/is-text/is-text.js +3 -3
- package/dist/esm/dom/set-offset-from-parent/set-offset-from-parent.js +34 -34
- package/dist/esm/dom/set-offset-from-parent/set-offset-from-parent.js.map +1 -1
- package/dist/esm/dom/set-style/set-style.js +6 -6
- package/dist/esm/dom/set-styles/set-styles.js +9 -9
- package/dist/esm/dom/types.js +1 -1
- package/dist/esm/env/get-browser/get-browser.js +49 -49
- package/dist/esm/env/get-browser/get-browser.js.map +1 -1
- package/dist/esm/env/get-engine/get-engine.js +13 -13
- package/dist/esm/env/get-engine/get-engine.js.map +1 -1
- package/dist/esm/env/get-os/get-os.js +27 -27
- package/dist/esm/env/get-os/get-os.js.map +1 -1
- package/dist/esm/env/get-platform/get-platform.js +27 -27
- package/dist/esm/env/get-platform/get-platform.js.map +1 -1
- package/dist/esm/env/index.js +20 -20
- package/dist/esm/env/is-browser/is-browser.js +5 -5
- package/dist/esm/env/is-chrome-like/is-chrome-like.js +5 -5
- package/dist/esm/env/is-desktop/is-desktop.js +5 -5
- package/dist/esm/env/is-engine/is-engine.js +5 -5
- package/dist/esm/env/is-firefox-like/is-firefox-like.js +5 -5
- package/dist/esm/env/is-mobile/is-mobile.js +5 -5
- package/dist/esm/env/is-os/is-os.js +5 -5
- package/dist/esm/env/is-portable/is-portable.js +4 -4
- package/dist/esm/env/is-safari-like/is-safari-like.js +5 -5
- package/dist/esm/env/is-stationary/is-stationary.js +4 -4
- package/dist/esm/env/is-tablet/is-tablet.js +5 -5
- package/dist/esm/env/is-tv/is-tv.js +5 -5
- package/dist/esm/env/matches/matches.js +19 -19
- package/dist/esm/env/matches/matches.js.map +1 -1
- package/dist/esm/env/matches-with-browsers/matches-with-browsers.js +31 -31
- package/dist/esm/env/matches-with-browsers/matches-with-browsers.js.map +1 -1
- package/dist/esm/env/matches-with-version/matches-with-version.js +35 -35
- package/dist/esm/env/matches-with-version/matches-with-version.js.map +1 -1
- package/dist/esm/env/private/private.js +52 -52
- package/dist/esm/env/private/private.js.map +1 -1
- package/dist/esm/env/types.js +1 -1
- package/dist/esm/env/user-agent/user-agent.js +19 -19
- package/dist/esm/env/user-agent/user-agent.js.map +1 -1
- package/dist/esm/index.js +7 -7
- package/dist/esm/num/in-range/in-range.js +23 -21
- package/dist/esm/num/in-range/in-range.js.map +1 -1
- package/dist/esm/num/index.js +2 -2
- package/dist/esm/num/round/round.js +4 -4
- package/dist/esm/obj/constant/constant.js +3 -3
- package/dist/esm/obj/deep-constant/deep-constant.js +18 -11
- package/dist/esm/obj/deep-constant/deep-constant.js.map +1 -1
- package/dist/esm/obj/diff-obj/diff-obj.js +41 -41
- package/dist/esm/obj/diff-obj/diff-obj.js.map +1 -1
- package/dist/esm/obj/exclude/exclude.js +11 -11
- package/dist/esm/obj/exclude/exclude.js.map +1 -1
- package/dist/esm/obj/extend/extend.js +39 -35
- package/dist/esm/obj/extend/extend.js.map +1 -1
- package/dist/esm/obj/for-each-obj/for-each-obj.js +9 -9
- package/dist/esm/obj/for-each-obj/for-each-obj.js.map +1 -1
- package/dist/esm/obj/has-own/has-own.js +3 -3
- package/dist/esm/obj/has-own/has-own.js.map +1 -1
- package/dist/esm/obj/include/include.js +11 -11
- package/dist/esm/obj/include/include.js.map +1 -1
- package/dist/esm/obj/index.js +12 -12
- package/dist/esm/obj/keys/keys.js +3 -3
- package/dist/esm/obj/map-obj/map-obj.js +6 -6
- package/dist/esm/obj/map-obj-to-arr/map-obj-to-arr.js +6 -6
- package/dist/esm/obj/values/values.js +6 -6
- package/dist/esm/str/index.js +3 -3
- package/dist/esm/str/to-camel-case/to-camel-case.js +12 -8
- package/dist/esm/str/to-camel-case/to-camel-case.js.map +1 -1
- package/dist/esm/str/to-hash/to-hash.js +13 -14
- package/dist/esm/str/to-hash/to-hash.js.map +1 -1
- package/dist/esm/str/with-capital/with-capital.js +3 -3
- package/dist/types/arr/at/at.d.ts +7 -7
- package/dist/types/arr/at/at.d.ts.map +1 -1
- package/dist/types/arr/cnd/cnd.d.ts +117 -117
- package/dist/types/arr/cnd/cnd.d.ts.map +1 -1
- package/dist/types/arr/diff-arr/diff-arr.d.ts +30 -30
- package/dist/types/arr/fill/fill.d.ts +8 -8
- package/dist/types/arr/for-each-arr/for-each-arr.d.ts +9 -9
- package/dist/types/arr/index-by/index-by.d.ts +9 -9
- package/dist/types/arr/index.d.ts +8 -8
- package/dist/types/arr/pluck/pluck.d.ts +7 -7
- package/dist/types/arr/within/within.d.ts +9 -9
- package/dist/types/common/copy/copy.d.ts +6 -6
- package/dist/types/common/equals/equals.d.ts +12 -12
- package/dist/types/common/error.d.ts +25 -25
- package/dist/types/common/for-each/for-each.d.ts +9 -9
- package/dist/types/common/get-unique-num-id/get-unique-num-id.d.ts +4 -4
- package/dist/types/common/get-unique-str-id/get-unique-str-id.d.ts +6 -4
- package/dist/types/common/get-unique-str-id/get-unique-str-id.d.ts.map +1 -1
- package/dist/types/common/has-iterator/has-iterator.d.ts +5 -5
- package/dist/types/common/index.d.ts +17 -17
- package/dist/types/common/interrupt.d.ts +4 -4
- package/dist/types/common/is/is.d.ts +136 -136
- package/dist/types/common/is-empty/is-empty.d.ts +6 -6
- package/dist/types/common/random/random.d.ts +7 -5
- package/dist/types/common/random/random.d.ts.map +1 -1
- package/dist/types/common/same/same.d.ts +6 -6
- package/dist/types/common/stub/stub.d.ts +4 -4
- package/dist/types/common/to-float/to-float.d.ts +6 -6
- package/dist/types/common/to-int/to-int.d.ts +6 -6
- package/dist/types/common/to-sorted-string/to-sorted-string.d.ts +7 -7
- package/dist/types/common/types.d.ts +64 -64
- package/dist/types/common/types.d.ts.map +1 -1
- package/dist/types/dom/closest/closest.d.ts +6 -6
- package/dist/types/dom/closest/closest.d.ts.map +1 -1
- package/dist/types/dom/document/document.d.ts +12 -12
- package/dist/types/dom/download-file/download-file.d.ts +7 -7
- package/dist/types/dom/download-file/download-file.d.ts.map +1 -1
- package/dist/types/dom/for-each-elements/for-each-elements.d.ts +8 -8
- package/dist/types/dom/for-each-nodes/for-each-nodes.d.ts +7 -7
- package/dist/types/dom/get-all-styles/get-all-styles.d.ts +5 -5
- package/dist/types/dom/get-body/get-body.d.ts +4 -4
- package/dist/types/dom/get-html/get-html.d.ts +4 -4
- package/dist/types/dom/get-non-static-parent/get-non-static-parent.d.ts +5 -5
- package/dist/types/dom/get-offset-from-doc/get-offset-from-doc.d.ts +6 -6
- package/dist/types/dom/get-offset-from-parent/get-offset-from-parent.d.ts +7 -7
- package/dist/types/dom/get-offset-from-win/get-offset-from-win.d.ts +6 -6
- package/dist/types/dom/get-scroll-width/get-scroll-width.d.ts +8 -8
- package/dist/types/dom/get-scroll-width/get-scroll-width.d.ts.map +1 -1
- package/dist/types/dom/get-style/get-style.d.ts +6 -6
- package/dist/types/dom/get-styles/get-styles.d.ts +9 -9
- package/dist/types/dom/get-valid-style-name/get-valid-style-name.d.ts +6 -6
- package/dist/types/dom/get-window/get-window.d.ts +4 -4
- package/dist/types/dom/has-name/has-name.d.ts +6 -6
- package/dist/types/dom/index.d.ts +25 -25
- package/dist/types/dom/is-comment/is-comment.d.ts +5 -5
- package/dist/types/dom/is-element/is-element.d.ts +5 -5
- package/dist/types/dom/is-text/is-text.d.ts +5 -5
- package/dist/types/dom/set-offset-from-parent/set-offset-from-parent.d.ts +8 -8
- package/dist/types/dom/set-style/set-style.d.ts +8 -8
- package/dist/types/dom/set-styles/set-styles.d.ts +8 -8
- package/dist/types/dom/types.d.ts +19 -19
- package/dist/types/env/get-browser/get-browser.d.ts +10 -10
- package/dist/types/env/get-engine/get-engine.d.ts +7 -7
- package/dist/types/env/get-os/get-os.d.ts +8 -8
- package/dist/types/env/get-platform/get-platform.d.ts +7 -7
- package/dist/types/env/index.d.ts +21 -21
- package/dist/types/env/is-browser/is-browser.d.ts +11 -11
- package/dist/types/env/is-chrome-like/is-chrome-like.d.ts +4 -4
- package/dist/types/env/is-desktop/is-desktop.d.ts +4 -4
- package/dist/types/env/is-engine/is-engine.d.ts +8 -8
- package/dist/types/env/is-firefox-like/is-firefox-like.d.ts +4 -4
- package/dist/types/env/is-mobile/is-mobile.d.ts +4 -4
- package/dist/types/env/is-os/is-os.d.ts +9 -9
- package/dist/types/env/is-portable/is-portable.d.ts +4 -4
- package/dist/types/env/is-safari-like/is-safari-like.d.ts +4 -4
- package/dist/types/env/is-stationary/is-stationary.d.ts +4 -4
- package/dist/types/env/is-tablet/is-tablet.d.ts +4 -4
- package/dist/types/env/is-tv/is-tv.d.ts +4 -4
- package/dist/types/env/matches/matches.d.ts +34 -34
- package/dist/types/env/matches-with-browsers/matches-with-browsers.d.ts +23 -23
- package/dist/types/env/matches-with-version/matches-with-version.d.ts +6 -6
- package/dist/types/env/private/private.d.ts +4 -4
- package/dist/types/env/types.d.ts +106 -106
- package/dist/types/env/types.d.ts.map +1 -1
- package/dist/types/env/user-agent/user-agent.d.ts +9 -9
- package/dist/types/index.d.ts +7 -7
- package/dist/types/num/in-range/in-range.d.ts +31 -31
- package/dist/types/num/in-range/in-range.d.ts.map +1 -1
- package/dist/types/num/index.d.ts +2 -2
- package/dist/types/num/round/round.d.ts +7 -7
- package/dist/types/obj/constant/constant.d.ts +6 -6
- package/dist/types/obj/deep-constant/deep-constant.d.ts +7 -6
- package/dist/types/obj/deep-constant/deep-constant.d.ts.map +1 -1
- package/dist/types/obj/diff-obj/diff-obj.d.ts +37 -37
- package/dist/types/obj/exclude/exclude.d.ts +7 -7
- package/dist/types/obj/extend/extend.d.ts +18 -16
- package/dist/types/obj/extend/extend.d.ts.map +1 -1
- package/dist/types/obj/for-each-obj/for-each-obj.d.ts +8 -8
- package/dist/types/obj/has-own/has-own.d.ts +8 -8
- package/dist/types/obj/has-own/has-own.d.ts.map +1 -1
- package/dist/types/obj/include/include.d.ts +7 -7
- package/dist/types/obj/index.d.ts +12 -12
- package/dist/types/obj/keys/keys.d.ts +6 -6
- package/dist/types/obj/map-obj/map-obj.d.ts +7 -7
- package/dist/types/obj/map-obj-to-arr/map-obj-to-arr.d.ts +7 -7
- package/dist/types/obj/values/values.d.ts +6 -6
- package/dist/types/str/index.d.ts +3 -3
- package/dist/types/str/to-camel-case/to-camel-case.d.ts +10 -10
- package/dist/types/str/to-camel-case/to-camel-case.d.ts.map +1 -1
- package/dist/types/str/to-hash/to-hash.d.ts +7 -7
- package/dist/types/str/to-hash/to-hash.d.ts.map +1 -1
- package/dist/types/str/with-capital/with-capital.d.ts +6 -6
- package/package.json +10 -10
- package/src/arr/at/at.ts +1 -2
- package/src/arr/diff-arr/diff-arr.ts +1 -1
- package/src/common/error.ts +2 -2
- package/src/common/get-unique-str-id/get-unique-str-id.ts +2 -0
- package/src/common/is/is.ts +2 -2
- package/src/common/is-empty/is-empty.ts +1 -1
- package/src/common/random/random.ts +6 -3
- package/src/dom/closest/closest.ts +4 -5
- package/src/dom/download-file/download-file.ts +3 -2
- package/src/dom/get-offset-from-parent/get-offset-from-parent.ts +2 -2
- package/src/dom/get-scroll-width/get-scroll-width.ts +3 -2
- package/src/dom/get-style/get-style.ts +3 -3
- package/src/dom/set-offset-from-parent/set-offset-from-parent.ts +3 -3
- package/src/env/matches-with-browsers/matches-with-browsers.ts +1 -1
- package/src/num/in-range/in-range.ts +3 -1
- package/src/obj/deep-constant/deep-constant.ts +12 -4
- package/src/obj/extend/extend.ts +11 -3
- package/src/obj/has-own/has-own.ts +1 -2
- package/src/str/to-camel-case/to-camel-case.ts +7 -1
- package/src/str/to-hash/to-hash.ts +1 -2
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Obj, ValueUnion } from '../../common';
|
|
2
|
-
/**
|
|
3
|
-
* Returns a new object, which has the mapped values of object fields
|
|
4
|
-
* @param obj - any object
|
|
5
|
-
* @param handler - function called for each field
|
|
6
|
-
*/
|
|
7
|
-
export declare function mapObj<T extends Obj, K extends keyof T, R>(obj: T, handler: (value: ValueUnion<T>, key: K, obj: T) => R): Record<K, R>;
|
|
1
|
+
import { Obj, ValueUnion } from '../../common';
|
|
2
|
+
/**
|
|
3
|
+
* Returns a new object, which has the mapped values of object fields
|
|
4
|
+
* @param obj - any object
|
|
5
|
+
* @param handler - function called for each field
|
|
6
|
+
*/
|
|
7
|
+
export declare function mapObj<T extends Obj, K extends keyof T, R>(obj: T, handler: (value: ValueUnion<T>, key: K, obj: T) => R): Record<K, R>;
|
|
8
8
|
//# sourceMappingURL=map-obj.d.ts.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Obj, ValueUnion } from '../../common';
|
|
2
|
-
/**
|
|
3
|
-
* Returns an array, which has the mapped values of object fields
|
|
4
|
-
* @param obj - any object
|
|
5
|
-
* @param handler - function called for each field
|
|
6
|
-
*/
|
|
7
|
-
export declare function mapObjToArr<T extends Obj, K extends keyof T, R>(obj: T, handler: (value: ValueUnion<T>, key: K, obj: T) => R): R[];
|
|
1
|
+
import { Obj, ValueUnion } from '../../common';
|
|
2
|
+
/**
|
|
3
|
+
* Returns an array, which has the mapped values of object fields
|
|
4
|
+
* @param obj - any object
|
|
5
|
+
* @param handler - function called for each field
|
|
6
|
+
*/
|
|
7
|
+
export declare function mapObjToArr<T extends Obj, K extends keyof T, R>(obj: T, handler: (value: ValueUnion<T>, key: K, obj: T) => R): R[];
|
|
8
8
|
//# sourceMappingURL=map-obj-to-arr.d.ts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Obj } from '../../common';
|
|
2
|
-
/**
|
|
3
|
-
* Returns an array of values for each object's own enumerable property
|
|
4
|
-
* @param obj - any object
|
|
5
|
-
*/
|
|
6
|
-
export declare function values<T>(obj: Obj<T>): T[];
|
|
1
|
+
import { Obj } from '../../common';
|
|
2
|
+
/**
|
|
3
|
+
* Returns an array of values for each object's own enumerable property
|
|
4
|
+
* @param obj - any object
|
|
5
|
+
*/
|
|
6
|
+
export declare function values<T>(obj: Obj<T>): T[];
|
|
7
7
|
//# sourceMappingURL=values.d.ts.map
|
|
@@ -1,4 +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';
|
|
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
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Converts a given string into camelCase format.
|
|
3
|
-
* CamelCase is a convention where a multi-word identifier is formed by joining words together,
|
|
4
|
-
* each starting with a capital letter except for the initial word.
|
|
5
|
-
* This function takes a string as input, which may be in various formats such as snake_case,
|
|
6
|
-
* kebab-case, or space-separated words, and transforms it into camelCase.
|
|
7
|
-
* @param str - the input string that needs to be converted to camelCase
|
|
8
|
-
* @param separators - an array of any separators, default '-', '_', ' '
|
|
9
|
-
*/
|
|
10
|
-
export declare function toCamelCase(str: string, separators?: string[]): string;
|
|
1
|
+
/**
|
|
2
|
+
* Converts a given string into camelCase format.
|
|
3
|
+
* CamelCase is a convention where a multi-word identifier is formed by joining words together,
|
|
4
|
+
* each starting with a capital letter except for the initial word.
|
|
5
|
+
* This function takes a string as input, which may be in various formats such as snake_case,
|
|
6
|
+
* kebab-case, or space-separated words, and transforms it into camelCase.
|
|
7
|
+
* @param str - the input string that needs to be converted to camelCase
|
|
8
|
+
* @param separators - an array of any separators, default '-', '_', ' '
|
|
9
|
+
*/
|
|
10
|
+
export declare function toCamelCase(str: string, separators?: string[]): string;
|
|
11
11
|
//# sourceMappingURL=to-camel-case.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-camel-case.d.ts","sourceRoot":"","sources":["../../../../src/str/to-camel-case/to-camel-case.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"to-camel-case.d.ts","sourceRoot":"","sources":["../../../../src/str/to-camel-case/to-camel-case.ts"],"names":[],"mappings":"AAMA;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,GAAE,MAAM,EAAoB,GAAG,MAAM,CAOvF"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generates a hash value for a given input string for insecure purposes
|
|
3
|
-
* Hash functions are commonly used to convert input data into a fixed-length string of characters,
|
|
4
|
-
* providing a unique representation of the input
|
|
5
|
-
* @param str - The input string to be hashed
|
|
6
|
-
*/
|
|
7
|
-
export declare function toHash(str: string): string;
|
|
1
|
+
/**
|
|
2
|
+
* Generates a hash value for a given input string for insecure purposes
|
|
3
|
+
* Hash functions are commonly used to convert input data into a fixed-length string of characters,
|
|
4
|
+
* providing a unique representation of the input
|
|
5
|
+
* @param str - The input string to be hashed
|
|
6
|
+
*/
|
|
7
|
+
export declare function toHash(str: string): string;
|
|
8
8
|
//# sourceMappingURL=to-hash.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-hash.d.ts","sourceRoot":"","sources":["../../../../src/str/to-hash/to-hash.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"to-hash.d.ts","sourceRoot":"","sources":["../../../../src/str/to-hash/to-hash.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAa1C"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Takes a string as input and returns a new string with the initial letter in uppercase,
|
|
3
|
-
* while preserving the rest of the string
|
|
4
|
-
* @param str - The input string whose first letter needs to be capitalized
|
|
5
|
-
*/
|
|
6
|
-
export declare function withCapital(str: string): string;
|
|
1
|
+
/**
|
|
2
|
+
* Takes a string as input and returns a new string with the initial letter in uppercase,
|
|
3
|
+
* while preserving the rest of the string
|
|
4
|
+
* @param str - The input string whose first letter needs to be capitalized
|
|
5
|
+
*/
|
|
6
|
+
export declare function withCapital(str: string): string;
|
|
7
7
|
//# sourceMappingURL=with-capital.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bitfiber/utils",
|
|
3
3
|
"description": "Collection of versatile utility functions for Javascript",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.2",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
7
|
-
"
|
|
7
|
+
"es2020": "./dist/esm/index.js",
|
|
8
8
|
"types": "index.d.ts",
|
|
9
9
|
"typesVersions": {
|
|
10
|
-
">=4.
|
|
10
|
+
">=5.4.2": {
|
|
11
11
|
"*": ["dist/types/*"]
|
|
12
12
|
}
|
|
13
13
|
},
|
|
@@ -17,49 +17,49 @@
|
|
|
17
17
|
"types": "./dist/types/index.d.ts",
|
|
18
18
|
"node": "./dist/cjs/index.js",
|
|
19
19
|
"require": "./dist/cjs/index.js",
|
|
20
|
-
"
|
|
20
|
+
"es2020": "./dist/esm/index.js",
|
|
21
21
|
"default": "./dist/esm/index.js"
|
|
22
22
|
},
|
|
23
23
|
"./arr": {
|
|
24
24
|
"types": "./dist/types/arr/index.d.ts",
|
|
25
25
|
"node": "./dist/cjs/arr/index.js",
|
|
26
26
|
"require": "./dist/cjs/arr/index.js",
|
|
27
|
-
"
|
|
27
|
+
"es2020": "./dist/esm/arr/index.js",
|
|
28
28
|
"default": "./dist/esm/arr/index.js"
|
|
29
29
|
},
|
|
30
30
|
"./obj": {
|
|
31
31
|
"types": "./dist/types/obj/index.d.ts",
|
|
32
32
|
"node": "./dist/cjs/obj/index.js",
|
|
33
33
|
"require": "./dist/cjs/obj/index.js",
|
|
34
|
-
"
|
|
34
|
+
"es2020": "./dist/esm/obj/index.js",
|
|
35
35
|
"default": "./dist/esm/obj/index.js"
|
|
36
36
|
},
|
|
37
37
|
"./str": {
|
|
38
38
|
"types": "./dist/types/str/index.d.ts",
|
|
39
39
|
"node": "./dist/cjs/str/index.js",
|
|
40
40
|
"require": "./dist/cjs/str/index.js",
|
|
41
|
-
"
|
|
41
|
+
"es2020": "./dist/esm/str/index.js",
|
|
42
42
|
"default": "./dist/esm/str/index.js"
|
|
43
43
|
},
|
|
44
44
|
"./num": {
|
|
45
45
|
"types": "./dist/types/num/index.d.ts",
|
|
46
46
|
"node": "./dist/cjs/num/index.js",
|
|
47
47
|
"require": "./dist/cjs/num/index.js",
|
|
48
|
-
"
|
|
48
|
+
"es2020": "./dist/esm/num/index.js",
|
|
49
49
|
"default": "./dist/esm/num/index.js"
|
|
50
50
|
},
|
|
51
51
|
"./dom": {
|
|
52
52
|
"types": "./dist/types/dom/index.d.ts",
|
|
53
53
|
"node": "./dist/cjs/dom/index.js",
|
|
54
54
|
"require": "./dist/cjs/dom/index.js",
|
|
55
|
-
"
|
|
55
|
+
"es2020": "./dist/esm/dom/index.js",
|
|
56
56
|
"default": "./dist/esm/dom/index.js"
|
|
57
57
|
},
|
|
58
58
|
"./env": {
|
|
59
59
|
"types": "./dist/types/env/index.d.ts",
|
|
60
60
|
"node": "./dist/cjs/env/index.js",
|
|
61
61
|
"require": "./dist/cjs/env/index.js",
|
|
62
|
-
"
|
|
62
|
+
"es2020": "./dist/esm/env/index.js",
|
|
63
63
|
"default": "./dist/esm/env/index.js"
|
|
64
64
|
},
|
|
65
65
|
"./package.json": "./package.json"
|
package/src/arr/at/at.ts
CHANGED
|
@@ -29,7 +29,7 @@ export interface ArrDiff<T> {
|
|
|
29
29
|
/**
|
|
30
30
|
* Returns the difference between two arrays
|
|
31
31
|
* Strict comparison of array items is applied
|
|
32
|
-
* The order doesn't matter
|
|
32
|
+
* The order doesn't matter, duplicate values are ignored
|
|
33
33
|
* @param arr1 - array 1
|
|
34
34
|
* @param arr2 - array 2
|
|
35
35
|
*/
|
package/src/common/error.ts
CHANGED
|
@@ -25,8 +25,8 @@ export class BfError extends Error {
|
|
|
25
25
|
*/
|
|
26
26
|
readonly data?: any;
|
|
27
27
|
|
|
28
|
-
constructor(
|
|
29
|
-
super(
|
|
28
|
+
constructor(message?: string, options?: BfErrorOptions) {
|
|
29
|
+
super(message);
|
|
30
30
|
this.name = 'BfError';
|
|
31
31
|
this.code = options?.code;
|
|
32
32
|
this.data = options?.data;
|
|
@@ -12,6 +12,8 @@ const salt = random(7);
|
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Returns a unique string identifier for the current session
|
|
15
|
+
* @note Uses Math.random for salt generation which is NOT cryptographically secure.
|
|
16
|
+
* Do not use for security-sensitive purposes such as tokens or passwords
|
|
15
17
|
*/
|
|
16
18
|
export function getUniqueStrId(): string {
|
|
17
19
|
return `${salt}${++counter}`;
|
package/src/common/is/is.ts
CHANGED
|
@@ -225,8 +225,8 @@ export function isTypedArray(value: any): value is TypedArr {
|
|
|
225
225
|
case Uint8ClampedArray:
|
|
226
226
|
case Uint16Array:
|
|
227
227
|
case Uint32Array:
|
|
228
|
-
|
|
229
|
-
|
|
228
|
+
case BigInt64Array:
|
|
229
|
+
case BigUint64Array:
|
|
230
230
|
return true;
|
|
231
231
|
default:
|
|
232
232
|
return false;
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
import {hasOwn} from '../../obj';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Returns true if the value is empty (null, undefined,
|
|
7
|
+
* Returns true if the value is empty (null, undefined, '', {}, [], Int32Array(), Set(), Map()),
|
|
8
8
|
* otherwise false
|
|
9
9
|
* @param value - anything
|
|
10
10
|
*/
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Returns a random integer between 0 and
|
|
2
|
+
* Returns a random integer between 0 and 10^numberOfDigits - 1
|
|
3
|
+
* @note Uses Math.random which is NOT cryptographically secure.
|
|
4
|
+
* Do not use for security-sensitive purposes such as tokens or passwords
|
|
3
5
|
* @param numberOfDigits - number of digits (default: 7, maximum: 15)
|
|
4
6
|
*/
|
|
5
7
|
export function random(numberOfDigits = 7): number {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
+
const MAX_DIGITS = 15;
|
|
9
|
+
numberOfDigits = numberOfDigits <= MAX_DIGITS ? numberOfDigits : MAX_DIGITS;
|
|
10
|
+
return Math.floor(Math.random() * Math.pow(10, numberOfDigits));
|
|
8
11
|
}
|
|
@@ -5,19 +5,18 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export function closest(element: HTMLElement, selectors: string | HTMLElement): HTMLElement | null {
|
|
7
7
|
let currentElem: HTMLElement | null = element;
|
|
8
|
+
const isElement = selectors instanceof Element;
|
|
8
9
|
|
|
9
10
|
while (currentElem) {
|
|
10
|
-
if (
|
|
11
|
+
if (isElement) {
|
|
11
12
|
if (currentElem === selectors) {
|
|
12
13
|
return currentElem;
|
|
13
|
-
} else {
|
|
14
|
-
currentElem = currentElem.parentElement;
|
|
15
14
|
}
|
|
16
15
|
} else if (currentElem.matches(selectors)) {
|
|
17
16
|
return currentElem;
|
|
18
|
-
} else {
|
|
19
|
-
currentElem = currentElem.parentElement;
|
|
20
17
|
}
|
|
18
|
+
|
|
19
|
+
currentElem = currentElem.parentElement;
|
|
21
20
|
}
|
|
22
21
|
|
|
23
22
|
return null;
|
|
@@ -14,13 +14,14 @@ export async function downloadFile(url: string, fetchOptions?: RequestInit): Pro
|
|
|
14
14
|
const doc = getDocument();
|
|
15
15
|
const win = getWindow();
|
|
16
16
|
const body = getBody();
|
|
17
|
-
const
|
|
17
|
+
const objectUrl = win.URL.createObjectURL(blob);
|
|
18
18
|
const link = doc.createElement('a');
|
|
19
|
-
link.href =
|
|
19
|
+
link.href = objectUrl;
|
|
20
20
|
link.download = 'downloaded_file';
|
|
21
21
|
body.appendChild(link);
|
|
22
22
|
link.click();
|
|
23
23
|
body.removeChild(link);
|
|
24
|
+
win.setTimeout(() => win.URL.revokeObjectURL?.(objectUrl), 100);
|
|
24
25
|
return blob;
|
|
25
26
|
} else {
|
|
26
27
|
return Promise.reject(new BfError(
|
|
@@ -44,9 +44,9 @@ export function getOffsetFromParent(element: HTMLElement): Offset {
|
|
|
44
44
|
// Subtract the element's margin so that the element is correctly placed relative to its parent
|
|
45
45
|
return {
|
|
46
46
|
top: offset.top - parentOffset.top - toFloat(getStyle(element, 'marginTop')),
|
|
47
|
-
bottom: offset.bottom - parentOffset.bottom - toFloat(getStyle(element, '
|
|
47
|
+
bottom: offset.bottom - parentOffset.bottom - toFloat(getStyle(element, 'marginBottom')),
|
|
48
48
|
left: offset.left - parentOffset.left - toFloat(getStyle(element, 'marginLeft')),
|
|
49
|
-
right: offset.right - parentOffset.right - toFloat(getStyle(element, '
|
|
49
|
+
right: offset.right - parentOffset.right - toFloat(getStyle(element, 'marginRight')),
|
|
50
50
|
width: offset.width,
|
|
51
51
|
height: offset.height,
|
|
52
52
|
};
|
|
@@ -15,15 +15,16 @@ export function getScrollWidth(element?: HTMLElement): {y: number; x: number} {
|
|
|
15
15
|
const clientHeight2 = element.clientHeight;
|
|
16
16
|
|
|
17
17
|
setStyle(element, 'overflow', originalValue);
|
|
18
|
+
const SCROLLBAR_BORDER_ADJUSTMENT = 1;
|
|
18
19
|
let y = clientWidth1 - clientWidth2;
|
|
19
20
|
let x = clientHeight1 - clientHeight2;
|
|
20
21
|
|
|
21
22
|
if (y > 0) {
|
|
22
|
-
y +=
|
|
23
|
+
y += SCROLLBAR_BORDER_ADJUSTMENT;
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
if (x > 0) {
|
|
26
|
-
x +=
|
|
27
|
+
x += SCROLLBAR_BORDER_ADJUSTMENT;
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
return {
|
|
@@ -10,12 +10,12 @@ const validStyleValues: Index<[string, string]> = {
|
|
|
10
10
|
/**
|
|
11
11
|
* Returns certain computed style value of a given HTML element
|
|
12
12
|
* @param element - any HTML element
|
|
13
|
-
* @param styleName - any style name
|
|
13
|
+
* @param styleName - any style name in camelCase or dashed format
|
|
14
14
|
*/
|
|
15
15
|
export function getStyle(element: HTMLElement, styleName: string): string {
|
|
16
|
-
const styles = getAllStyles(element)
|
|
16
|
+
const styles = getAllStyles(element) as unknown as Record<string, string>;
|
|
17
17
|
const validName = getValidStyleName(styleName);
|
|
18
|
-
const value = styles
|
|
18
|
+
const value = styles[validName] ?? '';
|
|
19
19
|
|
|
20
20
|
if (validStyleValues[validName] && value === validStyleValues[validName][0]) {
|
|
21
21
|
return validStyleValues[validName][1];
|
|
@@ -8,8 +8,8 @@ import {TopLeft, getOffsetFromParent, setStyle, getStyle, setStyles} from '../';
|
|
|
8
8
|
* @param offset - top and left position relative to the parent HTML element
|
|
9
9
|
*/
|
|
10
10
|
export function setOffsetFromParent(element: HTMLElement, offset: Partial<TopLeft>): void {
|
|
11
|
-
let top
|
|
12
|
-
let left
|
|
11
|
+
let top: number;
|
|
12
|
+
let left: number;
|
|
13
13
|
let styleTop = getStyle(element, 'top');
|
|
14
14
|
let styleLeft = getStyle(element, 'left');
|
|
15
15
|
const position = getStyle(element, 'position');
|
|
@@ -22,7 +22,7 @@ export function setOffsetFromParent(element: HTMLElement, offset: Partial<TopLef
|
|
|
22
22
|
setStyle(element, 'position', 'relative');
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
// If top or left is auto, need calculate real top and left relative to a non-static parent
|
|
25
|
+
// If top or left is auto, need to calculate real top and left relative to a non-static parent
|
|
26
26
|
if ((position === 'absolute' || position === 'fixed')
|
|
27
27
|
&& (styleTop === 'auto' || styleLeft === 'auto')) {
|
|
28
28
|
const offsetFromParent = getOffsetFromParent(element);
|
|
@@ -9,7 +9,7 @@ import {BrowsersCondition, getEngine, isBrowser, isEngine} from '../';
|
|
|
9
9
|
* {
|
|
10
10
|
* browserName?: versionCondition(x.x...x | [~ >= > <= <]x.x...x),
|
|
11
11
|
* engines?: engineName | {
|
|
12
|
-
*
|
|
12
|
+
* engineName: versionCondition(x.x...x | [~ >= > <= <]x.x...x)
|
|
13
13
|
* ...
|
|
14
14
|
* }
|
|
15
15
|
* ...
|
|
@@ -51,7 +51,9 @@ export function inRange(value: number | Nullish, options: InRangeOptions = {}):
|
|
|
51
51
|
newValue = options.max;
|
|
52
52
|
}
|
|
53
53
|
} else if (options.required) {
|
|
54
|
-
newValue =
|
|
54
|
+
newValue = isNumber(options.min)
|
|
55
|
+
? options.min
|
|
56
|
+
: (isNumber(options.max) && options.max < 0 ? options.max : 0);
|
|
55
57
|
}
|
|
56
58
|
|
|
57
59
|
return newValue;
|
|
@@ -2,17 +2,25 @@ import {isObject, Obj} from '../../common';
|
|
|
2
2
|
import {constant} from '../';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* Makes an object and its nested objects read-only
|
|
5
|
+
* Makes an object and its nested objects read-only.
|
|
6
|
+
* Objects that have been visited will be ignored to prevent looping
|
|
6
7
|
* @param obj - any object
|
|
7
8
|
*/
|
|
8
9
|
export function deepConstant<T extends Obj>(obj: T): Readonly<T> {
|
|
9
|
-
|
|
10
|
+
return _deepConstant(obj, new Set<Obj>());
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function _deepConstant<T extends Obj>(obj: T, visited: Set<Obj>): Readonly<T> {
|
|
14
|
+
if (visited.has(obj)) {
|
|
15
|
+
return obj;
|
|
16
|
+
}
|
|
17
|
+
visited.add(obj);
|
|
18
|
+
|
|
10
19
|
const fields = Object.getOwnPropertyNames(obj);
|
|
11
20
|
|
|
12
|
-
// Makes nested objects read-only
|
|
13
21
|
fields.forEach(key => {
|
|
14
22
|
if (isObject(obj[key])) {
|
|
15
|
-
|
|
23
|
+
_deepConstant(obj[key], visited);
|
|
16
24
|
}
|
|
17
25
|
});
|
|
18
26
|
|
package/src/obj/extend/extend.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import {copy, isDefined, isUsualObject, Obj, ValueIntersection} from '../../common';
|
|
2
2
|
import {forEachObj} from '../';
|
|
3
3
|
|
|
4
|
+
const UNSAFE_KEYS = new Set(['__proto__', 'constructor', 'prototype']);
|
|
5
|
+
|
|
4
6
|
/**
|
|
5
7
|
* Copies all enumerable own properties from one or more source objects to a target object.
|
|
6
|
-
* It returns the modified target object
|
|
8
|
+
* It returns the modified target object.
|
|
9
|
+
* Keys __proto__, constructor and prototype are skipped to prevent prototype pollution
|
|
7
10
|
* @param target - target object
|
|
8
11
|
* @param sources - source objects
|
|
9
12
|
*/
|
|
@@ -16,8 +19,9 @@ export function extend<T extends Obj, U extends Obj[]>(
|
|
|
16
19
|
|
|
17
20
|
/**
|
|
18
21
|
* Copies all enumerable own properties from one or more source objects to a target object
|
|
19
|
-
* and copies enumerable properties from nested source objects to nested target objects
|
|
20
|
-
* It returns the modified target object
|
|
22
|
+
* and copies enumerable properties from nested source objects to nested target objects.
|
|
23
|
+
* It returns the modified target object.
|
|
24
|
+
* Keys __proto__, constructor and prototype are skipped to prevent prototype pollution
|
|
21
25
|
* @param target - target object
|
|
22
26
|
* @param sources - source objects
|
|
23
27
|
*/
|
|
@@ -35,6 +39,10 @@ function _extend<T extends Obj, U extends Obj[]>(target: T, sources: U, deep: bo
|
|
|
35
39
|
visited.set(obj, true);
|
|
36
40
|
|
|
37
41
|
forEachObj(obj, (value, key) => {
|
|
42
|
+
if (UNSAFE_KEYS.has(key as string)) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
38
46
|
const descriptor = Object.getOwnPropertyDescriptor(obj, key);
|
|
39
47
|
|
|
40
48
|
if (descriptor?.get || descriptor?.set) {
|
|
@@ -7,6 +7,5 @@ import {Obj, NumStrSym} from '../../common';
|
|
|
7
7
|
* @param property
|
|
8
8
|
*/
|
|
9
9
|
export function hasOwn(obj: Obj, property: NumStrSym): boolean {
|
|
10
|
-
|
|
11
|
-
return Object.prototype.hasOwnProperty.call(obj, property);
|
|
10
|
+
return Object.hasOwn(obj, property as string | symbol);
|
|
12
11
|
}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
const REGEX_SPECIAL_CHARS = /[.*+?^${}()|[\]\\]/g;
|
|
2
|
+
|
|
3
|
+
function escapeRegExp(str: string): string {
|
|
4
|
+
return str.replace(REGEX_SPECIAL_CHARS, '\\$&');
|
|
5
|
+
}
|
|
6
|
+
|
|
1
7
|
/**
|
|
2
8
|
* Converts a given string into camelCase format.
|
|
3
9
|
* CamelCase is a convention where a multi-word identifier is formed by joining words together,
|
|
@@ -9,7 +15,7 @@
|
|
|
9
15
|
*/
|
|
10
16
|
export function toCamelCase(str: string, separators: string[] = ['-', '_', ' ']): string {
|
|
11
17
|
return separators.reduce((acc: string, separator: string) => {
|
|
12
|
-
const reg = new RegExp(separator + '([\\da-z])', 'gi');
|
|
18
|
+
const reg = new RegExp(escapeRegExp(separator) + '([\\da-z])', 'gi');
|
|
13
19
|
return acc.replace(reg, (all: string, letter: string) => {
|
|
14
20
|
return letter.toUpperCase();
|
|
15
21
|
});
|
|
@@ -10,8 +10,7 @@ export function toHash(str: string): string {
|
|
|
10
10
|
|
|
11
11
|
for (let i = 0; i < str.length; i++) {
|
|
12
12
|
const char = str.charCodeAt(i);
|
|
13
|
-
hash = ((hash << 5) - hash) + char;
|
|
14
|
-
hash = hash & hash;
|
|
13
|
+
hash = (((hash << 5) - hash) + char) | 0;
|
|
15
14
|
}
|
|
16
15
|
|
|
17
16
|
return hash < 0 ? 'hn' + Math.abs(hash) : 'hp' + hash;
|