@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,61 @@
|
|
|
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/formatter.ts
|
|
21
|
+
var formatter_exports = {};
|
|
22
|
+
__export(formatter_exports, {
|
|
23
|
+
formatBytes: () => formatBytes,
|
|
24
|
+
formatCurrency: () => formatCurrency,
|
|
25
|
+
formatNumber: () => formatNumber,
|
|
26
|
+
formatPercent: () => formatPercent
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(formatter_exports);
|
|
29
|
+
var formatNumber = (value, options = {}) => {
|
|
30
|
+
const {
|
|
31
|
+
locale = "en-US",
|
|
32
|
+
minimumFractionDigits = 0,
|
|
33
|
+
maximumFractionDigits = 20
|
|
34
|
+
} = options;
|
|
35
|
+
return new Intl.NumberFormat(locale, {
|
|
36
|
+
minimumFractionDigits,
|
|
37
|
+
maximumFractionDigits
|
|
38
|
+
}).format(value);
|
|
39
|
+
};
|
|
40
|
+
var formatCurrency = (value, currency = "USD", locale = "en-US") => {
|
|
41
|
+
return new Intl.NumberFormat(locale, {
|
|
42
|
+
style: "currency",
|
|
43
|
+
currency
|
|
44
|
+
}).format(value);
|
|
45
|
+
};
|
|
46
|
+
var formatBytes = (bytes, decimals = 2) => {
|
|
47
|
+
if (bytes === 0) return "0 Bytes";
|
|
48
|
+
const k = 1024;
|
|
49
|
+
const dm = decimals < 0 ? 0 : decimals;
|
|
50
|
+
const sizes = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
|
51
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
52
|
+
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i]}`;
|
|
53
|
+
};
|
|
54
|
+
var formatPercent = (value, decimals = 2, locale = "en-US") => {
|
|
55
|
+
const percent = value * 100;
|
|
56
|
+
return new Intl.NumberFormat(locale, {
|
|
57
|
+
style: "percent",
|
|
58
|
+
minimumFractionDigits: 0,
|
|
59
|
+
maximumFractionDigits: Math.max(0, decimals)
|
|
60
|
+
}).format(percent / 100);
|
|
61
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Formats a number with thousand separators and decimal places
|
|
3
|
+
* @param value - Number to format
|
|
4
|
+
* @param options - Options object with locale, minimumFractionDigits, and maximumFractionDigits
|
|
5
|
+
* Optimized: Uses Intl.NumberFormat for locale-aware formatting
|
|
6
|
+
*/
|
|
7
|
+
export declare const formatNumber: (value: number, options?: {
|
|
8
|
+
locale?: Intl.LocalesArgument;
|
|
9
|
+
minimumFractionDigits?: number;
|
|
10
|
+
maximumFractionDigits?: number;
|
|
11
|
+
}) => string;
|
|
12
|
+
/**
|
|
13
|
+
* Formats a number as currency
|
|
14
|
+
* @param value - Number to format
|
|
15
|
+
* @param currency - Currency code (default: 'USD')
|
|
16
|
+
* @param locale - Locale string (default: 'en-US')
|
|
17
|
+
* Optimized: Uses Intl.NumberFormat
|
|
18
|
+
*/
|
|
19
|
+
export declare const formatCurrency: (value: number, currency?: string, locale?: string) => string;
|
|
20
|
+
/**
|
|
21
|
+
* Formats bytes to human-readable string (KB, MB, GB, etc.)
|
|
22
|
+
* @param bytes - Number of bytes to format
|
|
23
|
+
* @param decimals - Number of decimal places to include (default: 2)
|
|
24
|
+
* Optimized: Logarithmic calculation for units
|
|
25
|
+
*/
|
|
26
|
+
export declare const formatBytes: (bytes: number, decimals?: number) => string;
|
|
27
|
+
/**
|
|
28
|
+
* Formats a number as a percentage
|
|
29
|
+
* @param value - Number to format
|
|
30
|
+
* @param decimals - Number of decimal places to include (default: 2)
|
|
31
|
+
* @param locale - Locale string (default: 'en-US')
|
|
32
|
+
* Optimized: Single multiplication and formatting
|
|
33
|
+
*/
|
|
34
|
+
export declare const formatPercent: (value: number, decimals?: number, locale?: string) => string;
|
|
35
|
+
//# sourceMappingURL=formatter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatter.d.ts","sourceRoot":"","sources":["../../../src/lib/maths/formatter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GACvB,OAAO,MAAM,EACb,UAAS;IACP,MAAM,CAAC,EAAE,IAAI,CAAC,eAAe,CAAC;IAC9B,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAC3B,KACL,MAWF,CAAC;AAGF;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,GACzB,OAAO,MAAM,EACb,WAAU,MAAc,EACxB,SAAQ,MAAgB,KACvB,MAKF,CAAC;AAGF;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GACtB,OAAO,MAAM,EACb,WAAU,MAAU,KACnB,MASF,CAAC;AAGF;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,GACxB,OAAO,MAAM,EACb,WAAU,MAAU,EACpB,SAAQ,MAAgB,KACvB,MAOF,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Formats a number with thousand separators and decimal places
|
|
3
|
+
* @param value - Number to format
|
|
4
|
+
* @param options - Options object with locale, minimumFractionDigits, and maximumFractionDigits
|
|
5
|
+
* Optimized: Uses Intl.NumberFormat for locale-aware formatting
|
|
6
|
+
*/
|
|
7
|
+
export const formatNumber = (value, options = {}) => {
|
|
8
|
+
const { locale = 'en-US', minimumFractionDigits = 0, maximumFractionDigits = 20 } = options;
|
|
9
|
+
return new Intl.NumberFormat(locale, {
|
|
10
|
+
minimumFractionDigits,
|
|
11
|
+
maximumFractionDigits
|
|
12
|
+
}).format(value);
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Formats a number as currency
|
|
16
|
+
* @param value - Number to format
|
|
17
|
+
* @param currency - Currency code (default: 'USD')
|
|
18
|
+
* @param locale - Locale string (default: 'en-US')
|
|
19
|
+
* Optimized: Uses Intl.NumberFormat
|
|
20
|
+
*/
|
|
21
|
+
export const formatCurrency = (value, currency = 'USD', locale = 'en-US') => {
|
|
22
|
+
return new Intl.NumberFormat(locale, {
|
|
23
|
+
style: 'currency',
|
|
24
|
+
currency
|
|
25
|
+
}).format(value);
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Formats bytes to human-readable string (KB, MB, GB, etc.)
|
|
29
|
+
* @param bytes - Number of bytes to format
|
|
30
|
+
* @param decimals - Number of decimal places to include (default: 2)
|
|
31
|
+
* Optimized: Logarithmic calculation for units
|
|
32
|
+
*/
|
|
33
|
+
export const formatBytes = (bytes, decimals = 2) => {
|
|
34
|
+
if (bytes === 0)
|
|
35
|
+
return '0 Bytes';
|
|
36
|
+
const k = 1024;
|
|
37
|
+
const dm = decimals < 0 ? 0 : decimals;
|
|
38
|
+
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
|
39
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
40
|
+
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i]}`;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Formats a number as a percentage
|
|
44
|
+
* @param value - Number to format
|
|
45
|
+
* @param decimals - Number of decimal places to include (default: 2)
|
|
46
|
+
* @param locale - Locale string (default: 'en-US')
|
|
47
|
+
* Optimized: Single multiplication and formatting
|
|
48
|
+
*/
|
|
49
|
+
export const formatPercent = (value, decimals = 2, locale = 'en-US') => {
|
|
50
|
+
const percent = value * 100;
|
|
51
|
+
return new Intl.NumberFormat(locale, {
|
|
52
|
+
style: 'percent',
|
|
53
|
+
minimumFractionDigits: 0,
|
|
54
|
+
maximumFractionDigits: Math.max(0, decimals),
|
|
55
|
+
}).format(percent / 100);
|
|
56
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// src/lib/maths/formatter.ts
|
|
2
|
+
var formatNumber = (value, options = {}) => {
|
|
3
|
+
const {
|
|
4
|
+
locale = "en-US",
|
|
5
|
+
minimumFractionDigits = 0,
|
|
6
|
+
maximumFractionDigits = 20
|
|
7
|
+
} = options;
|
|
8
|
+
return new Intl.NumberFormat(locale, {
|
|
9
|
+
minimumFractionDigits,
|
|
10
|
+
maximumFractionDigits
|
|
11
|
+
}).format(value);
|
|
12
|
+
};
|
|
13
|
+
var formatCurrency = (value, currency = "USD", locale = "en-US") => {
|
|
14
|
+
return new Intl.NumberFormat(locale, {
|
|
15
|
+
style: "currency",
|
|
16
|
+
currency
|
|
17
|
+
}).format(value);
|
|
18
|
+
};
|
|
19
|
+
var formatBytes = (bytes, decimals = 2) => {
|
|
20
|
+
if (bytes === 0) return "0 Bytes";
|
|
21
|
+
const k = 1024;
|
|
22
|
+
const dm = decimals < 0 ? 0 : decimals;
|
|
23
|
+
const sizes = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
|
24
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
25
|
+
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i]}`;
|
|
26
|
+
};
|
|
27
|
+
var formatPercent = (value, decimals = 2, locale = "en-US") => {
|
|
28
|
+
const percent = value * 100;
|
|
29
|
+
return new Intl.NumberFormat(locale, {
|
|
30
|
+
style: "percent",
|
|
31
|
+
minimumFractionDigits: 0,
|
|
32
|
+
maximumFractionDigits: Math.max(0, decimals)
|
|
33
|
+
}).format(percent / 100);
|
|
34
|
+
};
|
|
35
|
+
export {
|
|
36
|
+
formatBytes,
|
|
37
|
+
formatCurrency,
|
|
38
|
+
formatNumber,
|
|
39
|
+
formatPercent
|
|
40
|
+
};
|
|
@@ -0,0 +1,164 @@
|
|
|
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/guards.ts
|
|
22
|
+
var guards_exports = {};
|
|
23
|
+
__export(guards_exports, {
|
|
24
|
+
approxEqual: () => approxEqual,
|
|
25
|
+
isComplexNumber: () => isComplexNumber,
|
|
26
|
+
isEven: () => isEven,
|
|
27
|
+
isFiniteNumber: () => isFiniteNumber,
|
|
28
|
+
isFloat: () => isFloat,
|
|
29
|
+
isFraction: () => isFraction,
|
|
30
|
+
isInRange: () => isInRange,
|
|
31
|
+
isInt: () => isInt,
|
|
32
|
+
isInteger: () => isInteger,
|
|
33
|
+
isMatrix: () => isMatrix,
|
|
34
|
+
isNegative: () => isNegative,
|
|
35
|
+
isNonNegative: () => isNonNegative,
|
|
36
|
+
isNonPositive: () => isNonPositive,
|
|
37
|
+
isNumber: () => isNumber,
|
|
38
|
+
isNumeric: () => isNumeric,
|
|
39
|
+
isNumericString: () => isNumericString,
|
|
40
|
+
isOdd: () => isOdd,
|
|
41
|
+
isPositive: () => isPositive,
|
|
42
|
+
isPowerOfTwo: () => isPowerOfTwo,
|
|
43
|
+
isPrime: () => isPrime,
|
|
44
|
+
isSafeInteger: () => isSafeInteger,
|
|
45
|
+
isVector2D: () => isVector2D,
|
|
46
|
+
isVector3D: () => isVector3D,
|
|
47
|
+
isZero: () => isZero
|
|
48
|
+
});
|
|
49
|
+
module.exports = __toCommonJS(guards_exports);
|
|
50
|
+
var isNumericString = (value) => {
|
|
51
|
+
const trimmed = value.trim();
|
|
52
|
+
if (trimmed === "") return false;
|
|
53
|
+
if (!/^[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?$/.test(trimmed)) return false;
|
|
54
|
+
const num = Number(trimmed);
|
|
55
|
+
return Number.isFinite(num);
|
|
56
|
+
};
|
|
57
|
+
var isNumeric = (value) => {
|
|
58
|
+
if (typeof value === "number") return Number.isFinite(value);
|
|
59
|
+
if (typeof value === "string") return isNumericString(value);
|
|
60
|
+
return false;
|
|
61
|
+
};
|
|
62
|
+
var isInt = (value) => {
|
|
63
|
+
if (typeof value === "number") {
|
|
64
|
+
return Number.isInteger(value);
|
|
65
|
+
}
|
|
66
|
+
if (typeof value === "string") {
|
|
67
|
+
const trimmed = value.trim();
|
|
68
|
+
if (!trimmed) return false;
|
|
69
|
+
if (!/^[-+]?\d+$/.test(trimmed)) return false;
|
|
70
|
+
const num2 = Number(trimmed);
|
|
71
|
+
return Number.isInteger(num2) && Number.isFinite(num2);
|
|
72
|
+
}
|
|
73
|
+
if (typeof value === "boolean" || value == null) {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
if (Array.isArray(value)) return false;
|
|
77
|
+
const num = Number(value);
|
|
78
|
+
return !Number.isNaN(num) && Number.isInteger(num) && Number.isFinite(num);
|
|
79
|
+
};
|
|
80
|
+
var isNumber = (value) => {
|
|
81
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
82
|
+
};
|
|
83
|
+
var isSafeInteger = (value) => {
|
|
84
|
+
return typeof value === "number" && Number.isSafeInteger(value);
|
|
85
|
+
};
|
|
86
|
+
var isFloat = (value) => {
|
|
87
|
+
if (typeof value !== "number" || !Number.isFinite(value)) return false;
|
|
88
|
+
return !Number.isInteger(value);
|
|
89
|
+
};
|
|
90
|
+
function isInteger(value) {
|
|
91
|
+
return Number.isInteger(value);
|
|
92
|
+
}
|
|
93
|
+
function isFiniteNumber(value) {
|
|
94
|
+
return Number.isFinite(value);
|
|
95
|
+
}
|
|
96
|
+
function isVector2D(value) {
|
|
97
|
+
return typeof value === "object" && value !== null && "x" in value && "y" in value && typeof value.x === "number" && typeof value.y === "number";
|
|
98
|
+
}
|
|
99
|
+
function isVector3D(value) {
|
|
100
|
+
return typeof value === "object" && value !== null && "x" in value && "y" in value && "z" in value && typeof value.x === "number" && typeof value.y === "number" && typeof value.z === "number";
|
|
101
|
+
}
|
|
102
|
+
function isComplexNumber(value) {
|
|
103
|
+
return typeof value === "object" && value !== null && "real" in value && "imag" in value && typeof value.real === "number" && typeof value.imag === "number";
|
|
104
|
+
}
|
|
105
|
+
function isFraction(value) {
|
|
106
|
+
return typeof value === "object" && value !== null && "numerator" in value && "denominator" in value && typeof value.numerator === "number" && typeof value.denominator === "number" && value.denominator !== 0;
|
|
107
|
+
}
|
|
108
|
+
function isMatrix(value) {
|
|
109
|
+
return typeof value === "object" && value !== null && "rows" in value && "columns" in value && "data" in value && typeof value.rows === "number" && typeof value.columns === "number" && Array.isArray(value.data) && value.data.every((row) => Array.isArray(row));
|
|
110
|
+
}
|
|
111
|
+
var isPositive = (value) => {
|
|
112
|
+
return Number.isFinite(value) && value > 0;
|
|
113
|
+
};
|
|
114
|
+
var isNegative = (value) => {
|
|
115
|
+
return Number.isFinite(value) && value < 0;
|
|
116
|
+
};
|
|
117
|
+
function isNonNegative(value) {
|
|
118
|
+
return Number.isFinite(value) && value >= 0;
|
|
119
|
+
}
|
|
120
|
+
function isNonPositive(value) {
|
|
121
|
+
return Number.isFinite(value) && value <= 0;
|
|
122
|
+
}
|
|
123
|
+
var isZero = (value, epsilon = 1e-10) => {
|
|
124
|
+
return Number.isFinite(value) && Math.abs(value) < epsilon;
|
|
125
|
+
};
|
|
126
|
+
function isInRange(value, min, max, inclusive = true) {
|
|
127
|
+
return inclusive ? value >= min && value <= max : value > min && value < max;
|
|
128
|
+
}
|
|
129
|
+
function isEven(value) {
|
|
130
|
+
return (value & 1) === 0;
|
|
131
|
+
}
|
|
132
|
+
function isOdd(value) {
|
|
133
|
+
return (value & 1) === 1;
|
|
134
|
+
}
|
|
135
|
+
var isPrime = (n) => {
|
|
136
|
+
if (!Number.isInteger(n)) {
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
if (n <= 1) return false;
|
|
140
|
+
if (n <= 3) return true;
|
|
141
|
+
if (n % 2 === 0 || n % 3 === 0) return false;
|
|
142
|
+
for (let i = 5; i * i <= n; i += 6) {
|
|
143
|
+
if (n % i === 0 || n % (i + 2) === 0) return false;
|
|
144
|
+
}
|
|
145
|
+
return true;
|
|
146
|
+
};
|
|
147
|
+
var approxEqual = (a, b, epsilon = Math.E) => {
|
|
148
|
+
if (a === b) return true;
|
|
149
|
+
if (!Number.isFinite(a) || !Number.isFinite(b)) {
|
|
150
|
+
return a === b;
|
|
151
|
+
}
|
|
152
|
+
const absA = Math.abs(a);
|
|
153
|
+
const absB = Math.abs(b);
|
|
154
|
+
const diff = Math.abs(a - b);
|
|
155
|
+
if (a === 0 || b === 0 || diff < epsilon) {
|
|
156
|
+
return diff < epsilon;
|
|
157
|
+
}
|
|
158
|
+
if (diff > epsilon) return false;
|
|
159
|
+
const relativeError = diff / Math.min(absA + absB, Number.MAX_SAFE_INTEGER);
|
|
160
|
+
return relativeError < epsilon;
|
|
161
|
+
};
|
|
162
|
+
var isPowerOfTwo = (n) => {
|
|
163
|
+
return n > 0 && (n & n - 1) === 0;
|
|
164
|
+
};
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type guard functions for mathematical types.
|
|
3
|
+
* @module TypeGuards
|
|
4
|
+
*/
|
|
5
|
+
import type { Integer, Vector2D, Vector3D, ComplexNumber, Fraction } from './types/index.js';
|
|
6
|
+
/**
|
|
7
|
+
* Checks if a string is a valid numeric string.
|
|
8
|
+
* @param value - The string to check
|
|
9
|
+
* @returns True if the string is a valid numeric string
|
|
10
|
+
*/
|
|
11
|
+
export declare const isNumericString: (value: string) => boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Type guard to check if a value is numeric.
|
|
14
|
+
* @param value - The value to check
|
|
15
|
+
* @returns True if the value is numeric
|
|
16
|
+
*/
|
|
17
|
+
export declare const isNumeric: (value: unknown) => value is number | string;
|
|
18
|
+
/**
|
|
19
|
+
* Checks if a value is an integer with high performance
|
|
20
|
+
* @param value - The value to check
|
|
21
|
+
* @returns True if the value is a valid integer
|
|
22
|
+
* @example
|
|
23
|
+
* isInt(42) // true
|
|
24
|
+
* isInt("42") // true
|
|
25
|
+
* isInt("42.5") // false
|
|
26
|
+
* isInt(null) // false
|
|
27
|
+
*/
|
|
28
|
+
export declare const isInt: (value: unknown) => value is number;
|
|
29
|
+
/**
|
|
30
|
+
* Checks if a value is a finite number (not NaN, Infinity, or string)
|
|
31
|
+
* @param value - The value to check
|
|
32
|
+
* @returns True if the value is a finite number
|
|
33
|
+
* @example
|
|
34
|
+
* isNumber(42) // true
|
|
35
|
+
* isNumber(NaN) // false
|
|
36
|
+
* isNumber(Infinity) // false
|
|
37
|
+
* isNumber("42") // false
|
|
38
|
+
*/
|
|
39
|
+
export declare const isNumber: (value: unknown) => value is number;
|
|
40
|
+
/**
|
|
41
|
+
* Checks if a value is a safe integer within Number.MAX_SAFE_INTEGER range
|
|
42
|
+
* @param value - The value to check
|
|
43
|
+
* @returns True if value is a safe integer
|
|
44
|
+
* @example
|
|
45
|
+
* isSafeInteger(42) // true
|
|
46
|
+
* isSafeInteger(9007199254740992) // false (beyond safe range)
|
|
47
|
+
*/
|
|
48
|
+
export declare const isSafeInteger: (value: unknown) => boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Checks if a value is a float (not an integer)
|
|
51
|
+
* @param value - The value to check
|
|
52
|
+
* @returns True if the value is a float
|
|
53
|
+
*/
|
|
54
|
+
export declare const isFloat: (value: unknown) => boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Type guard to check if a number is an integer.
|
|
57
|
+
* @param value - The number to check
|
|
58
|
+
* @returns True if the number is an integer
|
|
59
|
+
*/
|
|
60
|
+
export declare function isInteger(value: unknown): value is Integer;
|
|
61
|
+
/**
|
|
62
|
+
* Type guard to check if a number is a finite number.
|
|
63
|
+
* @param value - The number to check
|
|
64
|
+
* @returns True if the number is finite
|
|
65
|
+
*/
|
|
66
|
+
export declare function isFiniteNumber(value: number): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Type guard to check if a value is a valid Vector2D.
|
|
69
|
+
* @param value - The value to check
|
|
70
|
+
* @returns True if the value is a valid Vector2D
|
|
71
|
+
*/
|
|
72
|
+
export declare function isVector2D(value: unknown): value is Vector2D;
|
|
73
|
+
/**
|
|
74
|
+
* Type guard to check if a value is a valid Vector3D.
|
|
75
|
+
* @param value - The value to check
|
|
76
|
+
* @returns True if the value is a valid Vector3D
|
|
77
|
+
*/
|
|
78
|
+
export declare function isVector3D(value: unknown): value is Vector3D;
|
|
79
|
+
/**
|
|
80
|
+
* Type guard to check if a value is a valid ComplexNumber.
|
|
81
|
+
* @param value - The value to check
|
|
82
|
+
* @returns True if the value is a valid ComplexNumber
|
|
83
|
+
*/
|
|
84
|
+
export declare function isComplexNumber(value: unknown): value is ComplexNumber;
|
|
85
|
+
/**
|
|
86
|
+
* Type guard to check if a value is a valid Fraction.
|
|
87
|
+
* @param value - The value to check
|
|
88
|
+
* @returns True if the value is a valid Fraction
|
|
89
|
+
*/
|
|
90
|
+
export declare function isFraction(value: unknown): value is Fraction;
|
|
91
|
+
/**
|
|
92
|
+
* Type guard to check if a value is a valid Matrix.
|
|
93
|
+
* @param value - The value to check
|
|
94
|
+
* @returns True if the value is a valid Matrix
|
|
95
|
+
*/
|
|
96
|
+
export declare function isMatrix(value: unknown): value is import('./types/index.js').Matrix<any, any>;
|
|
97
|
+
/**
|
|
98
|
+
* Type guard to check if a number is positive (> 0).
|
|
99
|
+
* @param value - The number to check
|
|
100
|
+
* @returns True if the number is positive
|
|
101
|
+
*/
|
|
102
|
+
export declare const isPositive: (value: number) => boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Type guard to check if a number is negative (< 0).
|
|
105
|
+
* @param value - The number to check
|
|
106
|
+
* @returns True if the number is negative
|
|
107
|
+
*/
|
|
108
|
+
export declare const isNegative: (value: number) => boolean;
|
|
109
|
+
/**
|
|
110
|
+
* Type guard to check if a number is non-negative (>= 0).
|
|
111
|
+
* @param value - The number to check
|
|
112
|
+
* @returns True if the number is non-negative
|
|
113
|
+
*/
|
|
114
|
+
export declare function isNonNegative(value: number): boolean;
|
|
115
|
+
/**
|
|
116
|
+
* Type guard to check if a number is non-positive (<= 0).
|
|
117
|
+
* @param value - The number to check
|
|
118
|
+
* @returns True if the number is non-positive
|
|
119
|
+
*/
|
|
120
|
+
export declare function isNonPositive(value: number): boolean;
|
|
121
|
+
/**
|
|
122
|
+
* Checks if a number is zero (or very close to zero)
|
|
123
|
+
*/
|
|
124
|
+
export declare const isZero: (value: number, epsilon?: number) => boolean;
|
|
125
|
+
/**
|
|
126
|
+
* Type guard to check if a number is within a range (inclusive).
|
|
127
|
+
* @param value - The number to check
|
|
128
|
+
* @param min - Minimum value
|
|
129
|
+
* @param max - Maximum value
|
|
130
|
+
* @param inclusive - Whether the range is inclusive
|
|
131
|
+
* @returns True if the number is within the range
|
|
132
|
+
*/
|
|
133
|
+
export declare function isInRange(value: number, min: number, max: number, inclusive?: boolean): boolean;
|
|
134
|
+
/**
|
|
135
|
+
* Type guard to check if a number is even.
|
|
136
|
+
* @param value - The number to check
|
|
137
|
+
* @returns True if the number is even
|
|
138
|
+
*/
|
|
139
|
+
export declare function isEven(value: number): boolean;
|
|
140
|
+
/**
|
|
141
|
+
* Type guard to check if a number is odd.
|
|
142
|
+
* @param value - The number to check
|
|
143
|
+
* @returns True if the number is odd
|
|
144
|
+
*/
|
|
145
|
+
export declare function isOdd(value: number): boolean;
|
|
146
|
+
/**
|
|
147
|
+
* Checks if a number is prime.
|
|
148
|
+
* @param n - The number to check
|
|
149
|
+
* @returns True if the number is prime, false otherwise
|
|
150
|
+
*/
|
|
151
|
+
export declare const isPrime: (n: number) => boolean;
|
|
152
|
+
/**
|
|
153
|
+
* Checks if two numbers are approximately equal.
|
|
154
|
+
* @param a - First number
|
|
155
|
+
* @param b - Second number
|
|
156
|
+
* @param epsilon - The maximum allowed difference between the numbers
|
|
157
|
+
* @returns True if the numbers are approximately equal, false otherwise
|
|
158
|
+
*/
|
|
159
|
+
export declare const approxEqual: (a: number, b: number, epsilon?: number) => boolean;
|
|
160
|
+
/**
|
|
161
|
+
* Checks if a number is a power of two
|
|
162
|
+
* @param n - The number to check
|
|
163
|
+
* Optimized: Bitwise trick
|
|
164
|
+
*/
|
|
165
|
+
export declare const isPowerOfTwo: (n: number) => boolean;
|
|
166
|
+
//# sourceMappingURL=guards.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guards.d.ts","sourceRoot":"","sources":["../../../src/lib/maths/guards.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE7F;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,OAAO,MAAM,KAAG,OAS/C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,SAAS,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,MAAM,GAAG,MAI5D,CAAC;AAEF;;;;;;;;;EASE;AACF,eAAO,MAAM,KAAK,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,MA4B/C,CAAC;AAIF;;;;;;;;;EASE;AACF,eAAO,MAAM,QAAQ,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,MAElD,CAAC;AAGF;;;;;;;EAOE;AACF,eAAO,MAAM,aAAa,GAAI,OAAO,OAAO,KAAG,OAE9C,CAAC;AAGF;;;;EAIE;AACF,eAAO,MAAM,OAAO,GAAI,OAAO,OAAO,KAAG,OAGxC,CAAC;AACF;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,OAAO,CAE1D;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAErD;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,QAAQ,CAS5D;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,QAAQ,CAW5D;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAStE;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,QAAQ,CAU5D;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,OAAO,kBAAkB,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAY7F;AAED;;;;GAIG;AACH,eAAO,MAAM,UAAU,GAAI,OAAO,MAAM,KAAG,OAE1C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,UAAU,GAAI,OAAO,MAAM,KAAG,OAE1C,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED;;GAEG;AACH,eAAO,MAAM,MAAM,GAAI,OAAO,MAAM,EAAE,UAAS,MAAc,KAAG,OAE/D,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,SAAS,GAAE,OAAc,GAAG,OAAO,CAErG;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAG7C;AAED;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAG5C;AAED;;;;GAIG;AACH,eAAO,MAAM,OAAO,GAAI,GAAG,MAAM,KAAG,OAenC,CAAC;AAEF;;;;;;EAME;AACF,eAAO,MAAM,WAAW,GACtB,GAAG,MAAM,EACT,GAAG,MAAM,EACT,UAAS,MAAe,KACvB,OAqBF,CAAC;AAGF;;;;GAIG;AACH,eAAO,MAAM,YAAY,GAAI,GAAG,MAAM,KAAG,OAExC,CAAC"}
|