@nberlette/math 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -0
- package/README.md +889 -0
- package/cjs/abs.d.ts +14 -0
- package/cjs/abs.d.ts.map +1 -0
- package/cjs/abs.js +22 -0
- package/cjs/abs.js.map +1 -0
- package/cjs/acos.d.ts +17 -0
- package/cjs/acos.d.ts.map +1 -0
- package/cjs/acos.js +27 -0
- package/cjs/acos.js.map +1 -0
- package/cjs/acosh.d.ts +11 -0
- package/cjs/acosh.d.ts.map +1 -0
- package/cjs/acosh.js +35 -0
- package/cjs/acosh.js.map +1 -0
- package/cjs/asin.d.ts +11 -0
- package/cjs/asin.d.ts.map +1 -0
- package/cjs/asin.js +28 -0
- package/cjs/asin.js.map +1 -0
- package/cjs/asinh.d.ts +9 -0
- package/cjs/asinh.d.ts.map +1 -0
- package/cjs/asinh.js +26 -0
- package/cjs/asinh.js.map +1 -0
- package/cjs/atan.d.ts +11 -0
- package/cjs/atan.d.ts.map +1 -0
- package/cjs/atan.js +65 -0
- package/cjs/atan.js.map +1 -0
- package/cjs/atan2.d.ts +12 -0
- package/cjs/atan2.d.ts.map +1 -0
- package/cjs/atan2.js +70 -0
- package/cjs/atan2.js.map +1 -0
- package/cjs/atanh.d.ts +11 -0
- package/cjs/atanh.d.ts.map +1 -0
- package/cjs/atanh.js +32 -0
- package/cjs/atanh.js.map +1 -0
- package/cjs/cbrt.d.ts +9 -0
- package/cjs/cbrt.d.ts.map +1 -0
- package/cjs/cbrt.js +26 -0
- package/cjs/cbrt.js.map +1 -0
- package/cjs/ceil.d.ts +15 -0
- package/cjs/ceil.d.ts.map +1 -0
- package/cjs/ceil.js +34 -0
- package/cjs/ceil.js.map +1 -0
- package/cjs/clamp.d.ts +15 -0
- package/cjs/clamp.d.ts.map +1 -0
- package/cjs/clamp.js +32 -0
- package/cjs/clamp.js.map +1 -0
- package/cjs/clz32.d.ts +20 -0
- package/cjs/clz32.d.ts.map +1 -0
- package/cjs/clz32.js +48 -0
- package/cjs/clz32.js.map +1 -0
- package/cjs/constants/e.d.ts +17 -0
- package/cjs/constants/e.d.ts.map +1 -0
- package/cjs/constants/e.js +19 -0
- package/cjs/constants/e.js.map +1 -0
- package/cjs/constants/epsilon.d.ts +24 -0
- package/cjs/constants/epsilon.d.ts.map +1 -0
- package/cjs/constants/epsilon.js +26 -0
- package/cjs/constants/epsilon.js.map +1 -0
- package/cjs/constants/index.d.ts +23 -0
- package/cjs/constants/index.d.ts.map +1 -0
- package/cjs/constants/index.js +39 -0
- package/cjs/constants/index.js.map +1 -0
- package/cjs/constants/infinity.d.ts +3 -0
- package/cjs/constants/infinity.d.ts.map +1 -0
- package/cjs/constants/infinity.js +19 -0
- package/cjs/constants/infinity.js.map +1 -0
- package/cjs/constants/ln10.d.ts +10 -0
- package/cjs/constants/ln10.d.ts.map +1 -0
- package/cjs/constants/ln10.js +12 -0
- package/cjs/constants/ln10.js.map +1 -0
- package/cjs/constants/ln2.d.ts +10 -0
- package/cjs/constants/ln2.d.ts.map +1 -0
- package/cjs/constants/ln2.js +12 -0
- package/cjs/constants/ln2.js.map +1 -0
- package/cjs/constants/log10e.d.ts +10 -0
- package/cjs/constants/log10e.d.ts.map +1 -0
- package/cjs/constants/log10e.js +12 -0
- package/cjs/constants/log10e.js.map +1 -0
- package/cjs/constants/log2e.d.ts +10 -0
- package/cjs/constants/log2e.d.ts.map +1 -0
- package/cjs/constants/log2e.js +12 -0
- package/cjs/constants/log2e.js.map +1 -0
- package/cjs/constants/max_safe_integer.d.ts +11 -0
- package/cjs/constants/max_safe_integer.d.ts.map +1 -0
- package/cjs/constants/max_safe_integer.js +13 -0
- package/cjs/constants/max_safe_integer.js.map +1 -0
- package/cjs/constants/max_value.d.ts +10 -0
- package/cjs/constants/max_value.d.ts.map +1 -0
- package/cjs/constants/max_value.js +12 -0
- package/cjs/constants/max_value.js.map +1 -0
- package/cjs/constants/min_safe_integer.d.ts +12 -0
- package/cjs/constants/min_safe_integer.d.ts.map +1 -0
- package/cjs/constants/min_safe_integer.js +14 -0
- package/cjs/constants/min_safe_integer.js.map +1 -0
- package/cjs/constants/min_value.d.ts +10 -0
- package/cjs/constants/min_value.d.ts.map +1 -0
- package/cjs/constants/min_value.js +12 -0
- package/cjs/constants/min_value.js.map +1 -0
- package/cjs/constants/nan.d.ts +47 -0
- package/cjs/constants/nan.d.ts.map +1 -0
- package/cjs/constants/nan.js +30 -0
- package/cjs/constants/nan.js.map +1 -0
- package/cjs/constants/negative_infinity.d.ts +28 -0
- package/cjs/constants/negative_infinity.d.ts.map +1 -0
- package/cjs/constants/negative_infinity.js +15 -0
- package/cjs/constants/negative_infinity.js.map +1 -0
- package/cjs/constants/negative_zero.d.ts +31 -0
- package/cjs/constants/negative_zero.d.ts.map +1 -0
- package/cjs/constants/negative_zero.js +21 -0
- package/cjs/constants/negative_zero.js.map +1 -0
- package/cjs/constants/pi.d.ts +10 -0
- package/cjs/constants/pi.d.ts.map +1 -0
- package/cjs/constants/pi.js +12 -0
- package/cjs/constants/pi.js.map +1 -0
- package/cjs/constants/positive_infinity.d.ts +29 -0
- package/cjs/constants/positive_infinity.d.ts.map +1 -0
- package/cjs/constants/positive_infinity.js +16 -0
- package/cjs/constants/positive_infinity.js.map +1 -0
- package/cjs/constants/positive_zero.d.ts +38 -0
- package/cjs/constants/positive_zero.d.ts.map +1 -0
- package/cjs/constants/positive_zero.js +36 -0
- package/cjs/constants/positive_zero.js.map +1 -0
- package/cjs/constants/sqrt1_2.d.ts +9 -0
- package/cjs/constants/sqrt1_2.d.ts.map +1 -0
- package/cjs/constants/sqrt1_2.js +11 -0
- package/cjs/constants/sqrt1_2.js.map +1 -0
- package/cjs/constants/sqrt2.d.ts +9 -0
- package/cjs/constants/sqrt2.d.ts.map +1 -0
- package/cjs/constants/sqrt2.js +11 -0
- package/cjs/constants/sqrt2.js.map +1 -0
- package/cjs/cos.d.ts +10 -0
- package/cjs/cos.d.ts.map +1 -0
- package/cjs/cos.js +32 -0
- package/cjs/cos.js.map +1 -0
- package/cjs/cosh.d.ts +10 -0
- package/cjs/cosh.d.ts.map +1 -0
- package/cjs/cosh.js +21 -0
- package/cjs/cosh.js.map +1 -0
- package/cjs/exp.d.ts +20 -0
- package/cjs/exp.d.ts.map +1 -0
- package/cjs/exp.js +48 -0
- package/cjs/exp.js.map +1 -0
- package/cjs/expm1.d.ts +11 -0
- package/cjs/expm1.d.ts.map +1 -0
- package/cjs/expm1.js +38 -0
- package/cjs/expm1.js.map +1 -0
- package/cjs/f16round.d.ts +24 -0
- package/cjs/f16round.d.ts.map +1 -0
- package/cjs/f16round.js +42 -0
- package/cjs/f16round.js.map +1 -0
- package/cjs/float16/constants.d.ts +97 -0
- package/cjs/float16/constants.d.ts.map +1 -0
- package/cjs/float16/constants.js +99 -0
- package/cjs/float16/constants.js.map +1 -0
- package/cjs/float16/decode.d.ts +40 -0
- package/cjs/float16/decode.d.ts.map +1 -0
- package/cjs/float16/decode.js +67 -0
- package/cjs/float16/decode.js.map +1 -0
- package/cjs/float16/encode.d.ts +67 -0
- package/cjs/float16/encode.d.ts.map +1 -0
- package/cjs/float16/encode.js +77 -0
- package/cjs/float16/encode.js.map +1 -0
- package/cjs/float16/guards.d.ts +22 -0
- package/cjs/float16/guards.d.ts.map +1 -0
- package/cjs/float16/guards.js +15 -0
- package/cjs/float16/guards.js.map +1 -0
- package/cjs/float16/index.d.ts +11 -0
- package/cjs/float16/index.d.ts.map +1 -0
- package/cjs/float16/index.js +27 -0
- package/cjs/float16/index.js.map +1 -0
- package/cjs/float16/round.d.ts +25 -0
- package/cjs/float16/round.d.ts.map +1 -0
- package/cjs/float16/round.js +46 -0
- package/cjs/float16/round.js.map +1 -0
- package/cjs/float32/constants.d.ts +96 -0
- package/cjs/float32/constants.d.ts.map +1 -0
- package/cjs/float32/constants.js +98 -0
- package/cjs/float32/constants.js.map +1 -0
- package/cjs/float32/decode.d.ts +38 -0
- package/cjs/float32/decode.d.ts.map +1 -0
- package/cjs/float32/decode.js +70 -0
- package/cjs/float32/decode.js.map +1 -0
- package/cjs/float32/encode.d.ts +50 -0
- package/cjs/float32/encode.d.ts.map +1 -0
- package/cjs/float32/encode.js +77 -0
- package/cjs/float32/encode.js.map +1 -0
- package/cjs/float32/guards.d.ts +37 -0
- package/cjs/float32/guards.d.ts.map +1 -0
- package/cjs/float32/guards.js +20 -0
- package/cjs/float32/guards.js.map +1 -0
- package/cjs/float32/index.d.ts +11 -0
- package/cjs/float32/index.d.ts.map +1 -0
- package/cjs/float32/index.js +27 -0
- package/cjs/float32/index.js.map +1 -0
- package/cjs/float32/round.d.ts +23 -0
- package/cjs/float32/round.d.ts.map +1 -0
- package/cjs/float32/round.js +36 -0
- package/cjs/float32/round.js.map +1 -0
- package/cjs/floor.d.ts +10 -0
- package/cjs/floor.d.ts.map +1 -0
- package/cjs/floor.js +32 -0
- package/cjs/floor.js.map +1 -0
- package/cjs/fround.d.ts +23 -0
- package/cjs/fround.d.ts.map +1 -0
- package/cjs/fround.js +35 -0
- package/cjs/fround.js.map +1 -0
- package/cjs/guards/finite.d.ts +23 -0
- package/cjs/guards/finite.d.ts.map +1 -0
- package/cjs/guards/finite.js +21 -0
- package/cjs/guards/finite.js.map +1 -0
- package/cjs/guards/index.d.ts +50 -0
- package/cjs/guards/index.d.ts.map +1 -0
- package/cjs/guards/index.js +66 -0
- package/cjs/guards/index.js.map +1 -0
- package/cjs/guards/infinity.d.ts +3 -0
- package/cjs/guards/infinity.d.ts.map +1 -0
- package/cjs/guards/infinity.js +19 -0
- package/cjs/guards/infinity.js.map +1 -0
- package/cjs/guards/integer.d.ts +47 -0
- package/cjs/guards/integer.d.ts.map +1 -0
- package/cjs/guards/integer.js +23 -0
- package/cjs/guards/integer.js.map +1 -0
- package/cjs/guards/nan.d.ts +61 -0
- package/cjs/guards/nan.d.ts.map +1 -0
- package/cjs/guards/nan.js +68 -0
- package/cjs/guards/nan.js.map +1 -0
- package/cjs/guards/negative_infinity.d.ts +19 -0
- package/cjs/guards/negative_infinity.d.ts.map +1 -0
- package/cjs/guards/negative_infinity.js +25 -0
- package/cjs/guards/negative_infinity.js.map +1 -0
- package/cjs/guards/negative_zero.d.ts +12 -0
- package/cjs/guards/negative_zero.d.ts.map +1 -0
- package/cjs/guards/negative_zero.js +24 -0
- package/cjs/guards/negative_zero.js.map +1 -0
- package/cjs/guards/positive_infinity.d.ts +19 -0
- package/cjs/guards/positive_infinity.d.ts.map +1 -0
- package/cjs/guards/positive_infinity.js +25 -0
- package/cjs/guards/positive_infinity.js.map +1 -0
- package/cjs/guards/positive_zero.d.ts +17 -0
- package/cjs/guards/positive_zero.d.ts.map +1 -0
- package/cjs/guards/positive_zero.js +36 -0
- package/cjs/guards/positive_zero.js.map +1 -0
- package/cjs/guards/safe_integer.d.ts +33 -0
- package/cjs/guards/safe_integer.d.ts.map +1 -0
- package/cjs/guards/safe_integer.js +27 -0
- package/cjs/guards/safe_integer.js.map +1 -0
- package/cjs/hypot.d.ts +18 -0
- package/cjs/hypot.d.ts.map +1 -0
- package/cjs/hypot.js +63 -0
- package/cjs/hypot.js.map +1 -0
- package/cjs/ieee754.d.ts +16 -0
- package/cjs/ieee754.d.ts.map +1 -0
- package/cjs/ieee754.js +32 -0
- package/cjs/ieee754.js.map +1 -0
- package/cjs/imul.d.ts +17 -0
- package/cjs/imul.d.ts.map +1 -0
- package/cjs/imul.js +24 -0
- package/cjs/imul.js.map +1 -0
- package/cjs/index.d.ts +84 -0
- package/cjs/index.d.ts.map +1 -0
- package/cjs/index.js +113 -0
- package/cjs/index.js.map +1 -0
- package/cjs/internal/ieee754.d.ts +174 -0
- package/cjs/internal/ieee754.d.ts.map +1 -0
- package/cjs/internal/ieee754.js +200 -0
- package/cjs/internal/ieee754.js.map +1 -0
- package/cjs/internal/primordials.d.ts +30 -0
- package/cjs/internal/primordials.d.ts.map +1 -0
- package/cjs/internal/primordials.js +30 -0
- package/cjs/internal/primordials.js.map +1 -0
- package/cjs/log.d.ts +9 -0
- package/cjs/log.d.ts.map +1 -0
- package/cjs/log.js +46 -0
- package/cjs/log.js.map +1 -0
- package/cjs/log10.d.ts +9 -0
- package/cjs/log10.d.ts.map +1 -0
- package/cjs/log10.js +21 -0
- package/cjs/log10.js.map +1 -0
- package/cjs/log1p.d.ts +10 -0
- package/cjs/log1p.d.ts.map +1 -0
- package/cjs/log1p.js +32 -0
- package/cjs/log1p.js.map +1 -0
- package/cjs/log2.d.ts +12 -0
- package/cjs/log2.d.ts.map +1 -0
- package/cjs/log2.js +24 -0
- package/cjs/log2.js.map +1 -0
- package/cjs/max.d.ts +22 -0
- package/cjs/max.d.ts.map +1 -0
- package/cjs/max.js +51 -0
- package/cjs/max.js.map +1 -0
- package/cjs/min.d.ts +10 -0
- package/cjs/min.d.ts.map +1 -0
- package/cjs/min.js +36 -0
- package/cjs/min.js.map +1 -0
- package/cjs/package.json +3 -0
- package/cjs/pow.d.ts +31 -0
- package/cjs/pow.d.ts.map +1 -0
- package/cjs/pow.js +36 -0
- package/cjs/pow.js.map +1 -0
- package/cjs/random.d.ts +93 -0
- package/cjs/random.d.ts.map +1 -0
- package/cjs/random.js +242 -0
- package/cjs/random.js.map +1 -0
- package/cjs/round.d.ts +9 -0
- package/cjs/round.d.ts.map +1 -0
- package/cjs/round.js +24 -0
- package/cjs/round.js.map +1 -0
- package/cjs/sign.d.ts +17 -0
- package/cjs/sign.d.ts.map +1 -0
- package/cjs/sign.js +22 -0
- package/cjs/sign.js.map +1 -0
- package/cjs/sin.d.ts +14 -0
- package/cjs/sin.d.ts.map +1 -0
- package/cjs/sin.js +31 -0
- package/cjs/sin.js.map +1 -0
- package/cjs/sinh.d.ts +14 -0
- package/cjs/sinh.d.ts.map +1 -0
- package/cjs/sinh.js +22 -0
- package/cjs/sinh.js.map +1 -0
- package/cjs/sqrt.d.ts +19 -0
- package/cjs/sqrt.d.ts.map +1 -0
- package/cjs/sqrt.js +45 -0
- package/cjs/sqrt.js.map +1 -0
- package/cjs/tan.d.ts +9 -0
- package/cjs/tan.d.ts.map +1 -0
- package/cjs/tan.js +26 -0
- package/cjs/tan.js.map +1 -0
- package/cjs/tanh.d.ts +17 -0
- package/cjs/tanh.d.ts.map +1 -0
- package/cjs/tanh.js +34 -0
- package/cjs/tanh.js.map +1 -0
- package/cjs/trunc.d.ts +21 -0
- package/cjs/trunc.d.ts.map +1 -0
- package/cjs/trunc.js +50 -0
- package/cjs/trunc.js.map +1 -0
- package/cjs/types/finite.d.ts +16 -0
- package/cjs/types/finite.d.ts.map +1 -0
- package/cjs/types/finite.js +4 -0
- package/cjs/types/finite.js.map +1 -0
- package/cjs/types/float.d.ts +65 -0
- package/cjs/types/float.d.ts.map +1 -0
- package/cjs/types/float.js +4 -0
- package/cjs/types/float.js.map +1 -0
- package/cjs/types/index.d.ts +6 -0
- package/cjs/types/index.d.ts.map +1 -0
- package/cjs/types/index.js +22 -0
- package/cjs/types/index.js.map +1 -0
- package/cjs/types/integer.d.ts +147 -0
- package/cjs/types/integer.d.ts.map +1 -0
- package/cjs/types/integer.js +5 -0
- package/cjs/types/integer.js.map +1 -0
- package/cjs/types/precision.d.ts +46 -0
- package/cjs/types/precision.d.ts.map +1 -0
- package/cjs/types/precision.js +9 -0
- package/cjs/types/precision.js.map +1 -0
- package/cjs/types/safe_integer.d.ts +17 -0
- package/cjs/types/safe_integer.d.ts.map +1 -0
- package/cjs/types/safe_integer.js +5 -0
- package/cjs/types/safe_integer.js.map +1 -0
- package/esm/abs.d.ts +14 -0
- package/esm/abs.d.ts.map +1 -0
- package/esm/abs.js +19 -0
- package/esm/abs.js.map +1 -0
- package/esm/acos.d.ts +17 -0
- package/esm/acos.d.ts.map +1 -0
- package/esm/acos.js +24 -0
- package/esm/acos.js.map +1 -0
- package/esm/acosh.d.ts +11 -0
- package/esm/acosh.d.ts.map +1 -0
- package/esm/acosh.js +32 -0
- package/esm/acosh.js.map +1 -0
- package/esm/asin.d.ts +11 -0
- package/esm/asin.d.ts.map +1 -0
- package/esm/asin.js +25 -0
- package/esm/asin.js.map +1 -0
- package/esm/asinh.d.ts +9 -0
- package/esm/asinh.d.ts.map +1 -0
- package/esm/asinh.js +23 -0
- package/esm/asinh.js.map +1 -0
- package/esm/atan.d.ts +11 -0
- package/esm/atan.d.ts.map +1 -0
- package/esm/atan.js +62 -0
- package/esm/atan.js.map +1 -0
- package/esm/atan2.d.ts +12 -0
- package/esm/atan2.d.ts.map +1 -0
- package/esm/atan2.js +67 -0
- package/esm/atan2.js.map +1 -0
- package/esm/atanh.d.ts +11 -0
- package/esm/atanh.d.ts.map +1 -0
- package/esm/atanh.js +29 -0
- package/esm/atanh.js.map +1 -0
- package/esm/cbrt.d.ts +9 -0
- package/esm/cbrt.d.ts.map +1 -0
- package/esm/cbrt.js +23 -0
- package/esm/cbrt.js.map +1 -0
- package/esm/ceil.d.ts +15 -0
- package/esm/ceil.d.ts.map +1 -0
- package/esm/ceil.js +31 -0
- package/esm/ceil.js.map +1 -0
- package/esm/clamp.d.ts +15 -0
- package/esm/clamp.d.ts.map +1 -0
- package/esm/clamp.js +29 -0
- package/esm/clamp.js.map +1 -0
- package/esm/clz32.d.ts +20 -0
- package/esm/clz32.d.ts.map +1 -0
- package/esm/clz32.js +45 -0
- package/esm/clz32.js.map +1 -0
- package/esm/constants/e.d.ts +17 -0
- package/esm/constants/e.d.ts.map +1 -0
- package/esm/constants/e.js +16 -0
- package/esm/constants/e.js.map +1 -0
- package/esm/constants/epsilon.d.ts +24 -0
- package/esm/constants/epsilon.d.ts.map +1 -0
- package/esm/constants/epsilon.js +23 -0
- package/esm/constants/epsilon.js.map +1 -0
- package/esm/constants/index.d.ts +23 -0
- package/esm/constants/index.d.ts.map +1 -0
- package/esm/constants/index.js +23 -0
- package/esm/constants/index.js.map +1 -0
- package/esm/constants/infinity.d.ts +3 -0
- package/esm/constants/infinity.d.ts.map +1 -0
- package/esm/constants/infinity.js +3 -0
- package/esm/constants/infinity.js.map +1 -0
- package/esm/constants/ln10.d.ts +10 -0
- package/esm/constants/ln10.d.ts.map +1 -0
- package/esm/constants/ln10.js +9 -0
- package/esm/constants/ln10.js.map +1 -0
- package/esm/constants/ln2.d.ts +10 -0
- package/esm/constants/ln2.d.ts.map +1 -0
- package/esm/constants/ln2.js +9 -0
- package/esm/constants/ln2.js.map +1 -0
- package/esm/constants/log10e.d.ts +10 -0
- package/esm/constants/log10e.d.ts.map +1 -0
- package/esm/constants/log10e.js +9 -0
- package/esm/constants/log10e.js.map +1 -0
- package/esm/constants/log2e.d.ts +10 -0
- package/esm/constants/log2e.d.ts.map +1 -0
- package/esm/constants/log2e.js +9 -0
- package/esm/constants/log2e.js.map +1 -0
- package/esm/constants/max_safe_integer.d.ts +11 -0
- package/esm/constants/max_safe_integer.d.ts.map +1 -0
- package/esm/constants/max_safe_integer.js +10 -0
- package/esm/constants/max_safe_integer.js.map +1 -0
- package/esm/constants/max_value.d.ts +10 -0
- package/esm/constants/max_value.d.ts.map +1 -0
- package/esm/constants/max_value.js +9 -0
- package/esm/constants/max_value.js.map +1 -0
- package/esm/constants/min_safe_integer.d.ts +12 -0
- package/esm/constants/min_safe_integer.d.ts.map +1 -0
- package/esm/constants/min_safe_integer.js +11 -0
- package/esm/constants/min_safe_integer.js.map +1 -0
- package/esm/constants/min_value.d.ts +10 -0
- package/esm/constants/min_value.d.ts.map +1 -0
- package/esm/constants/min_value.js +9 -0
- package/esm/constants/min_value.js.map +1 -0
- package/esm/constants/nan.d.ts +47 -0
- package/esm/constants/nan.d.ts.map +1 -0
- package/esm/constants/nan.js +27 -0
- package/esm/constants/nan.js.map +1 -0
- package/esm/constants/negative_infinity.d.ts +28 -0
- package/esm/constants/negative_infinity.d.ts.map +1 -0
- package/esm/constants/negative_infinity.js +12 -0
- package/esm/constants/negative_infinity.js.map +1 -0
- package/esm/constants/negative_zero.d.ts +31 -0
- package/esm/constants/negative_zero.d.ts.map +1 -0
- package/esm/constants/negative_zero.js +18 -0
- package/esm/constants/negative_zero.js.map +1 -0
- package/esm/constants/pi.d.ts +10 -0
- package/esm/constants/pi.d.ts.map +1 -0
- package/esm/constants/pi.js +9 -0
- package/esm/constants/pi.js.map +1 -0
- package/esm/constants/positive_infinity.d.ts +29 -0
- package/esm/constants/positive_infinity.d.ts.map +1 -0
- package/esm/constants/positive_infinity.js +13 -0
- package/esm/constants/positive_infinity.js.map +1 -0
- package/esm/constants/positive_zero.d.ts +38 -0
- package/esm/constants/positive_zero.d.ts.map +1 -0
- package/esm/constants/positive_zero.js +33 -0
- package/esm/constants/positive_zero.js.map +1 -0
- package/esm/constants/sqrt1_2.d.ts +9 -0
- package/esm/constants/sqrt1_2.d.ts.map +1 -0
- package/esm/constants/sqrt1_2.js +8 -0
- package/esm/constants/sqrt1_2.js.map +1 -0
- package/esm/constants/sqrt2.d.ts +9 -0
- package/esm/constants/sqrt2.d.ts.map +1 -0
- package/esm/constants/sqrt2.js +8 -0
- package/esm/constants/sqrt2.js.map +1 -0
- package/esm/cos.d.ts +10 -0
- package/esm/cos.d.ts.map +1 -0
- package/esm/cos.js +29 -0
- package/esm/cos.js.map +1 -0
- package/esm/cosh.d.ts +10 -0
- package/esm/cosh.d.ts.map +1 -0
- package/esm/cosh.js +18 -0
- package/esm/cosh.js.map +1 -0
- package/esm/exp.d.ts +20 -0
- package/esm/exp.d.ts.map +1 -0
- package/esm/exp.js +45 -0
- package/esm/exp.js.map +1 -0
- package/esm/expm1.d.ts +11 -0
- package/esm/expm1.d.ts.map +1 -0
- package/esm/expm1.js +35 -0
- package/esm/expm1.js.map +1 -0
- package/esm/f16round.d.ts +24 -0
- package/esm/f16round.d.ts.map +1 -0
- package/esm/f16round.js +39 -0
- package/esm/f16round.js.map +1 -0
- package/esm/float16/constants.d.ts +97 -0
- package/esm/float16/constants.d.ts.map +1 -0
- package/esm/float16/constants.js +96 -0
- package/esm/float16/constants.js.map +1 -0
- package/esm/float16/decode.d.ts +40 -0
- package/esm/float16/decode.d.ts.map +1 -0
- package/esm/float16/decode.js +61 -0
- package/esm/float16/decode.js.map +1 -0
- package/esm/float16/encode.d.ts +67 -0
- package/esm/float16/encode.d.ts.map +1 -0
- package/esm/float16/encode.js +71 -0
- package/esm/float16/encode.js.map +1 -0
- package/esm/float16/guards.d.ts +22 -0
- package/esm/float16/guards.d.ts.map +1 -0
- package/esm/float16/guards.js +12 -0
- package/esm/float16/guards.js.map +1 -0
- package/esm/float16/index.d.ts +11 -0
- package/esm/float16/index.d.ts.map +1 -0
- package/esm/float16/index.js +11 -0
- package/esm/float16/index.js.map +1 -0
- package/esm/float16/round.d.ts +25 -0
- package/esm/float16/round.d.ts.map +1 -0
- package/esm/float16/round.js +43 -0
- package/esm/float16/round.js.map +1 -0
- package/esm/float32/constants.d.ts +96 -0
- package/esm/float32/constants.d.ts.map +1 -0
- package/esm/float32/constants.js +95 -0
- package/esm/float32/constants.js.map +1 -0
- package/esm/float32/decode.d.ts +38 -0
- package/esm/float32/decode.d.ts.map +1 -0
- package/esm/float32/decode.js +64 -0
- package/esm/float32/decode.js.map +1 -0
- package/esm/float32/encode.d.ts +50 -0
- package/esm/float32/encode.d.ts.map +1 -0
- package/esm/float32/encode.js +71 -0
- package/esm/float32/encode.js.map +1 -0
- package/esm/float32/guards.d.ts +37 -0
- package/esm/float32/guards.d.ts.map +1 -0
- package/esm/float32/guards.js +16 -0
- package/esm/float32/guards.js.map +1 -0
- package/esm/float32/index.d.ts +11 -0
- package/esm/float32/index.d.ts.map +1 -0
- package/esm/float32/index.js +11 -0
- package/esm/float32/index.js.map +1 -0
- package/esm/float32/round.d.ts +23 -0
- package/esm/float32/round.d.ts.map +1 -0
- package/esm/float32/round.js +33 -0
- package/esm/float32/round.js.map +1 -0
- package/esm/floor.d.ts +10 -0
- package/esm/floor.d.ts.map +1 -0
- package/esm/floor.js +29 -0
- package/esm/floor.js.map +1 -0
- package/esm/fround.d.ts +23 -0
- package/esm/fround.d.ts.map +1 -0
- package/esm/fround.js +32 -0
- package/esm/fround.js.map +1 -0
- package/esm/guards/finite.d.ts +23 -0
- package/esm/guards/finite.d.ts.map +1 -0
- package/esm/guards/finite.js +18 -0
- package/esm/guards/finite.js.map +1 -0
- package/esm/guards/index.d.ts +50 -0
- package/esm/guards/index.d.ts.map +1 -0
- package/esm/guards/index.js +50 -0
- package/esm/guards/index.js.map +1 -0
- package/esm/guards/infinity.d.ts +3 -0
- package/esm/guards/infinity.d.ts.map +1 -0
- package/esm/guards/infinity.js +3 -0
- package/esm/guards/infinity.js.map +1 -0
- package/esm/guards/integer.d.ts +47 -0
- package/esm/guards/integer.d.ts.map +1 -0
- package/esm/guards/integer.js +19 -0
- package/esm/guards/integer.js.map +1 -0
- package/esm/guards/nan.d.ts +61 -0
- package/esm/guards/nan.d.ts.map +1 -0
- package/esm/guards/nan.js +63 -0
- package/esm/guards/nan.js.map +1 -0
- package/esm/guards/negative_infinity.d.ts +19 -0
- package/esm/guards/negative_infinity.d.ts.map +1 -0
- package/esm/guards/negative_infinity.js +21 -0
- package/esm/guards/negative_infinity.js.map +1 -0
- package/esm/guards/negative_zero.d.ts +12 -0
- package/esm/guards/negative_zero.d.ts.map +1 -0
- package/esm/guards/negative_zero.js +20 -0
- package/esm/guards/negative_zero.js.map +1 -0
- package/esm/guards/positive_infinity.d.ts +19 -0
- package/esm/guards/positive_infinity.d.ts.map +1 -0
- package/esm/guards/positive_infinity.js +21 -0
- package/esm/guards/positive_infinity.js.map +1 -0
- package/esm/guards/positive_zero.d.ts +17 -0
- package/esm/guards/positive_zero.d.ts.map +1 -0
- package/esm/guards/positive_zero.js +19 -0
- package/esm/guards/positive_zero.js.map +1 -0
- package/esm/guards/safe_integer.d.ts +33 -0
- package/esm/guards/safe_integer.d.ts.map +1 -0
- package/esm/guards/safe_integer.js +22 -0
- package/esm/guards/safe_integer.js.map +1 -0
- package/esm/hypot.d.ts +18 -0
- package/esm/hypot.d.ts.map +1 -0
- package/esm/hypot.js +60 -0
- package/esm/hypot.js.map +1 -0
- package/esm/ieee754.d.ts +16 -0
- package/esm/ieee754.d.ts.map +1 -0
- package/esm/ieee754.js +16 -0
- package/esm/ieee754.js.map +1 -0
- package/esm/imul.d.ts +17 -0
- package/esm/imul.d.ts.map +1 -0
- package/esm/imul.js +21 -0
- package/esm/imul.js.map +1 -0
- package/esm/index.d.ts +84 -0
- package/esm/index.d.ts.map +1 -0
- package/esm/index.js +84 -0
- package/esm/index.js.map +1 -0
- package/esm/internal/ieee754.d.ts +174 -0
- package/esm/internal/ieee754.d.ts.map +1 -0
- package/esm/internal/ieee754.js +194 -0
- package/esm/internal/ieee754.js.map +1 -0
- package/esm/internal/primordials.d.ts +30 -0
- package/esm/internal/primordials.d.ts.map +1 -0
- package/esm/internal/primordials.js +27 -0
- package/esm/internal/primordials.js.map +1 -0
- package/esm/log.d.ts +9 -0
- package/esm/log.d.ts.map +1 -0
- package/esm/log.js +43 -0
- package/esm/log.js.map +1 -0
- package/esm/log10.d.ts +9 -0
- package/esm/log10.d.ts.map +1 -0
- package/esm/log10.js +18 -0
- package/esm/log10.js.map +1 -0
- package/esm/log1p.d.ts +10 -0
- package/esm/log1p.d.ts.map +1 -0
- package/esm/log1p.js +29 -0
- package/esm/log1p.js.map +1 -0
- package/esm/log2.d.ts +12 -0
- package/esm/log2.d.ts.map +1 -0
- package/esm/log2.js +21 -0
- package/esm/log2.js.map +1 -0
- package/esm/max.d.ts +22 -0
- package/esm/max.d.ts.map +1 -0
- package/esm/max.js +48 -0
- package/esm/max.js.map +1 -0
- package/esm/min.d.ts +10 -0
- package/esm/min.d.ts.map +1 -0
- package/esm/min.js +33 -0
- package/esm/min.js.map +1 -0
- package/esm/package.json +3 -0
- package/esm/pow.d.ts +31 -0
- package/esm/pow.d.ts.map +1 -0
- package/esm/pow.js +33 -0
- package/esm/pow.js.map +1 -0
- package/esm/random.d.ts +93 -0
- package/esm/random.d.ts.map +1 -0
- package/esm/random.js +237 -0
- package/esm/random.js.map +1 -0
- package/esm/round.d.ts +9 -0
- package/esm/round.d.ts.map +1 -0
- package/esm/round.js +21 -0
- package/esm/round.js.map +1 -0
- package/esm/sign.d.ts +17 -0
- package/esm/sign.d.ts.map +1 -0
- package/esm/sign.js +19 -0
- package/esm/sign.js.map +1 -0
- package/esm/sin.d.ts +14 -0
- package/esm/sin.d.ts.map +1 -0
- package/esm/sin.js +28 -0
- package/esm/sin.js.map +1 -0
- package/esm/sinh.d.ts +14 -0
- package/esm/sinh.d.ts.map +1 -0
- package/esm/sinh.js +19 -0
- package/esm/sinh.js.map +1 -0
- package/esm/sqrt.d.ts +19 -0
- package/esm/sqrt.d.ts.map +1 -0
- package/esm/sqrt.js +42 -0
- package/esm/sqrt.js.map +1 -0
- package/esm/tan.d.ts +9 -0
- package/esm/tan.d.ts.map +1 -0
- package/esm/tan.js +23 -0
- package/esm/tan.js.map +1 -0
- package/esm/tanh.d.ts +17 -0
- package/esm/tanh.d.ts.map +1 -0
- package/esm/tanh.js +31 -0
- package/esm/tanh.js.map +1 -0
- package/esm/trunc.d.ts +21 -0
- package/esm/trunc.d.ts.map +1 -0
- package/esm/trunc.js +47 -0
- package/esm/trunc.js.map +1 -0
- package/esm/types/finite.d.ts +16 -0
- package/esm/types/finite.d.ts.map +1 -0
- package/esm/types/finite.js +3 -0
- package/esm/types/finite.js.map +1 -0
- package/esm/types/float.d.ts +65 -0
- package/esm/types/float.d.ts.map +1 -0
- package/esm/types/float.js +3 -0
- package/esm/types/float.js.map +1 -0
- package/esm/types/index.d.ts +6 -0
- package/esm/types/index.d.ts.map +1 -0
- package/esm/types/index.js +6 -0
- package/esm/types/index.js.map +1 -0
- package/esm/types/integer.d.ts +147 -0
- package/esm/types/integer.d.ts.map +1 -0
- package/esm/types/integer.js +4 -0
- package/esm/types/integer.js.map +1 -0
- package/esm/types/precision.d.ts +46 -0
- package/esm/types/precision.d.ts.map +1 -0
- package/esm/types/precision.js +8 -0
- package/esm/types/precision.js.map +1 -0
- package/esm/types/safe_integer.d.ts +17 -0
- package/esm/types/safe_integer.d.ts.map +1 -0
- package/esm/types/safe_integer.js +4 -0
- package/esm/types/safe_integer.js.map +1 -0
- package/package.json +1834 -0
- package/src/abs.ts +18 -0
- package/src/acos.ts +24 -0
- package/src/acosh.ts +28 -0
- package/src/asin.ts +24 -0
- package/src/asinh.ts +21 -0
- package/src/atan.ts +64 -0
- package/src/atan2.ts +58 -0
- package/src/atanh.ts +26 -0
- package/src/cbrt.ts +22 -0
- package/src/ceil.ts +27 -0
- package/src/clamp.ts +29 -0
- package/src/clz32.ts +45 -0
- package/src/constants/e.ts +18 -0
- package/src/constants/epsilon.ts +25 -0
- package/src/constants/index.ts +22 -0
- package/src/constants/infinity.ts +2 -0
- package/src/constants/ln10.ts +9 -0
- package/src/constants/ln2.ts +9 -0
- package/src/constants/log10e.ts +9 -0
- package/src/constants/log2e.ts +9 -0
- package/src/constants/max_safe_integer.ts +10 -0
- package/src/constants/max_value.ts +9 -0
- package/src/constants/min_safe_integer.ts +11 -0
- package/src/constants/min_value.ts +9 -0
- package/src/constants/nan.ts +57 -0
- package/src/constants/negative_infinity.ts +28 -0
- package/src/constants/negative_zero.ts +34 -0
- package/src/constants/pi.ts +9 -0
- package/src/constants/positive_infinity.ts +30 -0
- package/src/constants/positive_zero.ts +41 -0
- package/src/constants/sqrt1_2.ts +8 -0
- package/src/constants/sqrt2.ts +8 -0
- package/src/cos.ts +29 -0
- package/src/cosh.ts +18 -0
- package/src/exp.ts +45 -0
- package/src/expm1.ts +31 -0
- package/src/f16round.ts +39 -0
- package/src/float16/constants.ts +106 -0
- package/src/float16/decode.ts +61 -0
- package/src/float16/encode.ts +72 -0
- package/src/float16/guards.ts +33 -0
- package/src/float16/index.ts +10 -0
- package/src/float16/round.ts +43 -0
- package/src/float32/constants.ts +105 -0
- package/src/float32/decode.ts +64 -0
- package/src/float32/encode.ts +71 -0
- package/src/float32/guards.ts +54 -0
- package/src/float32/index.ts +10 -0
- package/src/float32/round.ts +33 -0
- package/src/floor.ts +26 -0
- package/src/fround.ts +32 -0
- package/src/guards/finite.ts +45 -0
- package/src/guards/index.ts +49 -0
- package/src/guards/infinity.ts +2 -0
- package/src/guards/integer.ts +62 -0
- package/src/guards/nan.ts +65 -0
- package/src/guards/negative_infinity.ts +22 -0
- package/src/guards/negative_zero.ts +21 -0
- package/src/guards/positive_infinity.ts +22 -0
- package/src/guards/positive_zero.ts +19 -0
- package/src/guards/safe_integer.ts +56 -0
- package/src/hypot.ts +59 -0
- package/src/ieee754.ts +15 -0
- package/src/imul.ts +21 -0
- package/src/index.ts +84 -0
- package/src/internal/ieee754.ts +255 -0
- package/src/internal/primordials.ts +33 -0
- package/src/log.ts +42 -0
- package/src/log10.ts +18 -0
- package/src/log1p.ts +26 -0
- package/src/log2.ts +21 -0
- package/src/max.ts +46 -0
- package/src/min.ts +32 -0
- package/src/pow.ts +33 -0
- package/src/random.ts +241 -0
- package/src/round.ts +20 -0
- package/src/sign.ts +19 -0
- package/src/sin.ts +29 -0
- package/src/sinh.ts +19 -0
- package/src/sqrt.ts +40 -0
- package/src/tan.ts +22 -0
- package/src/tanh.ts +28 -0
- package/src/trunc.ts +44 -0
- package/src/types/finite.ts +23 -0
- package/src/types/float.ts +74 -0
- package/src/types/index.ts +5 -0
- package/src/types/integer.ts +167 -0
- package/src/types/precision.ts +51 -0
- package/src/types/safe_integer.ts +18 -0
package/esm/sin.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculates the sine of a number, returning a value in the range `[-1, 1]`.
|
|
3
|
+
*
|
|
4
|
+
* @module sin
|
|
5
|
+
*/
|
|
6
|
+
import { abs } from "./abs.js";
|
|
7
|
+
import { EPSILON } from "./constants/epsilon.js";
|
|
8
|
+
import { NAN } from "./constants/nan.js";
|
|
9
|
+
import { isFinite } from "./guards/finite.js";
|
|
10
|
+
/**
|
|
11
|
+
* Calculates the sine of a number, returning a value in the range `[-1, 1]`.
|
|
12
|
+
*
|
|
13
|
+
* @param x The angle in radians whose sine is to be calculated.
|
|
14
|
+
* @returns The sine of the provided angle.
|
|
15
|
+
* @category Trigonometry
|
|
16
|
+
*/
|
|
17
|
+
export function sin(x) {
|
|
18
|
+
if (!isFinite(x))
|
|
19
|
+
return NAN;
|
|
20
|
+
let sum = (x = +x), term = x, n = 1;
|
|
21
|
+
while (abs(term) > EPSILON) {
|
|
22
|
+
n += 2;
|
|
23
|
+
term *= -x * x / (n * (n - 1));
|
|
24
|
+
sum += term;
|
|
25
|
+
}
|
|
26
|
+
return sum;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=sin.js.map
|
package/esm/sin.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sin.js","sourceRoot":"","sources":["../src/sin.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9C;;;;;;GAMG;AACH,MAAM,UAAU,GAAG,CAAC,CAAS;IAC3B,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;QAAE,OAAO,GAAG,CAAC;IAE7B,IAAI,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IACpC,OAAO,GAAG,CAAC,IAAI,CAAC,GAAG,OAAO,EAAE,CAAC;QAC3B,CAAC,IAAI,CAAC,CAAC;QACP,IAAI,IAAI,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAC/B,GAAG,IAAI,IAAI,CAAC;IACd,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/esm/sinh.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculates the hyperbolic sine of a number.
|
|
3
|
+
*
|
|
4
|
+
* @module sinh
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Calculates the hyperbolic sine of a number.
|
|
8
|
+
*
|
|
9
|
+
* @param x The number whose hyperbolic sine is to be calculated.
|
|
10
|
+
* @returns The hyperbolic sine of the provided number.
|
|
11
|
+
* @category Trigonometry
|
|
12
|
+
*/
|
|
13
|
+
export declare function sinh(x: number): number;
|
|
14
|
+
//# sourceMappingURL=sinh.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sinh.d.ts","sourceRoot":"","sources":["../src/sinh.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;;;;;GAMG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAGtC"}
|
package/esm/sinh.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculates the hyperbolic sine of a number.
|
|
3
|
+
*
|
|
4
|
+
* @module sinh
|
|
5
|
+
*/
|
|
6
|
+
import { exp } from "./exp.js";
|
|
7
|
+
/**
|
|
8
|
+
* Calculates the hyperbolic sine of a number.
|
|
9
|
+
*
|
|
10
|
+
* @param x The number whose hyperbolic sine is to be calculated.
|
|
11
|
+
* @returns The hyperbolic sine of the provided number.
|
|
12
|
+
* @category Trigonometry
|
|
13
|
+
*/
|
|
14
|
+
export function sinh(x) {
|
|
15
|
+
if (x === 0)
|
|
16
|
+
return x;
|
|
17
|
+
return (exp(x) - exp(-x)) / 2;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=sinh.js.map
|
package/esm/sinh.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sinh.js","sourceRoot":"","sources":["../src/sinh.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAE/B;;;;;;GAMG;AACH,MAAM,UAAU,IAAI,CAAC,CAAS;IAC5B,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC;IACtB,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;AAChC,CAAC"}
|
package/esm/sqrt.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculates the square root of a number.
|
|
3
|
+
*
|
|
4
|
+
* @param x The number to calculate the square root of
|
|
5
|
+
* @returns The square root of the provided number.
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* import * as math from "@nick/math";
|
|
9
|
+
*
|
|
10
|
+
* math.sqrt(4); // 2
|
|
11
|
+
* math.sqrt(16); // 4
|
|
12
|
+
* math.sqrt(0); // 0
|
|
13
|
+
* math.sqrt(1); // 1
|
|
14
|
+
* math.sqrt(-1); // NaN
|
|
15
|
+
* math.sqrt(-4); // NaN
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare function sqrt(x: number): number;
|
|
19
|
+
//# sourceMappingURL=sqrt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqrt.d.ts","sourceRoot":"","sources":["../src/sqrt.ts"],"names":[],"mappings":"AAUA;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAYtC"}
|
package/esm/sqrt.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculates the square root of a number.
|
|
3
|
+
*
|
|
4
|
+
* @module sqrt
|
|
5
|
+
*/
|
|
6
|
+
import { EPSILON } from "./constants/epsilon.js";
|
|
7
|
+
import { NAN } from "./constants/nan.js";
|
|
8
|
+
import { POSITIVE_INFINITY } from "./constants/positive_infinity.js";
|
|
9
|
+
import { abs } from "./abs.js";
|
|
10
|
+
/**
|
|
11
|
+
* Calculates the square root of a number.
|
|
12
|
+
*
|
|
13
|
+
* @param x The number to calculate the square root of
|
|
14
|
+
* @returns The square root of the provided number.
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* import * as math from "@nick/math";
|
|
18
|
+
*
|
|
19
|
+
* math.sqrt(4); // 2
|
|
20
|
+
* math.sqrt(16); // 4
|
|
21
|
+
* math.sqrt(0); // 0
|
|
22
|
+
* math.sqrt(1); // 1
|
|
23
|
+
* math.sqrt(-1); // NaN
|
|
24
|
+
* math.sqrt(-4); // NaN
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export function sqrt(x) {
|
|
28
|
+
if (x < 0)
|
|
29
|
+
return NAN; // negative numbers have no real square root
|
|
30
|
+
if (x === 0 || x === 1)
|
|
31
|
+
return x; // sqrt(0) = 0, sqrt(1) = 1
|
|
32
|
+
if (x === POSITIVE_INFINITY)
|
|
33
|
+
return x;
|
|
34
|
+
// use Newton's method to approximate the square root
|
|
35
|
+
let z = x / 2, prev;
|
|
36
|
+
do {
|
|
37
|
+
prev = z;
|
|
38
|
+
z = (z + x / z) / 2;
|
|
39
|
+
} while (abs(z - prev) > EPSILON);
|
|
40
|
+
return z;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=sqrt.js.map
|
package/esm/sqrt.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqrt.js","sourceRoot":"","sources":["../src/sqrt.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAE/B;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,IAAI,CAAC,CAAS;IAC5B,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,GAAG,CAAC,CAAC,4CAA4C;IACnE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC,CAAC,2BAA2B;IAC7D,IAAI,CAAC,KAAK,iBAAiB;QAAE,OAAO,CAAC,CAAC;IAEtC,qDAAqD;IACrD,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC;IACpB,GAAG,CAAC;QACF,IAAI,GAAG,CAAC,CAAC;QACT,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;IACtB,CAAC,QAAQ,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,OAAO,EAAE;IAClC,OAAO,CAAC,CAAC;AACX,CAAC"}
|
package/esm/tan.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculates the tangent of a number, returning a value in range `[-∞, +∞]`.
|
|
3
|
+
*
|
|
4
|
+
* @param x The angle in radians whose tangent is to be calculated.
|
|
5
|
+
* @returns The tangent of the provided angle.
|
|
6
|
+
* @category Trigonometry
|
|
7
|
+
*/
|
|
8
|
+
export declare function tan(x: number): number;
|
|
9
|
+
//# sourceMappingURL=tan.d.ts.map
|
package/esm/tan.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tan.d.ts","sourceRoot":"","sources":["../src/tan.ts"],"names":[],"mappings":"AAWA;;;;;;GAMG;AACH,wBAAgB,GAAG,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAGrC"}
|
package/esm/tan.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculates the tangent of `x`, returning a value in the range `[-∞, +∞]`.
|
|
3
|
+
*
|
|
4
|
+
* @category Trigonometry
|
|
5
|
+
* @module tan
|
|
6
|
+
*/
|
|
7
|
+
import { NAN } from "./constants/nan.js";
|
|
8
|
+
import { isFinite } from "./guards/finite.js";
|
|
9
|
+
import { cos } from "./cos.js";
|
|
10
|
+
import { sin } from "./sin.js";
|
|
11
|
+
/**
|
|
12
|
+
* Calculates the tangent of a number, returning a value in range `[-∞, +∞]`.
|
|
13
|
+
*
|
|
14
|
+
* @param x The angle in radians whose tangent is to be calculated.
|
|
15
|
+
* @returns The tangent of the provided angle.
|
|
16
|
+
* @category Trigonometry
|
|
17
|
+
*/
|
|
18
|
+
export function tan(x) {
|
|
19
|
+
if (!isFinite(x))
|
|
20
|
+
return NAN;
|
|
21
|
+
return sin(x) / cos(x);
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=tan.js.map
|
package/esm/tan.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tan.js","sourceRoot":"","sources":["../src/tan.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAE/B;;;;;;GAMG;AACH,MAAM,UAAU,GAAG,CAAC,CAAS;IAC3B,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;QAAE,OAAO,GAAG,CAAC;IAC7B,OAAO,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;AACzB,CAAC"}
|
package/esm/tanh.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculates the hyperbolic tangent of a number, returning a value in the
|
|
3
|
+
* range `[-1, 1]`.
|
|
4
|
+
*
|
|
5
|
+
* @category Trigonometry
|
|
6
|
+
* @module tanh
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Calculates the hyperbolic tangent of a number, returning a value in the
|
|
10
|
+
* range `[-1, 1]`.
|
|
11
|
+
*
|
|
12
|
+
* @param x The number whose hyperbolic tangent is to be calculated.
|
|
13
|
+
* @returns The hyperbolic tangent of the provided number.
|
|
14
|
+
* @category Trigonometry
|
|
15
|
+
*/
|
|
16
|
+
export declare function tanh(x: number): number;
|
|
17
|
+
//# sourceMappingURL=tanh.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tanh.d.ts","sourceRoot":"","sources":["../src/tanh.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAOH;;;;;;;GAOG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAMtC"}
|
package/esm/tanh.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculates the hyperbolic tangent of a number, returning a value in the
|
|
3
|
+
* range `[-1, 1]`.
|
|
4
|
+
*
|
|
5
|
+
* @category Trigonometry
|
|
6
|
+
* @module tanh
|
|
7
|
+
*/
|
|
8
|
+
import { exp } from "./exp.js";
|
|
9
|
+
import { isNaN, NAN } from "./guards/nan.js";
|
|
10
|
+
import { isPositiveInfinity } from "./guards/positive_infinity.js";
|
|
11
|
+
import { isNegativeInfinity } from "./guards/negative_infinity.js";
|
|
12
|
+
/**
|
|
13
|
+
* Calculates the hyperbolic tangent of a number, returning a value in the
|
|
14
|
+
* range `[-1, 1]`.
|
|
15
|
+
*
|
|
16
|
+
* @param x The number whose hyperbolic tangent is to be calculated.
|
|
17
|
+
* @returns The hyperbolic tangent of the provided number.
|
|
18
|
+
* @category Trigonometry
|
|
19
|
+
*/
|
|
20
|
+
export function tanh(x) {
|
|
21
|
+
if (x === 0)
|
|
22
|
+
return x;
|
|
23
|
+
if (isNaN(x))
|
|
24
|
+
return NAN;
|
|
25
|
+
if (isPositiveInfinity(x))
|
|
26
|
+
return 1;
|
|
27
|
+
if (isNegativeInfinity(x))
|
|
28
|
+
return -1;
|
|
29
|
+
return (exp(x) - exp(-x)) / (exp(x) + exp(-x));
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=tanh.js.map
|
package/esm/tanh.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tanh.js","sourceRoot":"","sources":["../src/tanh.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE;;;;;;;GAOG;AACH,MAAM,UAAU,IAAI,CAAC,CAAS;IAC5B,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC;IACtB,IAAI,KAAK,CAAC,CAAC,CAAC;QAAE,OAAO,GAAG,CAAC;IACzB,IAAI,kBAAkB,CAAC,CAAC,CAAC;QAAE,OAAO,CAAC,CAAC;IACpC,IAAI,kBAAkB,CAAC,CAAC,CAAC;QAAE,OAAO,CAAC,CAAC,CAAC;IACrC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACjD,CAAC"}
|
package/esm/trunc.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Truncates a number to an integer, removing any fractional digits.
|
|
3
|
+
*
|
|
4
|
+
* This is a local implementation of the native `Math.trunc` function.
|
|
5
|
+
*
|
|
6
|
+
* @param x The number to truncate
|
|
7
|
+
* @returns The integer part of the provided number.
|
|
8
|
+
* @category Rounding
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* import * as math from "@nick/math";
|
|
12
|
+
*
|
|
13
|
+
* math.trunc(13.37); // 13
|
|
14
|
+
* math.trunc(42.195); // 42
|
|
15
|
+
* math.trunc(-7.8); // -7
|
|
16
|
+
* math.trunc(-0.123); // 0
|
|
17
|
+
* math.trunc(0); // 0
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare function trunc(x: number): number;
|
|
21
|
+
//# sourceMappingURL=trunc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trunc.d.ts","sourceRoot":"","sources":["../src/trunc.ts"],"names":[],"mappings":"AAkBA;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAMvC"}
|
package/esm/trunc.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Truncates a number to an integer, removing any fractional digits.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* import * as math from "@nick/math";
|
|
7
|
+
*
|
|
8
|
+
* math.trunc(13.37); // 13
|
|
9
|
+
* math.trunc(42.195); // 42
|
|
10
|
+
* math.trunc(-7.8); // -7
|
|
11
|
+
* math.trunc(-0.123); // 0
|
|
12
|
+
* math.trunc(0); // 0
|
|
13
|
+
* ```
|
|
14
|
+
* @module trunc
|
|
15
|
+
*/
|
|
16
|
+
import { ceil } from "./ceil.js";
|
|
17
|
+
import { floor } from "./floor.js";
|
|
18
|
+
/**
|
|
19
|
+
* Truncates a number to an integer, removing any fractional digits.
|
|
20
|
+
*
|
|
21
|
+
* This is a local implementation of the native `Math.trunc` function.
|
|
22
|
+
*
|
|
23
|
+
* @param x The number to truncate
|
|
24
|
+
* @returns The integer part of the provided number.
|
|
25
|
+
* @category Rounding
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* import * as math from "@nick/math";
|
|
29
|
+
*
|
|
30
|
+
* math.trunc(13.37); // 13
|
|
31
|
+
* math.trunc(42.195); // 42
|
|
32
|
+
* math.trunc(-7.8); // -7
|
|
33
|
+
* math.trunc(-0.123); // 0
|
|
34
|
+
* math.trunc(0); // 0
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export function trunc(x) {
|
|
38
|
+
x = +x;
|
|
39
|
+
if (x !== x)
|
|
40
|
+
return x;
|
|
41
|
+
if (x === 0)
|
|
42
|
+
return x;
|
|
43
|
+
if (x > -1 && x < 0)
|
|
44
|
+
return -0;
|
|
45
|
+
return x < 0 ? ceil(x) : floor(x);
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=trunc.js.map
|
package/esm/trunc.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trunc.js","sourceRoot":"","sources":["../src/trunc.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,KAAK,CAAC,CAAS;IAC7B,CAAC,GAAG,CAAC,CAAC,CAAC;IACP,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC;IACtB,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC;IACtB,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,CAAC,CAAC,CAAC;IAC/B,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACpC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { NEGATIVE_INFINITY, POSITIVE_INFINITY } from "../constants/infinity.js";
|
|
2
|
+
import type { NAN } from "../constants/nan.js";
|
|
3
|
+
declare const Finite: unique symbol;
|
|
4
|
+
interface IsFinite {
|
|
5
|
+
readonly [Finite]: never;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Branded nominal type that represents a finite number, which is a real number
|
|
9
|
+
* that is not infinite or `NaN`.
|
|
10
|
+
*
|
|
11
|
+
* @category Types
|
|
12
|
+
* @tags number, nominal, finite
|
|
13
|
+
*/
|
|
14
|
+
export type Finite<N extends number = number> = (Exclude<N, NAN | POSITIVE_INFINITY | NEGATIVE_INFINITY> & IsFinite) extends infer U extends N ? U : never;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=finite.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"finite.d.ts","sourceRoot":"","sources":["../../src/types/finite.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAE/C,QAAA,MAAM,MAAM,EAAE,OAAO,MAAyB,CAAC;AAE/C,UAAU,QAAQ;IAChB,QAAQ,CAAC,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC;CAC1B;AAED;;;;;;GAMG;AACH,MAAM,MAAM,MAAM,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI,CAC5C,OAAO,CAAC,CAAC,EAAE,GAAG,GAAG,iBAAiB,GAAG,iBAAiB,CAAC,GACvD,QAAQ,CACX,SAAS,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"finite.js","sourceRoot":"","sources":["../../src/types/finite.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,GAAkB,MAAM,CAAC,QAAQ,CAAC,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This module provides nominal (branded) types for working with floating-point
|
|
3
|
+
* numbers of various precisions, which can be used to enforce type safety and
|
|
4
|
+
* prevent accidental mixing of floating-point values of different precisions.
|
|
5
|
+
*
|
|
6
|
+
* The types provided by this module are branded with unique symbols that are
|
|
7
|
+
* specific to floating-point numbers, and are designed to be used as generic
|
|
8
|
+
* type arguments to other functions and classes that work with floats.
|
|
9
|
+
*
|
|
10
|
+
* @module types/float
|
|
11
|
+
*/
|
|
12
|
+
import type { FloatPrecision, P32 } from "./precision.js";
|
|
13
|
+
declare const Float: unique symbol;
|
|
14
|
+
interface IsFloat<N extends FloatPrecision> {
|
|
15
|
+
readonly [Float]: N;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Represents a floating-point number `N`, branded with the precision specified
|
|
19
|
+
* by the generic type argument `P` (default: 32).
|
|
20
|
+
*
|
|
21
|
+
* This is a branded nominal type that accepts an optional generic type
|
|
22
|
+
* argument. When passed a literal number, it will "brand" it with an
|
|
23
|
+
* unforgeable unique symbol that is specific to floating points.
|
|
24
|
+
*
|
|
25
|
+
* @template {number} [N=number] The type of numeric value to check.
|
|
26
|
+
* @template {FloatPrecision} [P=P32] Precision of the floating-point number.
|
|
27
|
+
* @category Types
|
|
28
|
+
* @tags Float, Branded
|
|
29
|
+
*/
|
|
30
|
+
export type Float<N extends number = number, P extends FloatPrecision = P32> = number extends N ? number & IsFloat<P> : `${N}` extends `${bigint}` ? N extends 0 ? N & IsFloat<P> : never : N & IsFloat<P>;
|
|
31
|
+
/**
|
|
32
|
+
* Represents floating-point numbers of 16-bit precision.
|
|
33
|
+
*
|
|
34
|
+
* This is a branded nominal type that accepts an optional generic type
|
|
35
|
+
* argument. When passed a literal number, it will "brand" it with an
|
|
36
|
+
* unforgeable unique symbol that is specific to 16-bit floating points.
|
|
37
|
+
*
|
|
38
|
+
* @category Types
|
|
39
|
+
* @tags Float, 16-bit, Branded
|
|
40
|
+
*/
|
|
41
|
+
export type Float16<N extends number = number> = Float<N, 16>;
|
|
42
|
+
/**
|
|
43
|
+
* Represents floating-point numbers of 32-bit precision.
|
|
44
|
+
*
|
|
45
|
+
* This is a branded nominal type that accepts an optional generic type
|
|
46
|
+
* argument. When passed a literal number, it will "brand" it with an
|
|
47
|
+
* unforgeable unique symbol that is specific to 32-bit floating points.
|
|
48
|
+
*
|
|
49
|
+
* @category Types
|
|
50
|
+
* @tags Float, 32-bit, Branded
|
|
51
|
+
*/
|
|
52
|
+
export type Float32<N extends number = number> = Float<N, 32>;
|
|
53
|
+
/**
|
|
54
|
+
* Represents floating-point numbers of 64-bit precision.
|
|
55
|
+
*
|
|
56
|
+
* This is a branded nominal type that accepts an optional generic type
|
|
57
|
+
* argument. When passed a literal number, it will "brand" it with an
|
|
58
|
+
* unforgeable unique symbol that is specific to 64-bit floating points.
|
|
59
|
+
*
|
|
60
|
+
* @category Types
|
|
61
|
+
* @tags Float, 64-bit, Branded
|
|
62
|
+
*/
|
|
63
|
+
export type Float64<N extends number = number> = Float<N, 64>;
|
|
64
|
+
export type { Float64 as Double };
|
|
65
|
+
//# sourceMappingURL=float.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"float.d.ts","sourceRoot":"","sources":["../../src/types/float.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAE1D,QAAA,MAAM,KAAK,EAAE,OAAO,MAAwB,CAAC;AAE7C,UAAU,OAAO,CAAC,CAAC,SAAS,cAAc;IACxC,QAAQ,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;CACrB;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,KAAK,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EAAE,CAAC,SAAS,cAAc,GAAG,GAAG,IACzE,MAAM,SAAS,CAAC,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,GAClC,GAAG,CAAC,EAAE,SAAS,GAAG,MAAM,EAAE,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,KAAK,GACjE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AAErB;;;;;;;;;GASG;AACH,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAE9D;;;;;;;;;GASG;AACH,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAE9D;;;;;;;;;GASG;AACH,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAE9D,YAAY,EAAE,OAAO,IAAI,MAAM,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"float.js","sourceRoot":"","sources":["../../src/types/float.ts"],"names":[],"mappings":"AAaA,MAAM,KAAK,GAAkB,MAAM,CAAC,OAAO,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This module provides branded nominal types for signed and unsigned integers
|
|
3
|
+
* of various precisions, as well as bigints for 64-bit integers.
|
|
4
|
+
*
|
|
5
|
+
* @module types/integer
|
|
6
|
+
*/
|
|
7
|
+
import type { P32, Precision } from "./precision.js";
|
|
8
|
+
declare const Integer: unique symbol;
|
|
9
|
+
declare const Unsigned: unique symbol;
|
|
10
|
+
interface IsInt<N extends Precision = P32> {
|
|
11
|
+
readonly [Integer]: N;
|
|
12
|
+
}
|
|
13
|
+
interface IsUint<N extends Precision = P32> extends IsInt<N> {
|
|
14
|
+
readonly [Unsigned]: true;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Represents a signed/unsigned integer of a specific precision (default: 32).
|
|
18
|
+
*
|
|
19
|
+
* This type can be provided with a literal number for its first type argument,
|
|
20
|
+
* which will be checked at compile-time to ensure it is a valid integer.
|
|
21
|
+
*
|
|
22
|
+
* There is currently no realistic solution for checking that the value is
|
|
23
|
+
* within the range of the specified precision, so that part is left up to the
|
|
24
|
+
* runtime. This type will, however, brand the number with a unique symbol for
|
|
25
|
+
* the specified precision level `P`, preventing other numbers of different
|
|
26
|
+
* precisions from being assigned to the same variable/parameter.
|
|
27
|
+
*
|
|
28
|
+
* If you need to allow multiple precisions or multiple numbers, simply provide
|
|
29
|
+
* a union of the desired types to each of the type parameters.
|
|
30
|
+
*
|
|
31
|
+
* @category Types
|
|
32
|
+
* @tags integer, nominal
|
|
33
|
+
* @see {@linkcode Unsigned} for unsigned integers.
|
|
34
|
+
*/
|
|
35
|
+
export type Integer<N extends number = number, P extends Precision = P32> = number extends N ? number & IsInt<P> : `${N}` extends `${bigint}` ? N & IsInt<P> : never;
|
|
36
|
+
/**
|
|
37
|
+
* Represents an unsigned integer of a specific precision (default: 32).
|
|
38
|
+
*
|
|
39
|
+
* This type can be provided with a literal number for its first type argument,
|
|
40
|
+
* which will be checked at compile-time to ensure it is a positive integer.
|
|
41
|
+
*
|
|
42
|
+
* There is currently no realistic solution for checking that the value is
|
|
43
|
+
* within the range of the specified precision, so that part is left up to the
|
|
44
|
+
* runtime. This type will, however, brand the number with a unique symbol for
|
|
45
|
+
* the specified precision level `P`, preventing other numbers of different
|
|
46
|
+
* precisions from being assigned to the same variable/parameter.
|
|
47
|
+
*
|
|
48
|
+
* If you need to allow multiple precisions or multiple numbers, simply provide
|
|
49
|
+
* a union of the desired types to each of the type parameters.
|
|
50
|
+
*
|
|
51
|
+
* @category Types
|
|
52
|
+
* @tags integer, nominal, unsigned
|
|
53
|
+
* @see {@linkcode Integer} for signed/unsigned integers.
|
|
54
|
+
*/
|
|
55
|
+
export type Unsigned<N extends number = number, P extends Precision = P32> = number extends N ? number & IsUint<P> : `${N}` extends `${bigint}` ? `${N}` extends `-${string}` ? never : N & IsUint<P> : never;
|
|
56
|
+
/**
|
|
57
|
+
* Represents a signed/unsigned 8-bit integer. When given a number, this will
|
|
58
|
+
* verify it is an integer and brand it with the `Int8` symbol.
|
|
59
|
+
*
|
|
60
|
+
* @see {@linkcode Integer} for more information about how nominal types work.
|
|
61
|
+
* @category Types
|
|
62
|
+
* @tags integer, nominal, int8
|
|
63
|
+
*/
|
|
64
|
+
export type Int8<N extends number = number> = N & IsInt<8>;
|
|
65
|
+
/**
|
|
66
|
+
* Represents an unsigned 8-bit integer. When given a number, this will verify
|
|
67
|
+
* it is an integer and brand it with the `Uint8` symbol.
|
|
68
|
+
*
|
|
69
|
+
* @see {@linkcode Unsigned} for more information about how nominal types work.
|
|
70
|
+
* @category Types
|
|
71
|
+
* @tags integer, nominal, unsigned, uint8
|
|
72
|
+
*/
|
|
73
|
+
export type Uint8<N extends number = number> = N & IsUint<8>;
|
|
74
|
+
/**
|
|
75
|
+
* Represents a signed/unsigned 16-bit integer. When given a number, this will
|
|
76
|
+
* verify it is an integer and brand it with the `Int16` symbol.
|
|
77
|
+
*
|
|
78
|
+
* @see {@linkcode Integer} for more information about how nominal types work.
|
|
79
|
+
* @category Types
|
|
80
|
+
* @tags integer, nominal, int16
|
|
81
|
+
*/
|
|
82
|
+
export type Int16<N extends number = number> = N & IsInt<16>;
|
|
83
|
+
/**
|
|
84
|
+
* Represents an unsigned 16-bit integer. When given a number, this will verify
|
|
85
|
+
* it is an integer and brand it with the `Uint16` symbol.
|
|
86
|
+
*
|
|
87
|
+
* @see {@linkcode Unsigned} for more information about how nominal types work.
|
|
88
|
+
* @category Types
|
|
89
|
+
* @tags integer, nominal, unsigned, uint16
|
|
90
|
+
*/
|
|
91
|
+
export type Uint16<N extends number = number> = N & IsUint<16>;
|
|
92
|
+
/**
|
|
93
|
+
* Represents a signed/unsigned 32-bit integer. When given a number, this will
|
|
94
|
+
* verify it is an integer and brand it with the `Int32` symbol.
|
|
95
|
+
*
|
|
96
|
+
* @see {@linkcode Integer} for more information about how nominal types work.
|
|
97
|
+
* @category Types
|
|
98
|
+
* @tags integer, nominal, int32
|
|
99
|
+
*/
|
|
100
|
+
export type Int32<N extends number = number> = N & IsInt<32>;
|
|
101
|
+
/**
|
|
102
|
+
* Represents an unsigned 32-bit integer. When given a number, this will verify
|
|
103
|
+
* it is an integer and brand it with the `Uint32` symbol.
|
|
104
|
+
*
|
|
105
|
+
* @see {@linkcode Unsigned} for more information about how nominal types work.
|
|
106
|
+
* @category Types
|
|
107
|
+
* @tags integer, nominal, unsigned, uint32
|
|
108
|
+
*/
|
|
109
|
+
export type Uint32<N extends number = number> = N & IsUint<32>;
|
|
110
|
+
/**
|
|
111
|
+
* Represents a signed/unsigned 64-bit integer. When given a number, this will
|
|
112
|
+
* verify it is an integer and brand it with the `Int64` symbol.
|
|
113
|
+
*
|
|
114
|
+
* @see {@linkcode Integer} for more information about how nominal types work.
|
|
115
|
+
* @category Types
|
|
116
|
+
* @tags integer, nominal, int64
|
|
117
|
+
*/
|
|
118
|
+
export type Int64<N extends number = number> = N & IsInt<64>;
|
|
119
|
+
/**
|
|
120
|
+
* Represents an unsigned 64-bit integer. When given a number, this will verify
|
|
121
|
+
* it is an integer and brand it with the `Uint64` symbol.
|
|
122
|
+
*
|
|
123
|
+
* @see {@linkcode Unsigned} for more information about how nominal types work.
|
|
124
|
+
* @category Types
|
|
125
|
+
* @tags integer, nominal, unsigned, uint64
|
|
126
|
+
*/
|
|
127
|
+
export type Uint64<N extends number = number> = N & IsUint<64>;
|
|
128
|
+
/**
|
|
129
|
+
* Represents a signed/unsigned 64-bit bigint. This is like {@linkcode Int64},
|
|
130
|
+
* but for bigints instead of numbers.
|
|
131
|
+
*
|
|
132
|
+
* @see {@linkcode Integer} for more information about how nominal types work.
|
|
133
|
+
* @category Types
|
|
134
|
+
* @tags integer, bigint, nominal
|
|
135
|
+
*/
|
|
136
|
+
export type BigInt64<I extends bigint = bigint> = I & IsInt<64>;
|
|
137
|
+
/**
|
|
138
|
+
* Represents an unsigned 64-bit bigint. This is like {@linkcode Uint64}, but
|
|
139
|
+
* for bigints instead of numbers.
|
|
140
|
+
*
|
|
141
|
+
* @see {@linkcode Unsigned} for more information about how nominal types work.
|
|
142
|
+
* @category Types
|
|
143
|
+
* @tags integer, bigint, nominal, unsigned
|
|
144
|
+
*/
|
|
145
|
+
export type BigUint64<I extends bigint = bigint> = I & IsUint<64>;
|
|
146
|
+
export {};
|
|
147
|
+
//# sourceMappingURL=integer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"integer.d.ts","sourceRoot":"","sources":["../../src/types/integer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAErD,QAAA,MAAM,OAAO,EAAE,OAAO,MAA0B,CAAC;AACjD,QAAA,MAAM,QAAQ,EAAE,OAAO,MAA2B,CAAC;AAEnD,UAAU,KAAK,CAAC,CAAC,SAAS,SAAS,GAAG,GAAG;IACvC,QAAQ,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;CACvB;AAED,UAAU,MAAM,CAAC,CAAC,SAAS,SAAS,GAAG,GAAG,CAAE,SAAQ,KAAK,CAAC,CAAC,CAAC;IAC1D,QAAQ,CAAC,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC;CAC3B;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EAAE,CAAC,SAAS,SAAS,GAAG,GAAG,IACtE,MAAM,SAAS,CAAC,GAAG,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,GAChC,GAAG,CAAC,EAAE,SAAS,GAAG,MAAM,EAAE,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,GACzC,KAAK,CAAC;AAEZ;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EAAE,CAAC,SAAS,SAAS,GAAG,GAAG,IACvE,MAAM,SAAS,CAAC,GAAG,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,GACjC,GAAG,CAAC,EAAE,SAAS,GAAG,MAAM,EAAE,GAAG,GAAG,CAAC,EAAE,SAAS,IAAI,MAAM,EAAE,GAAG,KAAK,GAC9D,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,GACf,KAAK,CAAC;AAEZ;;;;;;;GAOG;AACH,MAAM,MAAM,IAAI,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;AAE3D;;;;;;;GAOG;AACH,MAAM,MAAM,KAAK,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AAE7D;;;;;;;GAOG;AACH,MAAM,MAAM,KAAK,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC;AAE7D;;;;;;;GAOG;AACH,MAAM,MAAM,MAAM,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC;AAE/D;;;;;;;GAOG;AACH,MAAM,MAAM,KAAK,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC;AAE7D;;;;;;;GAOG;AACH,MAAM,MAAM,MAAM,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC;AAE/D;;;;;;;GAOG;AACH,MAAM,MAAM,KAAK,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC;AAE7D;;;;;;;GAOG;AACH,MAAM,MAAM,MAAM,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC;AAE/D;;;;;;;GAOG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC;AAEhE;;;;;;;GAOG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"integer.js","sourceRoot":"","sources":["../../src/types/integer.ts"],"names":[],"mappings":"AAQA,MAAM,OAAO,GAAkB,MAAM,CAAC,SAAS,CAAC,CAAC;AACjD,MAAM,QAAQ,GAAkB,MAAM,CAAC,UAAU,CAAC,CAAC"}
|