@fluixi/utils 1.0.0-alpha.100
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 +21 -0
- package/README.md +68 -0
- package/dist/index.cjs +2858 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -0
- package/dist/index.mjs +2838 -0
- package/dist/lib/array/advanced.cjs +2227 -0
- package/dist/lib/array/advanced.d.ts +1116 -0
- package/dist/lib/array/advanced.d.ts.map +1 -0
- package/dist/lib/array/advanced.js +2429 -0
- package/dist/lib/array/advanced.mjs +2204 -0
- package/dist/lib/array/array.cjs +57 -0
- package/dist/lib/array/array.d.ts +6 -0
- package/dist/lib/array/array.d.ts.map +1 -0
- package/dist/lib/array/array.js +31 -0
- package/dist/lib/array/array.mjs +36 -0
- package/dist/lib/array/index.cjs +2344 -0
- package/dist/lib/array/index.d.ts +4 -0
- package/dist/lib/array/index.d.ts.map +1 -0
- package/dist/lib/array/index.js +3 -0
- package/dist/lib/array/index.mjs +2322 -0
- package/dist/lib/array/utils.cjs +103 -0
- package/dist/lib/array/utils.d.ts +100 -0
- package/dist/lib/array/utils.d.ts.map +1 -0
- package/dist/lib/array/utils.js +165 -0
- package/dist/lib/array/utils.mjs +82 -0
- package/dist/lib/color/color.cjs +2190 -0
- package/dist/lib/color/color.d.ts +366 -0
- package/dist/lib/color/color.d.ts.map +1 -0
- package/dist/lib/color/color.js +722 -0
- package/dist/lib/color/color.mjs +2167 -0
- package/dist/lib/color/constants.cjs +380 -0
- package/dist/lib/color/constants.d.ts +361 -0
- package/dist/lib/color/constants.d.ts.map +1 -0
- package/dist/lib/color/constants.js +358 -0
- package/dist/lib/color/constants.mjs +359 -0
- package/dist/lib/color/conversions.cjs +629 -0
- package/dist/lib/color/conversions.d.ts +166 -0
- package/dist/lib/color/conversions.d.ts.map +1 -0
- package/dist/lib/color/conversions.js +766 -0
- package/dist/lib/color/conversions.mjs +608 -0
- package/dist/lib/color/helpers.cjs +2534 -0
- package/dist/lib/color/helpers.d.ts +75 -0
- package/dist/lib/color/helpers.d.ts.map +1 -0
- package/dist/lib/color/helpers.js +419 -0
- package/dist/lib/color/helpers.mjs +2511 -0
- package/dist/lib/color/index.cjs +2641 -0
- package/dist/lib/color/index.d.ts +12 -0
- package/dist/lib/color/index.d.ts.map +1 -0
- package/dist/lib/color/index.js +15 -0
- package/dist/lib/color/index.mjs +2619 -0
- package/dist/lib/color/types.cjs +18 -0
- package/dist/lib/color/types.d.ts +179 -0
- package/dist/lib/color/types.d.ts.map +1 -0
- package/dist/lib/color/types.js +1 -0
- package/dist/lib/color/types.mjs +0 -0
- package/dist/lib/color/utils.cjs +962 -0
- package/dist/lib/color/utils.d.ts +199 -0
- package/dist/lib/color/utils.d.ts.map +1 -0
- package/dist/lib/color/utils.js +858 -0
- package/dist/lib/color/utils.mjs +939 -0
- package/dist/lib/compare/comparators.cjs +171 -0
- package/dist/lib/compare/comparators.d.ts +65 -0
- package/dist/lib/compare/comparators.d.ts.map +1 -0
- package/dist/lib/compare/comparators.js +210 -0
- package/dist/lib/compare/comparators.mjs +150 -0
- package/dist/lib/compare/index.cjs +172 -0
- package/dist/lib/compare/index.d.ts +2 -0
- package/dist/lib/compare/index.d.ts.map +1 -0
- package/dist/lib/compare/index.js +1 -0
- package/dist/lib/compare/index.mjs +152 -0
- package/dist/lib/cookie/codec.cjs +72 -0
- package/dist/lib/cookie/codec.d.ts +22 -0
- package/dist/lib/cookie/codec.d.ts.map +1 -0
- package/dist/lib/cookie/codec.js +67 -0
- package/dist/lib/cookie/codec.mjs +51 -0
- package/dist/lib/cookie/index.cjs +75 -0
- package/dist/lib/cookie/index.d.ts +2 -0
- package/dist/lib/cookie/index.d.ts.map +1 -0
- package/dist/lib/cookie/index.js +1 -0
- package/dist/lib/cookie/index.mjs +53 -0
- package/dist/lib/crypto/hash.cjs +83 -0
- package/dist/lib/crypto/hash.d.ts +6 -0
- package/dist/lib/crypto/hash.d.ts.map +1 -0
- package/dist/lib/crypto/hash.js +53 -0
- package/dist/lib/crypto/hash.mjs +62 -0
- package/dist/lib/crypto/index.cjs +85 -0
- package/dist/lib/crypto/index.d.ts +2 -0
- package/dist/lib/crypto/index.d.ts.map +1 -0
- package/dist/lib/crypto/index.js +1 -0
- package/dist/lib/crypto/index.mjs +62 -0
- package/dist/lib/dom/events.cjs +40 -0
- package/dist/lib/dom/events.d.ts +159 -0
- package/dist/lib/dom/events.d.ts.map +1 -0
- package/dist/lib/dom/events.js +50 -0
- package/dist/lib/dom/events.mjs +19 -0
- package/dist/lib/dom/index.cjs +78 -0
- package/dist/lib/dom/index.d.ts +3 -0
- package/dist/lib/dom/index.d.ts.map +1 -0
- package/dist/lib/dom/index.js +2 -0
- package/dist/lib/dom/index.mjs +56 -0
- package/dist/lib/dom/utils.cjs +57 -0
- package/dist/lib/dom/utils.d.ts +6 -0
- package/dist/lib/dom/utils.d.ts.map +1 -0
- package/dist/lib/dom/utils.js +37 -0
- package/dist/lib/dom/utils.mjs +36 -0
- package/dist/lib/functions/functions.cjs +366 -0
- package/dist/lib/functions/functions.d.ts +329 -0
- package/dist/lib/functions/functions.d.ts.map +1 -0
- package/dist/lib/functions/functions.js +585 -0
- package/dist/lib/functions/functions.mjs +345 -0
- package/dist/lib/functions/index.cjs +369 -0
- package/dist/lib/functions/index.d.ts +3 -0
- package/dist/lib/functions/index.d.ts.map +1 -0
- package/dist/lib/functions/index.js +1 -0
- package/dist/lib/functions/index.mjs +347 -0
- package/dist/lib/functions/types.cjs +18 -0
- package/dist/lib/functions/types.d.ts +2 -0
- package/dist/lib/functions/types.d.ts.map +1 -0
- package/dist/lib/functions/types.js +1 -0
- package/dist/lib/functions/types.mjs +0 -0
- package/dist/lib/helpers.cjs +78 -0
- package/dist/lib/helpers.d.ts +13 -0
- package/dist/lib/helpers.d.ts.map +1 -0
- package/dist/lib/helpers.js +66 -0
- package/dist/lib/helpers.mjs +59 -0
- package/dist/lib/index.cjs +2857 -0
- package/dist/lib/index.d.ts +6 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +8 -0
- package/dist/lib/index.mjs +2836 -0
- package/dist/lib/maths/constants.cjs +70 -0
- package/dist/lib/maths/constants.d.ts +84 -0
- package/dist/lib/maths/constants.d.ts.map +1 -0
- package/dist/lib/maths/constants.js +79 -0
- package/dist/lib/maths/constants.mjs +50 -0
- package/dist/lib/maths/fn/advanced.cjs +231 -0
- package/dist/lib/maths/fn/advanced.d.ts +149 -0
- package/dist/lib/maths/fn/advanced.d.ts.map +1 -0
- package/dist/lib/maths/fn/advanced.js +264 -0
- package/dist/lib/maths/fn/advanced.mjs +208 -0
- package/dist/lib/maths/fn/basic.cjs +212 -0
- package/dist/lib/maths/fn/basic.d.ts +182 -0
- package/dist/lib/maths/fn/basic.d.ts.map +1 -0
- package/dist/lib/maths/fn/basic.js +343 -0
- package/dist/lib/maths/fn/basic.mjs +191 -0
- package/dist/lib/maths/fn/complex.cjs +268 -0
- package/dist/lib/maths/fn/complex.d.ts +153 -0
- package/dist/lib/maths/fn/complex.d.ts.map +1 -0
- package/dist/lib/maths/fn/complex.js +383 -0
- package/dist/lib/maths/fn/complex.mjs +247 -0
- package/dist/lib/maths/fn/index.cjs +877 -0
- package/dist/lib/maths/fn/index.d.ts +10 -0
- package/dist/lib/maths/fn/index.d.ts.map +1 -0
- package/dist/lib/maths/fn/index.js +9 -0
- package/dist/lib/maths/fn/index.mjs +855 -0
- package/dist/lib/maths/fn/trigo.cjs +179 -0
- package/dist/lib/maths/fn/trigo.d.ts +147 -0
- package/dist/lib/maths/fn/trigo.d.ts.map +1 -0
- package/dist/lib/maths/fn/trigo.js +227 -0
- package/dist/lib/maths/fn/trigo.mjs +156 -0
- package/dist/lib/maths/fn/vector.cjs +728 -0
- package/dist/lib/maths/fn/vector.d.ts +512 -0
- package/dist/lib/maths/fn/vector.d.ts.map +1 -0
- package/dist/lib/maths/fn/vector.js +1136 -0
- package/dist/lib/maths/fn/vector.mjs +707 -0
- package/dist/lib/maths/formatter.cjs +61 -0
- package/dist/lib/maths/formatter.d.ts +35 -0
- package/dist/lib/maths/formatter.d.ts.map +1 -0
- package/dist/lib/maths/formatter.js +56 -0
- package/dist/lib/maths/formatter.mjs +40 -0
- package/dist/lib/maths/guards.cjs +164 -0
- package/dist/lib/maths/guards.d.ts +166 -0
- package/dist/lib/maths/guards.d.ts.map +1 -0
- package/dist/lib/maths/guards.js +315 -0
- package/dist/lib/maths/guards.mjs +144 -0
- package/dist/lib/maths/index.cjs +1152 -0
- package/dist/lib/maths/index.d.ts +24 -0
- package/dist/lib/maths/index.d.ts.map +1 -0
- package/dist/lib/maths/index.js +29 -0
- package/dist/lib/maths/index.mjs +1130 -0
- package/dist/lib/maths/parser.cjs +75 -0
- package/dist/lib/maths/parser.d.ts +20 -0
- package/dist/lib/maths/parser.d.ts.map +1 -0
- package/dist/lib/maths/parser.js +78 -0
- package/dist/lib/maths/parser.mjs +54 -0
- package/dist/lib/maths/random.cjs +49 -0
- package/dist/lib/maths/random.d.ts +27 -0
- package/dist/lib/maths/random.d.ts.map +1 -0
- package/dist/lib/maths/random.js +49 -0
- package/dist/lib/maths/random.mjs +28 -0
- package/dist/lib/maths/types/advanced.cjs +18 -0
- package/dist/lib/maths/types/advanced.d.ts +357 -0
- package/dist/lib/maths/types/advanced.d.ts.map +1 -0
- package/dist/lib/maths/types/advanced.js +5 -0
- package/dist/lib/maths/types/advanced.mjs +0 -0
- package/dist/lib/maths/types/basic.cjs +18 -0
- package/dist/lib/maths/types/basic.d.ts +95 -0
- package/dist/lib/maths/types/basic.d.ts.map +1 -0
- package/dist/lib/maths/types/basic.js +5 -0
- package/dist/lib/maths/types/basic.mjs +0 -0
- package/dist/lib/maths/types/index.cjs +19 -0
- package/dist/lib/maths/types/index.d.ts +4 -0
- package/dist/lib/maths/types/index.d.ts.map +1 -0
- package/dist/lib/maths/types/index.js +3 -0
- package/dist/lib/maths/types/index.mjs +1 -0
- package/dist/lib/maths/types/negative.cjs +18 -0
- package/dist/lib/maths/types/negative.d.ts +51 -0
- package/dist/lib/maths/types/negative.d.ts.map +1 -0
- package/dist/lib/maths/types/negative.js +5 -0
- package/dist/lib/maths/types/negative.mjs +0 -0
- package/dist/lib/maths/types/operations.cjs +18 -0
- package/dist/lib/maths/types/operations.d.ts +188 -0
- package/dist/lib/maths/types/operations.d.ts.map +1 -0
- package/dist/lib/maths/types/operations.js +6 -0
- package/dist/lib/maths/types/operations.mjs +0 -0
- package/dist/lib/object/clone.cjs +88 -0
- package/dist/lib/object/clone.d.ts +46 -0
- package/dist/lib/object/clone.d.ts.map +1 -0
- package/dist/lib/object/clone.js +104 -0
- package/dist/lib/object/clone.mjs +65 -0
- package/dist/lib/object/diff.cjs +573 -0
- package/dist/lib/object/diff.d.ts +203 -0
- package/dist/lib/object/diff.d.ts.map +1 -0
- package/dist/lib/object/diff.js +805 -0
- package/dist/lib/object/diff.mjs +550 -0
- package/dist/lib/object/getter-setter.cjs +2351 -0
- package/dist/lib/object/getter-setter.d.ts +361 -0
- package/dist/lib/object/getter-setter.d.ts.map +1 -0
- package/dist/lib/object/getter-setter.js +1771 -0
- package/dist/lib/object/getter-setter.mjs +2330 -0
- package/dist/lib/object/index.cjs +3956 -0
- package/dist/lib/object/index.d.ts +13 -0
- package/dist/lib/object/index.d.ts.map +1 -0
- package/dist/lib/object/index.js +12 -0
- package/dist/lib/object/index.mjs +3936 -0
- package/dist/lib/object/merge.cjs +1029 -0
- package/dist/lib/object/merge.d.ts +93 -0
- package/dist/lib/object/merge.d.ts.map +1 -0
- package/dist/lib/object/merge.js +474 -0
- package/dist/lib/object/merge.mjs +1006 -0
- package/dist/lib/object/object.cjs +280 -0
- package/dist/lib/object/object.d.ts +128 -0
- package/dist/lib/object/object.d.ts.map +1 -0
- package/dist/lib/object/object.js +432 -0
- package/dist/lib/object/object.mjs +257 -0
- package/dist/lib/object/omit.cjs +2022 -0
- package/dist/lib/object/omit.d.ts +351 -0
- package/dist/lib/object/omit.d.ts.map +1 -0
- package/dist/lib/object/omit.js +656 -0
- package/dist/lib/object/omit.mjs +1999 -0
- package/dist/lib/object/reconcile.cjs +126 -0
- package/dist/lib/object/reconcile.d.ts +7 -0
- package/dist/lib/object/reconcile.d.ts.map +1 -0
- package/dist/lib/object/reconcile.js +122 -0
- package/dist/lib/object/reconcile.mjs +105 -0
- package/dist/lib/object/selector.cjs +303 -0
- package/dist/lib/object/selector.d.ts +50 -0
- package/dist/lib/object/selector.d.ts.map +1 -0
- package/dist/lib/object/selector.js +371 -0
- package/dist/lib/object/selector.mjs +282 -0
- package/dist/lib/object/sort.cjs +209 -0
- package/dist/lib/object/sort.d.ts +149 -0
- package/dist/lib/object/sort.d.ts.map +1 -0
- package/dist/lib/object/sort.js +298 -0
- package/dist/lib/object/sort.mjs +186 -0
- package/dist/lib/object/transform.cjs +2211 -0
- package/dist/lib/object/transform.d.ts +620 -0
- package/dist/lib/object/transform.d.ts.map +1 -0
- package/dist/lib/object/transform.js +1058 -0
- package/dist/lib/object/transform.mjs +2190 -0
- package/dist/lib/object/types.cjs +18 -0
- package/dist/lib/object/types.d.ts +250 -0
- package/dist/lib/object/types.d.ts.map +1 -0
- package/dist/lib/object/types.js +1 -0
- package/dist/lib/object/types.mjs +0 -0
- package/dist/lib/object/utils.cjs +326 -0
- package/dist/lib/object/utils.d.ts +165 -0
- package/dist/lib/object/utils.d.ts.map +1 -0
- package/dist/lib/object/utils.js +444 -0
- package/dist/lib/object/utils.mjs +305 -0
- package/dist/lib/primitive/boolean/boolean.cjs +407 -0
- package/dist/lib/primitive/boolean/boolean.d.ts +276 -0
- package/dist/lib/primitive/boolean/boolean.d.ts.map +1 -0
- package/dist/lib/primitive/boolean/boolean.js +615 -0
- package/dist/lib/primitive/boolean/boolean.mjs +386 -0
- package/dist/lib/primitive/boolean/index.cjs +382 -0
- package/dist/lib/primitive/boolean/index.d.ts +3 -0
- package/dist/lib/primitive/boolean/index.d.ts.map +1 -0
- package/dist/lib/primitive/boolean/index.js +2 -0
- package/dist/lib/primitive/boolean/index.mjs +359 -0
- package/dist/lib/primitive/boolean/types.cjs +18 -0
- package/dist/lib/primitive/boolean/types.d.ts +14 -0
- package/dist/lib/primitive/boolean/types.d.ts.map +1 -0
- package/dist/lib/primitive/boolean/types.js +1 -0
- package/dist/lib/primitive/boolean/types.mjs +0 -0
- package/dist/lib/primitive/date/date.cjs +1126 -0
- package/dist/lib/primitive/date/date.d.ts +641 -0
- package/dist/lib/primitive/date/date.d.ts.map +1 -0
- package/dist/lib/primitive/date/date.js +1998 -0
- package/dist/lib/primitive/date/date.mjs +1105 -0
- package/dist/lib/primitive/date/index.cjs +1128 -0
- package/dist/lib/primitive/date/index.d.ts +3 -0
- package/dist/lib/primitive/date/index.d.ts.map +1 -0
- package/dist/lib/primitive/date/index.js +2 -0
- package/dist/lib/primitive/date/index.mjs +1105 -0
- package/dist/lib/primitive/date/types.cjs +18 -0
- package/dist/lib/primitive/date/types.d.ts +205 -0
- package/dist/lib/primitive/date/types.d.ts.map +1 -0
- package/dist/lib/primitive/date/types.js +7 -0
- package/dist/lib/primitive/date/types.mjs +0 -0
- package/dist/lib/primitive/index.cjs +2338 -0
- package/dist/lib/primitive/index.d.ts +5 -0
- package/dist/lib/primitive/index.d.ts.map +1 -0
- package/dist/lib/primitive/index.js +4 -0
- package/dist/lib/primitive/index.mjs +2316 -0
- package/dist/lib/primitive/string/index.cjs +875 -0
- package/dist/lib/primitive/string/index.d.ts +3 -0
- package/dist/lib/primitive/string/index.d.ts.map +1 -0
- package/dist/lib/primitive/string/index.js +2 -0
- package/dist/lib/primitive/string/index.mjs +852 -0
- package/dist/lib/primitive/string/parser-2.cjs +543 -0
- package/dist/lib/primitive/string/parser-2.d.ts +17 -0
- package/dist/lib/primitive/string/parser-2.d.ts.map +1 -0
- package/dist/lib/primitive/string/parser-2.js +656 -0
- package/dist/lib/primitive/string/parser-2.mjs +522 -0
- package/dist/lib/primitive/string/parser.cjs +236 -0
- package/dist/lib/primitive/string/parser.d.ts +9 -0
- package/dist/lib/primitive/string/parser.d.ts.map +1 -0
- package/dist/lib/primitive/string/parser.js +775 -0
- package/dist/lib/primitive/string/parser.mjs +215 -0
- package/dist/lib/primitive/string/string.cjs +926 -0
- package/dist/lib/primitive/string/string.d.ts +535 -0
- package/dist/lib/primitive/string/string.d.ts.map +1 -0
- package/dist/lib/primitive/string/string.js +1301 -0
- package/dist/lib/primitive/string/string.mjs +903 -0
- package/dist/lib/primitive/string/types.cjs +18 -0
- package/dist/lib/primitive/string/types.d.ts +318 -0
- package/dist/lib/primitive/string/types.d.ts.map +1 -0
- package/dist/lib/primitive/string/types.js +5 -0
- package/dist/lib/primitive/string/types.mjs +0 -0
- package/dist/lib/primitive/types.cjs +18 -0
- package/dist/lib/primitive/types.d.ts +27 -0
- package/dist/lib/primitive/types.d.ts.map +1 -0
- package/dist/lib/primitive/types.js +1 -0
- package/dist/lib/primitive/types.mjs +0 -0
- package/dist/lib/url/index.cjs +327 -0
- package/dist/lib/url/index.d.ts +3 -0
- package/dist/lib/url/index.d.ts.map +1 -0
- package/dist/lib/url/index.js +2 -0
- package/dist/lib/url/index.mjs +304 -0
- package/dist/lib/url/parser.cjs +325 -0
- package/dist/lib/url/parser.d.ts +216 -0
- package/dist/lib/url/parser.d.ts.map +1 -0
- package/dist/lib/url/parser.js +488 -0
- package/dist/lib/url/parser.mjs +304 -0
- package/dist/lib/url/types.cjs +18 -0
- package/dist/lib/url/types.d.ts +18 -0
- package/dist/lib/url/types.d.ts.map +1 -0
- package/dist/lib/url/types.js +1 -0
- package/dist/lib/url/types.mjs +0 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -0
- package/package.json +127 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/*! @fluixi/utils v1.0.0-alpha.100 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
|
|
2
|
+
"use strict";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/lib/maths/constants.ts
|
|
22
|
+
var constants_exports = {};
|
|
23
|
+
__export(constants_exports, {
|
|
24
|
+
Constants: () => Constants,
|
|
25
|
+
DEGREES_IN_CIRCLE: () => DEGREES_IN_CIRCLE,
|
|
26
|
+
DEGREES_PER_RADIAN: () => DEGREES_PER_RADIAN,
|
|
27
|
+
E: () => E,
|
|
28
|
+
GRADIANS_IN_CIRCLE: () => GRADIANS_IN_CIRCLE,
|
|
29
|
+
LN10: () => LN10,
|
|
30
|
+
LN2: () => LN2,
|
|
31
|
+
LOG10E: () => LOG10E,
|
|
32
|
+
LOG2E: () => LOG2E,
|
|
33
|
+
PHI: () => PHI,
|
|
34
|
+
PI: () => PI,
|
|
35
|
+
RADIANS_IN_CIRCLE: () => RADIANS_IN_CIRCLE,
|
|
36
|
+
RADIANS_PER_DEGREE: () => RADIANS_PER_DEGREE,
|
|
37
|
+
SQRT1_2: () => SQRT1_2,
|
|
38
|
+
SQRT2: () => SQRT2
|
|
39
|
+
});
|
|
40
|
+
module.exports = __toCommonJS(constants_exports);
|
|
41
|
+
var PI = 3.141592653589793;
|
|
42
|
+
var E = 2.718281828459045;
|
|
43
|
+
var PHI = 1.618033988749894;
|
|
44
|
+
var SQRT2 = 1.4142135623730951;
|
|
45
|
+
var SQRT1_2 = 0.7071067811865476;
|
|
46
|
+
var LN2 = 0.6931471805599453;
|
|
47
|
+
var LN10 = 2.302585092994046;
|
|
48
|
+
var LOG2E = 1.4426950408889634;
|
|
49
|
+
var LOG10E = 0.4342944819032518;
|
|
50
|
+
var DEGREES_IN_CIRCLE = 360;
|
|
51
|
+
var RADIANS_IN_CIRCLE = 2 * PI;
|
|
52
|
+
var GRADIANS_IN_CIRCLE = 400;
|
|
53
|
+
var DEGREES_PER_RADIAN = 180 / PI;
|
|
54
|
+
var RADIANS_PER_DEGREE = PI / 180;
|
|
55
|
+
var Constants = {
|
|
56
|
+
PI,
|
|
57
|
+
E,
|
|
58
|
+
PHI,
|
|
59
|
+
SQRT2,
|
|
60
|
+
SQRT1_2,
|
|
61
|
+
LN2,
|
|
62
|
+
LN10,
|
|
63
|
+
LOG2E,
|
|
64
|
+
LOG10E,
|
|
65
|
+
DEGREES_IN_CIRCLE,
|
|
66
|
+
RADIANS_IN_CIRCLE,
|
|
67
|
+
GRADIANS_IN_CIRCLE,
|
|
68
|
+
DEGREES_PER_RADIAN,
|
|
69
|
+
RADIANS_PER_DEGREE
|
|
70
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mathematical constants with precise typing.
|
|
3
|
+
* @module MathConstants
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* The ratio of a circle's circumference to its diameter.
|
|
7
|
+
*/
|
|
8
|
+
export declare const PI: 3.141592653589793;
|
|
9
|
+
/**
|
|
10
|
+
* Euler's number, the base of natural logarithms.
|
|
11
|
+
*/
|
|
12
|
+
export declare const E: 2.718281828459045;
|
|
13
|
+
/**
|
|
14
|
+
* The golden ratio, approximately 1.61803.
|
|
15
|
+
*/
|
|
16
|
+
export declare const PHI: 1.618033988749894;
|
|
17
|
+
/**
|
|
18
|
+
* Square root of 2.
|
|
19
|
+
*/
|
|
20
|
+
export declare const SQRT2: 1.4142135623730951;
|
|
21
|
+
/**
|
|
22
|
+
* Square root of 1/2.
|
|
23
|
+
*/
|
|
24
|
+
export declare const SQRT1_2: 0.7071067811865476;
|
|
25
|
+
/**
|
|
26
|
+
* Natural logarithm of 2.
|
|
27
|
+
*/
|
|
28
|
+
export declare const LN2: 0.6931471805599453;
|
|
29
|
+
/**
|
|
30
|
+
* Natural logarithm of 10.
|
|
31
|
+
*/
|
|
32
|
+
export declare const LN10: 2.302585092994046;
|
|
33
|
+
/**
|
|
34
|
+
* Base-2 logarithm of E.
|
|
35
|
+
*/
|
|
36
|
+
export declare const LOG2E: 1.4426950408889634;
|
|
37
|
+
/**
|
|
38
|
+
* Base-10 logarithm of E.
|
|
39
|
+
*/
|
|
40
|
+
export declare const LOG10E: 0.4342944819032518;
|
|
41
|
+
/**
|
|
42
|
+
* Degrees in a circle.
|
|
43
|
+
*/
|
|
44
|
+
export declare const DEGREES_IN_CIRCLE: 360;
|
|
45
|
+
/**
|
|
46
|
+
* Radians in a circle.
|
|
47
|
+
*/
|
|
48
|
+
export declare const RADIANS_IN_CIRCLE: number;
|
|
49
|
+
/**
|
|
50
|
+
* Gradians in a circle.
|
|
51
|
+
*/
|
|
52
|
+
export declare const GRADIANS_IN_CIRCLE: 400;
|
|
53
|
+
/**
|
|
54
|
+
* Degrees per radian.
|
|
55
|
+
*/
|
|
56
|
+
export declare const DEGREES_PER_RADIAN: number;
|
|
57
|
+
/**
|
|
58
|
+
* Radians per degree.
|
|
59
|
+
*/
|
|
60
|
+
export declare const RADIANS_PER_DEGREE: number;
|
|
61
|
+
/**
|
|
62
|
+
* Mathematical constants object for grouped access.
|
|
63
|
+
*/
|
|
64
|
+
export declare const Constants: {
|
|
65
|
+
readonly PI: 3.141592653589793;
|
|
66
|
+
readonly E: 2.718281828459045;
|
|
67
|
+
readonly PHI: 1.618033988749894;
|
|
68
|
+
readonly SQRT2: 1.4142135623730951;
|
|
69
|
+
readonly SQRT1_2: 0.7071067811865476;
|
|
70
|
+
readonly LN2: 0.6931471805599453;
|
|
71
|
+
readonly LN10: 2.302585092994046;
|
|
72
|
+
readonly LOG2E: 1.4426950408889634;
|
|
73
|
+
readonly LOG10E: 0.4342944819032518;
|
|
74
|
+
readonly DEGREES_IN_CIRCLE: 360;
|
|
75
|
+
readonly RADIANS_IN_CIRCLE: number;
|
|
76
|
+
readonly GRADIANS_IN_CIRCLE: 400;
|
|
77
|
+
readonly DEGREES_PER_RADIAN: number;
|
|
78
|
+
readonly RADIANS_PER_DEGREE: number;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Type inference for mathematical constants.
|
|
82
|
+
*/
|
|
83
|
+
export type MathConstants = typeof Constants;
|
|
84
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/lib/maths/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,eAAO,MAAM,EAAE,EAAG,iBAA0B,CAAC;AAE7C;;GAEG;AACH,eAAO,MAAM,CAAC,EAAG,iBAA0B,CAAC;AAE5C;;GAEG;AACH,eAAO,MAAM,GAAG,EAAG,iBAA0B,CAAC;AAE9C;;GAEG;AACH,eAAO,MAAM,KAAK,EAAG,kBAA2B,CAAC;AAEjD;;GAEG;AACH,eAAO,MAAM,OAAO,EAAG,kBAA2B,CAAC;AAEnD;;GAEG;AACH,eAAO,MAAM,GAAG,EAAG,kBAA2B,CAAC;AAE/C;;GAEG;AACH,eAAO,MAAM,IAAI,EAAG,iBAA0B,CAAC;AAE/C;;GAEG;AACH,eAAO,MAAM,KAAK,EAAG,kBAA2B,CAAC;AAEjD;;GAEG;AACH,eAAO,MAAM,MAAM,EAAG,kBAA2B,CAAC;AAElD;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAG,GAAY,CAAC;AAE9C;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAa,MAAM,CAAC;AAElD;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAG,GAAY,CAAC;AAE/C;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAe,MAAM,CAAC;AAErD;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAe,MAAM,CAAC;AAErD;;GAEG;AACH,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;CAeZ,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,OAAO,SAAS,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mathematical constants with precise typing.
|
|
3
|
+
* @module MathConstants
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* The ratio of a circle's circumference to its diameter.
|
|
7
|
+
*/
|
|
8
|
+
export const PI = 3.141592653589793;
|
|
9
|
+
/**
|
|
10
|
+
* Euler's number, the base of natural logarithms.
|
|
11
|
+
*/
|
|
12
|
+
export const E = 2.718281828459045;
|
|
13
|
+
/**
|
|
14
|
+
* The golden ratio, approximately 1.61803.
|
|
15
|
+
*/
|
|
16
|
+
export const PHI = 1.618033988749894;
|
|
17
|
+
/**
|
|
18
|
+
* Square root of 2.
|
|
19
|
+
*/
|
|
20
|
+
export const SQRT2 = 1.4142135623730951;
|
|
21
|
+
/**
|
|
22
|
+
* Square root of 1/2.
|
|
23
|
+
*/
|
|
24
|
+
export const SQRT1_2 = 0.7071067811865476;
|
|
25
|
+
/**
|
|
26
|
+
* Natural logarithm of 2.
|
|
27
|
+
*/
|
|
28
|
+
export const LN2 = 0.6931471805599453;
|
|
29
|
+
/**
|
|
30
|
+
* Natural logarithm of 10.
|
|
31
|
+
*/
|
|
32
|
+
export const LN10 = 2.302585092994046;
|
|
33
|
+
/**
|
|
34
|
+
* Base-2 logarithm of E.
|
|
35
|
+
*/
|
|
36
|
+
export const LOG2E = 1.4426950408889634;
|
|
37
|
+
/**
|
|
38
|
+
* Base-10 logarithm of E.
|
|
39
|
+
*/
|
|
40
|
+
export const LOG10E = 0.4342944819032518;
|
|
41
|
+
/**
|
|
42
|
+
* Degrees in a circle.
|
|
43
|
+
*/
|
|
44
|
+
export const DEGREES_IN_CIRCLE = 360;
|
|
45
|
+
/**
|
|
46
|
+
* Radians in a circle.
|
|
47
|
+
*/
|
|
48
|
+
export const RADIANS_IN_CIRCLE = 2 * PI;
|
|
49
|
+
/**
|
|
50
|
+
* Gradians in a circle.
|
|
51
|
+
*/
|
|
52
|
+
export const GRADIANS_IN_CIRCLE = 400;
|
|
53
|
+
/**
|
|
54
|
+
* Degrees per radian.
|
|
55
|
+
*/
|
|
56
|
+
export const DEGREES_PER_RADIAN = 180 / PI;
|
|
57
|
+
/**
|
|
58
|
+
* Radians per degree.
|
|
59
|
+
*/
|
|
60
|
+
export const RADIANS_PER_DEGREE = PI / 180;
|
|
61
|
+
/**
|
|
62
|
+
* Mathematical constants object for grouped access.
|
|
63
|
+
*/
|
|
64
|
+
export const Constants = {
|
|
65
|
+
PI,
|
|
66
|
+
E,
|
|
67
|
+
PHI,
|
|
68
|
+
SQRT2,
|
|
69
|
+
SQRT1_2,
|
|
70
|
+
LN2,
|
|
71
|
+
LN10,
|
|
72
|
+
LOG2E,
|
|
73
|
+
LOG10E,
|
|
74
|
+
DEGREES_IN_CIRCLE,
|
|
75
|
+
RADIANS_IN_CIRCLE,
|
|
76
|
+
GRADIANS_IN_CIRCLE,
|
|
77
|
+
DEGREES_PER_RADIAN,
|
|
78
|
+
RADIANS_PER_DEGREE,
|
|
79
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/*! @fluixi/utils v1.0.0-alpha.100 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
|
|
2
|
+
|
|
3
|
+
// src/lib/maths/constants.ts
|
|
4
|
+
var PI = 3.141592653589793;
|
|
5
|
+
var E = 2.718281828459045;
|
|
6
|
+
var PHI = 1.618033988749894;
|
|
7
|
+
var SQRT2 = 1.4142135623730951;
|
|
8
|
+
var SQRT1_2 = 0.7071067811865476;
|
|
9
|
+
var LN2 = 0.6931471805599453;
|
|
10
|
+
var LN10 = 2.302585092994046;
|
|
11
|
+
var LOG2E = 1.4426950408889634;
|
|
12
|
+
var LOG10E = 0.4342944819032518;
|
|
13
|
+
var DEGREES_IN_CIRCLE = 360;
|
|
14
|
+
var RADIANS_IN_CIRCLE = 2 * PI;
|
|
15
|
+
var GRADIANS_IN_CIRCLE = 400;
|
|
16
|
+
var DEGREES_PER_RADIAN = 180 / PI;
|
|
17
|
+
var RADIANS_PER_DEGREE = PI / 180;
|
|
18
|
+
var Constants = {
|
|
19
|
+
PI,
|
|
20
|
+
E,
|
|
21
|
+
PHI,
|
|
22
|
+
SQRT2,
|
|
23
|
+
SQRT1_2,
|
|
24
|
+
LN2,
|
|
25
|
+
LN10,
|
|
26
|
+
LOG2E,
|
|
27
|
+
LOG10E,
|
|
28
|
+
DEGREES_IN_CIRCLE,
|
|
29
|
+
RADIANS_IN_CIRCLE,
|
|
30
|
+
GRADIANS_IN_CIRCLE,
|
|
31
|
+
DEGREES_PER_RADIAN,
|
|
32
|
+
RADIANS_PER_DEGREE
|
|
33
|
+
};
|
|
34
|
+
export {
|
|
35
|
+
Constants,
|
|
36
|
+
DEGREES_IN_CIRCLE,
|
|
37
|
+
DEGREES_PER_RADIAN,
|
|
38
|
+
E,
|
|
39
|
+
GRADIANS_IN_CIRCLE,
|
|
40
|
+
LN10,
|
|
41
|
+
LN2,
|
|
42
|
+
LOG10E,
|
|
43
|
+
LOG2E,
|
|
44
|
+
PHI,
|
|
45
|
+
PI,
|
|
46
|
+
RADIANS_IN_CIRCLE,
|
|
47
|
+
RADIANS_PER_DEGREE,
|
|
48
|
+
SQRT1_2,
|
|
49
|
+
SQRT2
|
|
50
|
+
};
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/lib/maths/fn/advanced.ts
|
|
21
|
+
var advanced_exports = {};
|
|
22
|
+
__export(advanced_exports, {
|
|
23
|
+
addFractions: () => addFractions,
|
|
24
|
+
cbrt: () => cbrt,
|
|
25
|
+
evaluatePolynomial: () => evaluatePolynomial,
|
|
26
|
+
exp: () => exp,
|
|
27
|
+
ln: () => ln,
|
|
28
|
+
log: () => log,
|
|
29
|
+
log10: () => log10,
|
|
30
|
+
log2: () => log2,
|
|
31
|
+
multiplyFractions: () => multiplyFractions,
|
|
32
|
+
normalize: () => normalize,
|
|
33
|
+
nthRoot: () => nthRoot,
|
|
34
|
+
percentage: () => percentage,
|
|
35
|
+
range: () => range,
|
|
36
|
+
simplifyFraction: () => simplifyFraction,
|
|
37
|
+
solveQuadratic: () => solveQuadratic,
|
|
38
|
+
toBase: () => toBase,
|
|
39
|
+
toOrdinal: () => toOrdinal,
|
|
40
|
+
truncateDecimals: () => truncateDecimals,
|
|
41
|
+
wrap: () => wrap
|
|
42
|
+
});
|
|
43
|
+
module.exports = __toCommonJS(advanced_exports);
|
|
44
|
+
|
|
45
|
+
// src/lib/maths/fn/basic.ts
|
|
46
|
+
var round = (value, precision = 0, mode = "round") => {
|
|
47
|
+
if (mode === "david") return roundUsingDavidGay(value, precision, mode);
|
|
48
|
+
if (!Number.isFinite(value)) return value;
|
|
49
|
+
if (precision === 0) return Math[mode](value);
|
|
50
|
+
if (precision < 0) {
|
|
51
|
+
const factor2 = 10 ** -precision;
|
|
52
|
+
return Math[mode](value / factor2) * factor2;
|
|
53
|
+
}
|
|
54
|
+
const factor = 10 ** precision;
|
|
55
|
+
const epsilon = Math.pow(2, -52);
|
|
56
|
+
const adjusted = value * factor;
|
|
57
|
+
const correction = Math.sign(adjusted) * epsilon * Math.abs(adjusted);
|
|
58
|
+
let rounded;
|
|
59
|
+
switch (mode) {
|
|
60
|
+
case "round":
|
|
61
|
+
rounded = Math.round(adjusted + correction);
|
|
62
|
+
break;
|
|
63
|
+
case "ceil":
|
|
64
|
+
rounded = Math.ceil(adjusted - epsilon);
|
|
65
|
+
break;
|
|
66
|
+
case "floor":
|
|
67
|
+
rounded = Math.floor(adjusted + epsilon);
|
|
68
|
+
break;
|
|
69
|
+
case "trunc":
|
|
70
|
+
rounded = adjusted < 0 ? Math.ceil(adjusted) : Math.floor(adjusted);
|
|
71
|
+
break;
|
|
72
|
+
default:
|
|
73
|
+
rounded = Math.round(adjusted + correction);
|
|
74
|
+
}
|
|
75
|
+
return rounded / factor;
|
|
76
|
+
};
|
|
77
|
+
var roundUsingDavidGay = (_value, precision = 0, mode = "round") => {
|
|
78
|
+
let value = Math.abs(_value);
|
|
79
|
+
const multiplicator = _value < 0 ? -1 : 1;
|
|
80
|
+
if (precision === 0) {
|
|
81
|
+
return Math.round(value) * multiplicator;
|
|
82
|
+
}
|
|
83
|
+
if (!Number.isFinite(value)) {
|
|
84
|
+
return value * multiplicator;
|
|
85
|
+
}
|
|
86
|
+
const factor = 10 ** precision;
|
|
87
|
+
let shifted = value * factor;
|
|
88
|
+
const epsilon = Math.pow(2, -53);
|
|
89
|
+
const correction = Math.sign(shifted) * epsilon * Math.abs(shifted);
|
|
90
|
+
shifted += correction;
|
|
91
|
+
const rounded = Math.round(shifted);
|
|
92
|
+
return rounded / factor * multiplicator;
|
|
93
|
+
};
|
|
94
|
+
function gcd(a, b) {
|
|
95
|
+
a = Math.abs(a);
|
|
96
|
+
b = Math.abs(b);
|
|
97
|
+
while (b !== 0) {
|
|
98
|
+
const temp = b;
|
|
99
|
+
b = a % b;
|
|
100
|
+
a = temp;
|
|
101
|
+
}
|
|
102
|
+
return a;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// src/lib/maths/fn/advanced.ts
|
|
106
|
+
function ln(value) {
|
|
107
|
+
if (value <= 0) {
|
|
108
|
+
throw new Error("Natural logarithm is only defined for positive numbers");
|
|
109
|
+
}
|
|
110
|
+
return Math.log(value);
|
|
111
|
+
}
|
|
112
|
+
function log10(value) {
|
|
113
|
+
if (value <= 0) {
|
|
114
|
+
throw new Error("Logarithm is only defined for positive numbers");
|
|
115
|
+
}
|
|
116
|
+
return Math.log10(value);
|
|
117
|
+
}
|
|
118
|
+
function log2(value) {
|
|
119
|
+
if (value <= 0) {
|
|
120
|
+
throw new Error("Logarithm is only defined for positive numbers");
|
|
121
|
+
}
|
|
122
|
+
return Math.log2(value);
|
|
123
|
+
}
|
|
124
|
+
function log(value, base) {
|
|
125
|
+
if (value <= 0 || base <= 0) {
|
|
126
|
+
throw new Error("Logarithm is only defined for positive numbers and bases");
|
|
127
|
+
}
|
|
128
|
+
return Math.log(value) / Math.log(base);
|
|
129
|
+
}
|
|
130
|
+
function exp(x) {
|
|
131
|
+
return Math.exp(x);
|
|
132
|
+
}
|
|
133
|
+
function cbrt(value) {
|
|
134
|
+
return Math.cbrt(value);
|
|
135
|
+
}
|
|
136
|
+
function nthRoot(value, n) {
|
|
137
|
+
if (n === 0) {
|
|
138
|
+
throw new Error("Cannot calculate 0th root");
|
|
139
|
+
}
|
|
140
|
+
if (value < 0 && n % 2 === 0) {
|
|
141
|
+
throw new Error("Cannot calculate even root of negative number");
|
|
142
|
+
}
|
|
143
|
+
const exponent = 1 / n;
|
|
144
|
+
return Math.sign(value) * Math.pow(Math.abs(value), exponent);
|
|
145
|
+
}
|
|
146
|
+
function solveQuadratic(a, b, c) {
|
|
147
|
+
if (a === 0) {
|
|
148
|
+
if (b === 0) return [];
|
|
149
|
+
return [-c / b];
|
|
150
|
+
}
|
|
151
|
+
const discriminant = b * b - 4 * a * c;
|
|
152
|
+
if (discriminant < 0) {
|
|
153
|
+
return [];
|
|
154
|
+
} else if (discriminant === 0) {
|
|
155
|
+
return [-b / (2 * a)];
|
|
156
|
+
} else {
|
|
157
|
+
const sqrtDiscriminant = Math.sqrt(discriminant);
|
|
158
|
+
return [
|
|
159
|
+
(-b - sqrtDiscriminant) / (2 * a),
|
|
160
|
+
(-b + sqrtDiscriminant) / (2 * a)
|
|
161
|
+
];
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
function evaluatePolynomial(coefficients, x) {
|
|
165
|
+
let result = 0;
|
|
166
|
+
for (let i = 0; i < coefficients.length; i++) {
|
|
167
|
+
result = result * x + coefficients[i];
|
|
168
|
+
}
|
|
169
|
+
return result;
|
|
170
|
+
}
|
|
171
|
+
function simplifyFraction(fraction) {
|
|
172
|
+
const divisor = gcd(fraction.numerator, fraction.denominator);
|
|
173
|
+
return {
|
|
174
|
+
numerator: fraction.numerator / divisor,
|
|
175
|
+
denominator: fraction.denominator / divisor
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
function addFractions(a, b) {
|
|
179
|
+
const numerator = a.numerator * b.denominator + b.numerator * a.denominator;
|
|
180
|
+
const denominator = a.denominator * b.denominator;
|
|
181
|
+
return simplifyFraction({ numerator, denominator });
|
|
182
|
+
}
|
|
183
|
+
function multiplyFractions(a, b) {
|
|
184
|
+
const numerator = a.numerator * b.numerator;
|
|
185
|
+
const denominator = a.denominator * b.denominator;
|
|
186
|
+
return simplifyFraction({ numerator, denominator });
|
|
187
|
+
}
|
|
188
|
+
var percentage = (value, total, precision = 2) => {
|
|
189
|
+
if (total === 0) return 0;
|
|
190
|
+
const percent = value / total * 100;
|
|
191
|
+
return round(percent, precision);
|
|
192
|
+
};
|
|
193
|
+
var toBase = (number, base, minLength = 1) => {
|
|
194
|
+
if (base < 2 || base > 36) {
|
|
195
|
+
throw new Error("Base must be between 2 and 36");
|
|
196
|
+
}
|
|
197
|
+
const result = number.toString(base);
|
|
198
|
+
return result.padStart(minLength, "0");
|
|
199
|
+
};
|
|
200
|
+
var toOrdinal = (n) => {
|
|
201
|
+
const suffix = ["th", "st", "nd", "rd"];
|
|
202
|
+
const v = n % 100;
|
|
203
|
+
return n + (suffix[(v - 20) % 10] || suffix[v] || suffix[0]);
|
|
204
|
+
};
|
|
205
|
+
var range = (start, end, step = 1) => {
|
|
206
|
+
const result = [];
|
|
207
|
+
if (step === 0) return result;
|
|
208
|
+
if (step > 0) {
|
|
209
|
+
for (let i = start; i < end; i += step) {
|
|
210
|
+
result.push(i);
|
|
211
|
+
}
|
|
212
|
+
} else {
|
|
213
|
+
for (let i = start; i > end; i += step) {
|
|
214
|
+
result.push(i);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
return result;
|
|
218
|
+
};
|
|
219
|
+
var truncateDecimals = (value, decimalPlaces) => {
|
|
220
|
+
if (!Number.isFinite(value)) return value;
|
|
221
|
+
const factor = 10 ** decimalPlaces;
|
|
222
|
+
return Math.trunc(value * factor) / factor;
|
|
223
|
+
};
|
|
224
|
+
var normalize = (value, min, max) => {
|
|
225
|
+
if (min === max) return 0;
|
|
226
|
+
return (value - min) / (max - min);
|
|
227
|
+
};
|
|
228
|
+
var wrap = (value, min, max) => {
|
|
229
|
+
const range2 = max - min;
|
|
230
|
+
return ((value - min) % range2 + range2) % range2 + min;
|
|
231
|
+
};
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Advanced mathematical operations.
|
|
3
|
+
* @module AdvancedMathFunctions
|
|
4
|
+
*/
|
|
5
|
+
import type { Fraction } from '../types/advanced.js';
|
|
6
|
+
/**
|
|
7
|
+
* Calculates the natural logarithm of a number.
|
|
8
|
+
* @param value - The number
|
|
9
|
+
* @returns The natural logarithm
|
|
10
|
+
* @throws {Error} If value is not positive
|
|
11
|
+
*/
|
|
12
|
+
export declare function ln(value: number): number;
|
|
13
|
+
/**
|
|
14
|
+
* Calculates the base-10 logarithm of a number.
|
|
15
|
+
* @param value - The number
|
|
16
|
+
* @returns The base-10 logarithm
|
|
17
|
+
* @throws {Error} If value is not positive
|
|
18
|
+
*/
|
|
19
|
+
export declare function log10(value: number): number;
|
|
20
|
+
/**
|
|
21
|
+
* Calculates the base-2 logarithm of a number.
|
|
22
|
+
* @param value - The number
|
|
23
|
+
* @returns The base-2 logarithm
|
|
24
|
+
* @throws {Error} If value is not positive
|
|
25
|
+
*/
|
|
26
|
+
export declare function log2(value: number): number;
|
|
27
|
+
/**
|
|
28
|
+
* Calculates the logarithm of a number with a custom base.
|
|
29
|
+
* @param value - The number
|
|
30
|
+
* @param base - The logarithm base
|
|
31
|
+
* @returns The logarithm with specified base
|
|
32
|
+
* @throws {Error} If value or base is not positive
|
|
33
|
+
*/
|
|
34
|
+
export declare function log(value: number, base: number): number;
|
|
35
|
+
/**
|
|
36
|
+
* Calculates the exponential function e^x.
|
|
37
|
+
* @param x - The exponent
|
|
38
|
+
* @returns e raised to the power x
|
|
39
|
+
*/
|
|
40
|
+
export declare function exp(x: number): number;
|
|
41
|
+
/**
|
|
42
|
+
* Calculates the cube root of a number.
|
|
43
|
+
* @param value - The number
|
|
44
|
+
* @returns The cube root
|
|
45
|
+
*/
|
|
46
|
+
export declare function cbrt(value: number): number;
|
|
47
|
+
/**
|
|
48
|
+
* Calculates the nth root of a number.
|
|
49
|
+
* @param value - The number
|
|
50
|
+
* @param n - The root degree
|
|
51
|
+
* @returns The nth root
|
|
52
|
+
* @throws {Error} If n is 0 or value is negative for even n
|
|
53
|
+
*/
|
|
54
|
+
export declare function nthRoot(value: number, n: number): number;
|
|
55
|
+
/**
|
|
56
|
+
* Solves a quadratic equation ax^2 + bx + c = 0.
|
|
57
|
+
* @param a - Coefficient of x^2
|
|
58
|
+
* @param b - Coefficient of x
|
|
59
|
+
* @param c - Constant term
|
|
60
|
+
* @returns Array of real roots (0, 1, or 2 roots)
|
|
61
|
+
*/
|
|
62
|
+
export declare function solveQuadratic(a: number, b: number, c: number): number[];
|
|
63
|
+
/**
|
|
64
|
+
* Evaluates a polynomial at a given x value.
|
|
65
|
+
* @param coefficients - Polynomial coefficients from highest to lowest degree
|
|
66
|
+
* @param x - The value to evaluate at
|
|
67
|
+
* @returns The polynomial value at x
|
|
68
|
+
*/
|
|
69
|
+
export declare function evaluatePolynomial(coefficients: number[], x: number): number;
|
|
70
|
+
/**
|
|
71
|
+
* Simplifies a fraction to its lowest terms.
|
|
72
|
+
* @param fraction - The fraction to simplify
|
|
73
|
+
* @returns The simplified fraction
|
|
74
|
+
*/
|
|
75
|
+
export declare function simplifyFraction(fraction: Fraction): Fraction;
|
|
76
|
+
/**
|
|
77
|
+
* Adds two fractions.
|
|
78
|
+
* @param a - First fraction
|
|
79
|
+
* @param b - Second fraction
|
|
80
|
+
* @returns The sum as a simplified fraction
|
|
81
|
+
*/
|
|
82
|
+
export declare function addFractions(a: Fraction, b: Fraction): Fraction;
|
|
83
|
+
/**
|
|
84
|
+
* Multiplies two fractions.
|
|
85
|
+
* @param a - First fraction
|
|
86
|
+
* @param b - Second fraction
|
|
87
|
+
* @returns The product as a simplified fraction
|
|
88
|
+
*/
|
|
89
|
+
export declare function multiplyFractions(a: Fraction, b: Fraction): Fraction;
|
|
90
|
+
/**
|
|
91
|
+
* Calculates the percentage of a number.
|
|
92
|
+
* @param value - The number
|
|
93
|
+
* @param percentage - The percentage (e.g., 25 for 25%)
|
|
94
|
+
* @param precision - The number of decimal places
|
|
95
|
+
* @returns The percentage of the number
|
|
96
|
+
*/
|
|
97
|
+
export declare const percentage: (value: number, total: number, precision?: number) => number;
|
|
98
|
+
/**
|
|
99
|
+
* Converts a number to a specified base (2-36)
|
|
100
|
+
*
|
|
101
|
+
* @param number - The number
|
|
102
|
+
*/
|
|
103
|
+
export declare const toBase: (number: number, base: number, minLength?: number) => string;
|
|
104
|
+
/**
|
|
105
|
+
* Converts a number to ordinal string (1st, 2nd, 3rd, etc.)
|
|
106
|
+
*
|
|
107
|
+
* @param n - The number
|
|
108
|
+
*/
|
|
109
|
+
export declare const toOrdinal: (n: number) => string;
|
|
110
|
+
/**
|
|
111
|
+
* Generates a sequence of numbers
|
|
112
|
+
*
|
|
113
|
+
* @param start - The starting number
|
|
114
|
+
* @param end - The ending number
|
|
115
|
+
* @param step - The step size
|
|
116
|
+
*
|
|
117
|
+
* @returns An array of numbers
|
|
118
|
+
*/
|
|
119
|
+
export declare const range: (start: number, end: number, step?: number) => number[];
|
|
120
|
+
/**
|
|
121
|
+
* Limits the number of decimal places without rounding
|
|
122
|
+
*
|
|
123
|
+
* @param value - The number
|
|
124
|
+
* @param decimalPlaces - The number of decimal places
|
|
125
|
+
*
|
|
126
|
+
* @returns The truncated number
|
|
127
|
+
*/
|
|
128
|
+
export declare const truncateDecimals: (value: number, decimalPlaces: number) => number;
|
|
129
|
+
/**
|
|
130
|
+
* Normalizes a value to a 0-1 range based on min/max
|
|
131
|
+
*
|
|
132
|
+
* @param value - The number
|
|
133
|
+
* @param min - The minimum value
|
|
134
|
+
* @param max - The maximum value
|
|
135
|
+
*
|
|
136
|
+
* @returns The normalized value
|
|
137
|
+
*/
|
|
138
|
+
export declare const normalize: (value: number, min: number, max: number) => number;
|
|
139
|
+
/**
|
|
140
|
+
* Wraps a value within a range (like modulo for floats)
|
|
141
|
+
*
|
|
142
|
+
* @param value - The number
|
|
143
|
+
* @param min - The minimum value
|
|
144
|
+
* @param max - The maximum value
|
|
145
|
+
*
|
|
146
|
+
* @returns The wrapped value
|
|
147
|
+
*/
|
|
148
|
+
export declare const wrap: (value: number, min: number, max: number) => number;
|
|
149
|
+
//# sourceMappingURL=advanced.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"advanced.d.ts","sourceRoot":"","sources":["../../../../src/lib/maths/fn/advanced.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAGrD;;;;;GAKG;AACH,wBAAgB,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAKxC;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAK3C;AAED;;;;;GAKG;AACH,wBAAgB,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAK1C;AAED;;;;;;GAMG;AACH,wBAAgB,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAKvD;AAED;;;;GAIG;AACH,wBAAgB,GAAG,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAErC;AAED;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE1C;AAED;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAWxD;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAoBxE;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,YAAY,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAM5E;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,GAAG,QAAQ,CAM7D;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAI/D;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAIpE;AAED;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,GACrB,OAAO,MAAM,EACb,OAAO,MAAM,EACb,YAAW,MAAU,KACpB,MAIF,CAAC;AAGF;;;;GAIG;AACH,eAAO,MAAM,MAAM,GACjB,QAAQ,MAAM,EACd,MAAM,MAAM,EACZ,YAAW,MAAU,KACpB,MAOF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,SAAS,GAAI,GAAG,MAAM,KAAG,MAIrC,CAAC;AAGF;;;;;;;;GAQG;AACH,eAAO,MAAM,KAAK,GAChB,OAAO,MAAM,EACb,KAAK,MAAM,EACX,OAAM,MAAU,KACf,MAAM,EAgBR,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,GAC3B,OAAO,MAAM,EACb,eAAe,MAAM,KACpB,MAKF,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,SAAS,GACpB,OAAO,MAAM,EACb,KAAK,MAAM,EACX,KAAK,MAAM,KACV,MAGF,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,IAAI,GAAI,OAAO,MAAM,EAAE,KAAK,MAAM,EAAE,KAAK,MAAM,KAAG,MAG9D,CAAC"}
|