@tempots/std 0.12.0 → 0.13.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/array.d.ts +0 -32
- package/function.cjs +1 -1
- package/function.d.ts +0 -17
- package/function.js +10 -25
- package/index.cjs +1 -1
- package/index.js +150 -156
- package/number.cjs +1 -1
- package/number.d.ts +23 -2
- package/number.js +31 -32
- package/package.json +1 -1
- package/string.cjs +4 -4
- package/string.d.ts +305 -76
- package/string.js +175 -185
package/index.js
CHANGED
|
@@ -1,39 +1,38 @@
|
|
|
1
|
-
import { allElements as
|
|
2
|
-
import { AsyncResult as
|
|
3
|
-
import { biAbs as
|
|
4
|
-
import { deepEqual as
|
|
5
|
-
import {
|
|
6
|
-
import { EPSILON as
|
|
7
|
-
import { isEmptyObject as
|
|
8
|
-
import { mapRegExp as
|
|
9
|
-
import { R as
|
|
10
|
-
import {
|
|
1
|
+
import { allElements as t, anyElement as i, applyArrayDiffOperations as a, areArraysEqual as s, arrayDiffOperations as n, arrayHasValues as o, arrayHead as l, arrayOfIterableIterator as m, arrayTail as p, compareArrays as c, concatArrays as y, createFilledArray as A, filterArray as f, filterMapArray as d, filterNullsFromArray as x, flatMapArray as g, flattenArray as u, foldLeftArray as C, forEachElement as b, generateArray as v, generateSequenceArray as h, isArrayEmpty as S, joinArrayWithConjunction as E, mapArray as I, rankArray as T, removeAllFromArray as O, removeAllFromArrayByPredicate as F, removeOneFromArray as W, removeOneFromArrayByPredicate as q, sortArray as L, uniqueByPredicate as P, uniquePrimitives as j } from "./array.js";
|
|
2
|
+
import { AsyncResult as B } from "./async-result.js";
|
|
3
|
+
import { biAbs as N, biCeilDiv as z, biCompare as H, biFloorDiv as M, biGcd as R, biIsEven as k, biIsNegative as V, biIsOdd as K, biIsOne as Q, biIsPositive as Z, biIsPrime as G, biIsZero as U, biLcm as J, biMax as X, biMin as Y, biNextPrime as _, biPow as $, biPrevPrime as ee } from "./bigint.js";
|
|
4
|
+
import { deepEqual as te, looseEqual as ie, strictEqual as ae } from "./equal.js";
|
|
5
|
+
import { curryLeft as ne, identity as oe, memoize as le } from "./function.js";
|
|
6
|
+
import { EPSILON as pe, angleDifference as ce, ceilTo as ye, clamp as Ae, clampInt as fe, clampSym as de, compareNumbers as xe, floorTo as ge, interpolate as ue, interpolateAngle as Ce, interpolateAngleCCW as be, interpolateAngleCW as ve, interpolateWidestAngle as he, nearEqualAngles as Se, nearEquals as Ee, nearZero as Ie, root as Te, roundTo as Oe, sign as Fe, toHex as We, widestAngleDifference as qe, wrap as Le, wrapCircular as Pe } from "./number.js";
|
|
7
|
+
import { isEmptyObject as we, isObject as Be, mergeObjects as De, objectKeys as Ne, removeObjectFields as ze, sameObjectKeys as He } from "./object.js";
|
|
8
|
+
import { mapRegExp as Re } from "./regexp.js";
|
|
9
|
+
import { R as Ve, V as Ke } from "./result-Czm7RKNP.js";
|
|
10
|
+
import { afterLastText as Ze, afterText as Ge, beforeLastText as Ue, beforeText as Je, canonicalizeNewlines as Xe, capitalize as Ye, capitalizeWords as _e, chunkText as $e, compareCaseInsensitive as er, compareStrings as rr, containsAllText as tr, containsAllTextCaseInsensitive as ir, containsAnyText as ar, containsAnyTextCaseInsensitive as sr, countTextOccurrences as nr, dasherize as or, decodeBase64 as lr, ellipsis as mr, ellipsisMiddle as pr, encodeBase64 as cr, endsWithAnyText as yr, filterCharcode as Ar, filterText as fr, humanize as dr, ifEmptyString as xr, isAlpha as gr, isAlphaNum as ur, isBreakingWhitespace as Cr, isDigitsOnly as br, isEmptyString as vr, isLowerCase as hr, isSpaceAt as Sr, isUpperCase as Er, jsQuote as Ir, lowerCaseFirst as Tr, lpad as Or, mapChars as Fr, quote as Wr, randomString as qr, randomStringSequence as Lr, randomStringSequenceBase64 as Pr, removeFirstFromString as jr, removeFromString as wr, removeFromStringAfter as Br, removeFromStringBefore as Dr, removeSliceFromString as Nr, repeatString as zr, replaceAll as Hr, reverseString as Mr, rpad as Rr, smartQuote as kr, splitOnFirst as Vr, splitOnLast as Kr, splitStringOnce as Qr, stringHasContent as Zr, stringHashCode as Gr, stringToCharcodes as Ur, stringToChars as Jr, stringToLines as Xr, stringsDifferAtIndex as Yr, surroundText as _r, textCollapse as $r, textContains as et, textContainsCaseInsensitive as rt, textEndsWith as tt, textEndsWithAnyCaseInsensitive as it, textEndsWithCaseInsensitive as at, textStartsWith as st, textStartsWithAny as nt, textStartsWithAnyCaseInsensitive as ot, textStartsWithCaseInsensitive as lt, trimChars as mt, trimCharsLeft as pt, trimCharsRight as ct, underscore as yt, upperCaseFirst as At, wrapColumns as ft, wrapLine as dt } from "./string.js";
|
|
11
11
|
export {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
de as angleDifference,
|
|
12
|
+
B as AsyncResult,
|
|
13
|
+
pe as EPSILON,
|
|
14
|
+
Ve as Result,
|
|
15
|
+
Ke as Validation,
|
|
16
|
+
Ze as afterLastText,
|
|
17
|
+
Ge as afterText,
|
|
18
|
+
t as allElements,
|
|
19
|
+
ce as angleDifference,
|
|
21
20
|
i as anyElement,
|
|
22
|
-
|
|
21
|
+
a as applyArrayDiffOperations,
|
|
23
22
|
s as areArraysEqual,
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
n as arrayDiffOperations,
|
|
24
|
+
o as arrayHasValues,
|
|
26
25
|
l as arrayHead,
|
|
27
26
|
m as arrayOfIterableIterator,
|
|
28
27
|
p as arrayTail,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
Ue as beforeLastText,
|
|
29
|
+
Je as beforeText,
|
|
30
|
+
N as biAbs,
|
|
32
31
|
z as biCeilDiv,
|
|
33
|
-
|
|
32
|
+
H as biCompare,
|
|
34
33
|
M as biFloorDiv,
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
R as biGcd,
|
|
35
|
+
k as biIsEven,
|
|
37
36
|
V as biIsNegative,
|
|
38
37
|
K as biIsOdd,
|
|
39
38
|
Q as biIsOne,
|
|
@@ -46,140 +45,135 @@ export {
|
|
|
46
45
|
_ as biNextPrime,
|
|
47
46
|
$ as biPow,
|
|
48
47
|
ee as biPrevPrime,
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
ve as compare,
|
|
48
|
+
Xe as canonicalizeNewlines,
|
|
49
|
+
Ye as capitalize,
|
|
50
|
+
_e as capitalizeWords,
|
|
51
|
+
ye as ceilTo,
|
|
52
|
+
$e as chunkText,
|
|
53
|
+
Ae as clamp,
|
|
54
|
+
fe as clampInt,
|
|
55
|
+
de as clampSym,
|
|
58
56
|
c as compareArrays,
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
57
|
+
er as compareCaseInsensitive,
|
|
58
|
+
xe as compareNumbers,
|
|
59
|
+
rr as compareStrings,
|
|
62
60
|
y as concatArrays,
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
cr as containsCaseInsensitive,
|
|
69
|
-
yr as count,
|
|
61
|
+
tr as containsAllText,
|
|
62
|
+
ir as containsAllTextCaseInsensitive,
|
|
63
|
+
ar as containsAnyText,
|
|
64
|
+
sr as containsAnyTextCaseInsensitive,
|
|
65
|
+
nr as countTextOccurrences,
|
|
70
66
|
A as createFilledArray,
|
|
71
67
|
ne as curryLeft,
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
br as encodeBase64,
|
|
80
|
-
hr as endsWith,
|
|
81
|
-
vr as endsWithAny,
|
|
82
|
-
Ir as endsWithAnyCaseInsensitive,
|
|
83
|
-
Er as endsWithCaseInsensitive,
|
|
84
|
-
Or as filter,
|
|
68
|
+
or as dasherize,
|
|
69
|
+
lr as decodeBase64,
|
|
70
|
+
te as deepEqual,
|
|
71
|
+
mr as ellipsis,
|
|
72
|
+
pr as ellipsisMiddle,
|
|
73
|
+
cr as encodeBase64,
|
|
74
|
+
yr as endsWithAnyText,
|
|
85
75
|
f as filterArray,
|
|
86
|
-
|
|
76
|
+
Ar as filterCharcode,
|
|
87
77
|
d as filterMapArray,
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
Sr as isUpperCase,
|
|
119
|
-
g as joinArrayWithConjunction,
|
|
120
|
-
zr as jsQuote,
|
|
78
|
+
x as filterNullsFromArray,
|
|
79
|
+
fr as filterText,
|
|
80
|
+
g as flatMapArray,
|
|
81
|
+
u as flattenArray,
|
|
82
|
+
ge as floorTo,
|
|
83
|
+
C as foldLeftArray,
|
|
84
|
+
b as forEachElement,
|
|
85
|
+
v as generateArray,
|
|
86
|
+
h as generateSequenceArray,
|
|
87
|
+
dr as humanize,
|
|
88
|
+
oe as identity,
|
|
89
|
+
xr as ifEmptyString,
|
|
90
|
+
ue as interpolate,
|
|
91
|
+
Ce as interpolateAngle,
|
|
92
|
+
be as interpolateAngleCCW,
|
|
93
|
+
ve as interpolateAngleCW,
|
|
94
|
+
he as interpolateWidestAngle,
|
|
95
|
+
gr as isAlpha,
|
|
96
|
+
ur as isAlphaNum,
|
|
97
|
+
S as isArrayEmpty,
|
|
98
|
+
Cr as isBreakingWhitespace,
|
|
99
|
+
br as isDigitsOnly,
|
|
100
|
+
we as isEmptyObject,
|
|
101
|
+
vr as isEmptyString,
|
|
102
|
+
hr as isLowerCase,
|
|
103
|
+
Be as isObject,
|
|
104
|
+
Sr as isSpaceAt,
|
|
105
|
+
Er as isUpperCase,
|
|
106
|
+
E as joinArrayWithConjunction,
|
|
107
|
+
Ir as jsQuote,
|
|
121
108
|
ie as looseEqual,
|
|
122
109
|
Tr as lowerCaseFirst,
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
110
|
+
Or as lpad,
|
|
111
|
+
I as mapArray,
|
|
112
|
+
Fr as mapChars,
|
|
113
|
+
Re as mapRegExp,
|
|
114
|
+
le as memoize,
|
|
115
|
+
De as mergeObjects,
|
|
116
|
+
Se as nearEqualAngles,
|
|
117
|
+
Ee as nearEquals,
|
|
118
|
+
Ie as nearZero,
|
|
119
|
+
Ne as objectKeys,
|
|
120
|
+
Wr as quote,
|
|
121
|
+
qr as randomString,
|
|
122
|
+
Lr as randomStringSequence,
|
|
123
|
+
Pr as randomStringSequenceBase64,
|
|
124
|
+
T as rankArray,
|
|
125
|
+
O as removeAllFromArray,
|
|
126
|
+
F as removeAllFromArrayByPredicate,
|
|
127
|
+
jr as removeFirstFromString,
|
|
128
|
+
wr as removeFromString,
|
|
129
|
+
Br as removeFromStringAfter,
|
|
130
|
+
Dr as removeFromStringBefore,
|
|
131
|
+
ze as removeObjectFields,
|
|
132
|
+
W as removeOneFromArray,
|
|
133
|
+
q as removeOneFromArrayByPredicate,
|
|
134
|
+
Nr as removeSliceFromString,
|
|
135
|
+
zr as repeatString,
|
|
136
|
+
Hr as replaceAll,
|
|
137
|
+
Mr as reverseString,
|
|
138
|
+
Te as root,
|
|
139
|
+
Oe as roundTo,
|
|
140
|
+
Rr as rpad,
|
|
141
|
+
He as sameObjectKeys,
|
|
142
|
+
Fe as sign,
|
|
143
|
+
kr as smartQuote,
|
|
144
|
+
L as sortArray,
|
|
145
|
+
Vr as splitOnFirst,
|
|
146
|
+
Kr as splitOnLast,
|
|
147
|
+
Qr as splitStringOnce,
|
|
148
|
+
ae as strictEqual,
|
|
149
|
+
Zr as stringHasContent,
|
|
150
|
+
Gr as stringHashCode,
|
|
151
|
+
Ur as stringToCharcodes,
|
|
152
|
+
Jr as stringToChars,
|
|
153
|
+
Xr as stringToLines,
|
|
154
|
+
Yr as stringsDifferAtIndex,
|
|
155
|
+
_r as surroundText,
|
|
156
|
+
$r as textCollapse,
|
|
157
|
+
et as textContains,
|
|
158
|
+
rt as textContainsCaseInsensitive,
|
|
159
|
+
tt as textEndsWith,
|
|
160
|
+
it as textEndsWithAnyCaseInsensitive,
|
|
161
|
+
at as textEndsWithCaseInsensitive,
|
|
162
|
+
st as textStartsWith,
|
|
163
|
+
nt as textStartsWithAny,
|
|
164
|
+
ot as textStartsWithAnyCaseInsensitive,
|
|
165
|
+
lt as textStartsWithCaseInsensitive,
|
|
166
|
+
We as toHex,
|
|
167
|
+
mt as trimChars,
|
|
168
|
+
pt as trimCharsLeft,
|
|
169
|
+
ct as trimCharsRight,
|
|
170
|
+
yt as underscore,
|
|
171
|
+
P as uniqueByPredicate,
|
|
172
|
+
j as uniquePrimitives,
|
|
173
|
+
At as upperCaseFirst,
|
|
174
|
+
qe as widestAngleDifference,
|
|
175
|
+
Le as wrap,
|
|
176
|
+
Pe as wrapCircular,
|
|
177
|
+
ft as wrapColumns,
|
|
178
|
+
dt as wrapLine
|
|
185
179
|
};
|
package/number.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./string.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./string.cjs"),l=1e-9;function u(e,n,t=360){let r=(n-e)%t;return r<0&&(r+=t),r>t/2&&(r-=t),r}function s(e,n){const t=Math.pow(10,n);return Math.ceil(e*t)/t}function f(e,n,t){return Math.min(Math.max(e,n),t)}function p(e,n,t){return Math.trunc(f(e,n,t))}function g(e,n){return f(e,-n,n)}function M(e,n){return e<n?-1:e>n?1:0}function h(e,n){const t=Math.pow(10,n);return Math.floor(e*t)/t}function A(e,n=0){return a.lpad(e.toString(16),"0",n)}function o(e,n,t){return(n-e)*t+e}function d(e,n,t,r=360){return i(o(e,e+u(e,n,r),t),r)}function c(e,n,t=360){let r=(n-e)%t;return r<0&&(r+=t),r>t/2&&(r-=t),r}function w(e,n,t,r=360){return i(o(e,e+c(e,n,r),t),r)}function N(e,n,t,r=360){return e=i(e,r),n=i(n,r),n<e&&(n+=r),i(o(e,n,t),r)}function m(e,n,t,r=360){return e=i(e,r),n=i(n,r),n>e&&(n-=r),i(o(e,n,t),r)}function C(e,n,t=l){return isFinite(e)?isFinite(n)?Math.abs(e-n)<=t:!1:isNaN(e)?isNaN(n):isNaN(n)||isFinite(n)?!1:e>0==n>0}function S(e,n,t=360,r=l){return Math.abs(u(e,n,t))<=r}function T(e,n=l){return Math.abs(e)<=n}function E(e,n){return Math.pow(e,1/n)}function W(e,n){const t=Math.pow(10,n);return Math.round(e*t)/t}function q(e){return e<0?-1:1}function y(e,n,t){const r=t-n+1;return e<n&&(e+=r*((n-e)/r+1)),n+(e-n)%r}function i(e,n){return e=e%n,e<0&&(e+=n),e}exports.EPSILON=l;exports.angleDifference=u;exports.ceilTo=s;exports.clamp=f;exports.clampInt=p;exports.clampSym=g;exports.compareNumbers=M;exports.floorTo=h;exports.interpolate=o;exports.interpolateAngle=d;exports.interpolateAngleCCW=m;exports.interpolateAngleCW=N;exports.interpolateWidestAngle=w;exports.nearEqualAngles=S;exports.nearEquals=C;exports.nearZero=T;exports.root=E;exports.roundTo=W;exports.sign=q;exports.toHex=A;exports.widestAngleDifference=c;exports.wrap=y;exports.wrapCircular=i;
|
package/number.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export declare const TOLERANCE = 0.0001;
|
|
2
1
|
/**
|
|
3
2
|
Constant value employed to see if two `number` values are very close.
|
|
4
3
|
**/
|
|
@@ -11,6 +10,7 @@ export declare const EPSILON = 1e-9;
|
|
|
11
10
|
* @param turn - The total number of degrees in a full turn. Default is 360.0.
|
|
12
11
|
* @returns The difference between the two angles.
|
|
13
12
|
* @public
|
|
13
|
+
* @remarks
|
|
14
14
|
* @example
|
|
15
15
|
* ```ts
|
|
16
16
|
* angleDifference(0, 90) // returns 90
|
|
@@ -27,6 +27,7 @@ export declare function angleDifference(a: number, b: number, turn?: number): nu
|
|
|
27
27
|
* @param decimals - The number of decimals to round up to.
|
|
28
28
|
* @returns The rounded up number.
|
|
29
29
|
* @public
|
|
30
|
+
* @remarks
|
|
30
31
|
* @example
|
|
31
32
|
* ```ts
|
|
32
33
|
* ceilTo(1.234, 2) // returns 1.24
|
|
@@ -43,6 +44,7 @@ export declare function ceilTo(v: number, decimals: number): number;
|
|
|
43
44
|
* @param max - The maximum value.
|
|
44
45
|
* @returns The clamped value.
|
|
45
46
|
* @public
|
|
47
|
+
* @remarks
|
|
46
48
|
* @example
|
|
47
49
|
* ```ts
|
|
48
50
|
* clamp(1.3, 0, 1) // returns 1
|
|
@@ -59,6 +61,7 @@ export declare function clamp(value: number, min: number, max: number): number;
|
|
|
59
61
|
* @param max - The maximum value of the range.
|
|
60
62
|
* @returns The clamped integer value.
|
|
61
63
|
* @public
|
|
64
|
+
* @remarks
|
|
62
65
|
* @example
|
|
63
66
|
* ```ts
|
|
64
67
|
* clampInt(5, 0, 10) // returns 5
|
|
@@ -75,6 +78,7 @@ export declare function clampInt(value: number, min: number, max: number): numbe
|
|
|
75
78
|
* @param max - The maximum value.
|
|
76
79
|
* @returns The clamped value.
|
|
77
80
|
* @public
|
|
81
|
+
* @remarks
|
|
78
82
|
* @example
|
|
79
83
|
* ```ts
|
|
80
84
|
* clampSym(5, 10) // returns 5
|
|
@@ -91,6 +95,7 @@ export declare function clampSym(v: number, max: number): number;
|
|
|
91
95
|
* @param b - The second value to compare.
|
|
92
96
|
* @returns A number indicating the relative order of the two values.
|
|
93
97
|
* @public
|
|
98
|
+
* @remarks
|
|
94
99
|
* @example
|
|
95
100
|
* ```ts
|
|
96
101
|
* compare(5, 10) // returns -1
|
|
@@ -98,7 +103,7 @@ export declare function clampSym(v: number, max: number): number;
|
|
|
98
103
|
* compare(5, 5) // returns 0
|
|
99
104
|
* ```
|
|
100
105
|
**/
|
|
101
|
-
export declare function
|
|
106
|
+
export declare function compareNumbers(a: number, b: number): number;
|
|
102
107
|
/**
|
|
103
108
|
* Rounds a number down to the specified number of decimals.
|
|
104
109
|
*
|
|
@@ -106,6 +111,7 @@ export declare function compare(a: number, b: number): number;
|
|
|
106
111
|
* @param decimals - The number of decimals to round down to.
|
|
107
112
|
* @returns The rounded down number.
|
|
108
113
|
* @public
|
|
114
|
+
* @remarks
|
|
109
115
|
* @example
|
|
110
116
|
* ```ts
|
|
111
117
|
* floorTo(1.234, 2) // returns 1.23
|
|
@@ -121,6 +127,7 @@ export declare function floorTo(v: number, decimals: number): number;
|
|
|
121
127
|
* @param length - The desired length of the hexadecimal string. Defaults to 0.
|
|
122
128
|
* @returns The hexadecimal representation of the number.
|
|
123
129
|
* @public
|
|
130
|
+
* @remarks
|
|
124
131
|
* @example
|
|
125
132
|
* ```ts
|
|
126
133
|
* toHex(255) // returns 'ff'
|
|
@@ -137,6 +144,7 @@ export declare function toHex(num: number, length?: number): string;
|
|
|
137
144
|
* @param t - The interpolation value.
|
|
138
145
|
* @returns The interpolated value.
|
|
139
146
|
* @public
|
|
147
|
+
* @remarks
|
|
140
148
|
* @example
|
|
141
149
|
* ```ts
|
|
142
150
|
* interpolate(0, 10, 0.5) // returns 5
|
|
@@ -155,6 +163,7 @@ export declare function interpolate(a: number, b: number, t: number): number;
|
|
|
155
163
|
* @param turn - The total number of degrees in a full turn. Default is 360.0.
|
|
156
164
|
* @returns The interpolated angle.
|
|
157
165
|
* @public
|
|
166
|
+
* @remarks
|
|
158
167
|
* @example
|
|
159
168
|
* ```ts
|
|
160
169
|
* interpolateAngle(0, 90, 0.5) // returns 45
|
|
@@ -172,6 +181,7 @@ export declare function interpolateAngle(a: number, b: number, t: number, turn?:
|
|
|
172
181
|
* @param turn - The total angle of a full turn. Defaults to 360 degrees.
|
|
173
182
|
* @returns The widest angle difference between `a` and `b`.
|
|
174
183
|
* @public
|
|
184
|
+
* @remarks
|
|
175
185
|
* @example
|
|
176
186
|
* ```ts
|
|
177
187
|
* widestAngleDifference(0, 90) // returns 90
|
|
@@ -191,6 +201,7 @@ export declare function widestAngleDifference(a: number, b: number, turn?: numbe
|
|
|
191
201
|
* @param turn - The total number of degrees in a full turn. Default is 360.0.
|
|
192
202
|
* @returns The interpolated angle.
|
|
193
203
|
* @public
|
|
204
|
+
* @remarks
|
|
194
205
|
* @example
|
|
195
206
|
* ```ts
|
|
196
207
|
* interpolateWidestAngle(0, 90, 0.5) // returns 45
|
|
@@ -209,6 +220,7 @@ export declare function interpolateWidestAngle(a: number, b: number, t: number,
|
|
|
209
220
|
* @param turn - The total number of degrees in a full turn. Default is 360.0.
|
|
210
221
|
* @returns The interpolated angle.
|
|
211
222
|
* @public
|
|
223
|
+
* @remarks
|
|
212
224
|
* @example
|
|
213
225
|
* ```ts
|
|
214
226
|
* interpolateAngleCW(0, 90, 0.5) // returns 45
|
|
@@ -227,6 +239,7 @@ export declare function interpolateAngleCW(a: number, b: number, t: number, turn
|
|
|
227
239
|
* @param turn - The total number of degrees in a full turn. Default is 360.0.
|
|
228
240
|
* @returns The interpolated angle.
|
|
229
241
|
* @public
|
|
242
|
+
* @remarks
|
|
230
243
|
* @example
|
|
231
244
|
* ```ts
|
|
232
245
|
* interpolateAngleCCW(0, 90, 0.5) // returns 45
|
|
@@ -246,6 +259,7 @@ export declare function interpolateAngleCCW(a: number, b: number, t: number, tur
|
|
|
246
259
|
* @param tollerance - The tollerance value. Default is `EPSILON`.
|
|
247
260
|
* @returns `true` if the numbers are very close, `false` otherwise.
|
|
248
261
|
* @public
|
|
262
|
+
* @remarks
|
|
249
263
|
* @example
|
|
250
264
|
* ```ts
|
|
251
265
|
* nearEquals(5, 5.000000000000001) // returns true
|
|
@@ -266,6 +280,7 @@ export declare function nearEquals(a: number, b: number, tollerance?: number): b
|
|
|
266
280
|
* @param tollerance - The tollerance value. Default is `EPSILON`.
|
|
267
281
|
* @returns `true` if the angles are very close, `false` otherwise.
|
|
268
282
|
* @public
|
|
283
|
+
* @remarks
|
|
269
284
|
* @example
|
|
270
285
|
* ```ts
|
|
271
286
|
* nearEqualAngles(0, 360) // returns true
|
|
@@ -283,6 +298,7 @@ export declare function nearEqualAngles(a: number, b: number, turn?: number, tol
|
|
|
283
298
|
* @param tollerance - The tollerance value. Default is `EPSILON`.
|
|
284
299
|
* @returns `true` if the number is zero or very close to it, `false` otherwise.
|
|
285
300
|
* @public
|
|
301
|
+
* @remarks
|
|
286
302
|
* @example
|
|
287
303
|
* ```ts
|
|
288
304
|
* nearZero(0.000000000000001) // returns true
|
|
@@ -298,6 +314,7 @@ export declare function nearZero(n: number, tollerance?: number): boolean;
|
|
|
298
314
|
* @param index - The index of the root.
|
|
299
315
|
* @returns The nth root of the base number.
|
|
300
316
|
* @public
|
|
317
|
+
* @remarks
|
|
301
318
|
* @example
|
|
302
319
|
* ```ts
|
|
303
320
|
* root(8, 3) // returns 2
|
|
@@ -313,6 +330,7 @@ export declare function root(base: number, index: number): number;
|
|
|
313
330
|
* @param decimals - The number of decimals to round to.
|
|
314
331
|
* @returns The rounded number.
|
|
315
332
|
* @public
|
|
333
|
+
* @remarks
|
|
316
334
|
* @example
|
|
317
335
|
* ```ts
|
|
318
336
|
* roundTo(1.234, 2) // returns 1.23
|
|
@@ -327,6 +345,7 @@ export declare function roundTo(f: number, decimals: number): number;
|
|
|
327
345
|
* @param value - The number to check.
|
|
328
346
|
* @returns `-1` if the number is negative, `1` otherwise.
|
|
329
347
|
* @public
|
|
348
|
+
* @remarks
|
|
330
349
|
* @example
|
|
331
350
|
* ```ts
|
|
332
351
|
* sign(-5) // returns -1
|
|
@@ -345,6 +364,7 @@ export declare function sign<T extends number>(value: T): number;
|
|
|
345
364
|
* @param max - The maximum value of the range.
|
|
346
365
|
* @returns The wrapped value.
|
|
347
366
|
* @public
|
|
367
|
+
* @remarks
|
|
348
368
|
* @example
|
|
349
369
|
* ```ts
|
|
350
370
|
* wrap(5, 0, 10) // returns 5
|
|
@@ -360,6 +380,7 @@ export declare function wrap(v: number, min: number, max: number): number;
|
|
|
360
380
|
* @param max - The maximum value of the range.
|
|
361
381
|
* @returns The wrapped value.
|
|
362
382
|
* @public
|
|
383
|
+
* @remarks
|
|
363
384
|
* @example
|
|
364
385
|
* ```ts
|
|
365
386
|
* wrapCircular(5, 10) // returns 5
|
package/number.js
CHANGED
|
@@ -1,55 +1,55 @@
|
|
|
1
1
|
import { lpad as l } from "./string.js";
|
|
2
|
-
const
|
|
2
|
+
const f = 1e-9;
|
|
3
3
|
function u(n, t, e = 360) {
|
|
4
4
|
let r = (t - n) % e;
|
|
5
5
|
return r < 0 && (r += e), r > e / 2 && (r -= e), r;
|
|
6
6
|
}
|
|
7
|
-
function
|
|
7
|
+
function p(n, t) {
|
|
8
8
|
const e = Math.pow(10, t);
|
|
9
9
|
return Math.ceil(n * e) / e;
|
|
10
10
|
}
|
|
11
11
|
function c(n, t, e) {
|
|
12
12
|
return Math.min(Math.max(n, t), e);
|
|
13
13
|
}
|
|
14
|
-
function
|
|
14
|
+
function h(n, t, e) {
|
|
15
15
|
return Math.trunc(c(n, t, e));
|
|
16
16
|
}
|
|
17
|
-
function
|
|
17
|
+
function M(n, t) {
|
|
18
18
|
return c(n, -t, t);
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function g(n, t) {
|
|
21
21
|
return n < t ? -1 : n > t ? 1 : 0;
|
|
22
22
|
}
|
|
23
|
-
function
|
|
23
|
+
function N(n, t) {
|
|
24
24
|
const e = Math.pow(10, t);
|
|
25
25
|
return Math.floor(n * e) / e;
|
|
26
26
|
}
|
|
27
|
-
function
|
|
27
|
+
function w(n, t = 0) {
|
|
28
28
|
return l(n.toString(16), "0", t);
|
|
29
29
|
}
|
|
30
30
|
function o(n, t, e) {
|
|
31
31
|
return (t - n) * e + n;
|
|
32
32
|
}
|
|
33
|
-
function
|
|
33
|
+
function A(n, t, e, r = 360) {
|
|
34
34
|
return i(o(n, n + u(n, t, r), e), r);
|
|
35
35
|
}
|
|
36
36
|
function a(n, t, e = 360) {
|
|
37
37
|
let r = (t - n) % e;
|
|
38
38
|
return r < 0 && (r += e), r > e / 2 && (r -= e), r;
|
|
39
39
|
}
|
|
40
|
-
function
|
|
40
|
+
function d(n, t, e, r = 360) {
|
|
41
41
|
return i(
|
|
42
42
|
o(n, n + a(n, t, r), e),
|
|
43
43
|
r
|
|
44
44
|
);
|
|
45
45
|
}
|
|
46
|
-
function
|
|
46
|
+
function m(n, t, e, r = 360) {
|
|
47
47
|
return n = i(n, r), t = i(t, r), t < n && (t += r), i(o(n, t, e), r);
|
|
48
48
|
}
|
|
49
|
-
function
|
|
49
|
+
function C(n, t, e, r = 360) {
|
|
50
50
|
return n = i(n, r), t = i(t, r), t > n && (t -= r), i(o(n, t, e), r);
|
|
51
51
|
}
|
|
52
|
-
function
|
|
52
|
+
function E(n, t, e = f) {
|
|
53
53
|
return isFinite(n) ? isFinite(t) ? Math.abs(n - t) <= e : !1 : isNaN(n) ? isNaN(t) : isNaN(t) || isFinite(t) ? !1 : n > 0 == t > 0;
|
|
54
54
|
}
|
|
55
55
|
function F(n, t, e = 360, r = f) {
|
|
@@ -58,17 +58,17 @@ function F(n, t, e = 360, r = f) {
|
|
|
58
58
|
function S(n, t = f) {
|
|
59
59
|
return Math.abs(n) <= t;
|
|
60
60
|
}
|
|
61
|
-
function
|
|
61
|
+
function T(n, t) {
|
|
62
62
|
return Math.pow(n, 1 / t);
|
|
63
63
|
}
|
|
64
|
-
function
|
|
64
|
+
function W(n, t) {
|
|
65
65
|
const e = Math.pow(10, t);
|
|
66
66
|
return Math.round(n * e) / e;
|
|
67
67
|
}
|
|
68
|
-
function
|
|
68
|
+
function q(n) {
|
|
69
69
|
return n < 0 ? -1 : 1;
|
|
70
70
|
}
|
|
71
|
-
function
|
|
71
|
+
function D(n, t, e) {
|
|
72
72
|
const r = e - t + 1;
|
|
73
73
|
return n < t && (n += r * ((t - n) / r + 1)), t + (n - t) % r;
|
|
74
74
|
}
|
|
@@ -77,27 +77,26 @@ function i(n, t) {
|
|
|
77
77
|
}
|
|
78
78
|
export {
|
|
79
79
|
f as EPSILON,
|
|
80
|
-
p as TOLERANCE,
|
|
81
80
|
u as angleDifference,
|
|
82
|
-
|
|
81
|
+
p as ceilTo,
|
|
83
82
|
c as clamp,
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
83
|
+
h as clampInt,
|
|
84
|
+
M as clampSym,
|
|
85
|
+
g as compareNumbers,
|
|
86
|
+
N as floorTo,
|
|
88
87
|
o as interpolate,
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
88
|
+
A as interpolateAngle,
|
|
89
|
+
C as interpolateAngleCCW,
|
|
90
|
+
m as interpolateAngleCW,
|
|
91
|
+
d as interpolateWidestAngle,
|
|
93
92
|
F as nearEqualAngles,
|
|
94
|
-
|
|
93
|
+
E as nearEquals,
|
|
95
94
|
S as nearZero,
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
95
|
+
T as root,
|
|
96
|
+
W as roundTo,
|
|
97
|
+
q as sign,
|
|
98
|
+
w as toHex,
|
|
100
99
|
a as widestAngleDifference,
|
|
101
|
-
|
|
100
|
+
D as wrap,
|
|
102
101
|
i as wrapCircular
|
|
103
102
|
};
|