rattail 1.0.10 → 1.0.12
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/lib/index.cjs +21 -2
- package/lib/index.d.cts +6 -1
- package/lib/index.d.ts +6 -1
- package/lib/index.global.js +1371 -0
- package/lib/index.js +18 -2
- package/package.json +4 -2
package/lib/index.cjs
CHANGED
|
@@ -39,9 +39,11 @@ var src_exports = {};
|
|
|
39
39
|
__export(src_exports, {
|
|
40
40
|
NOOP: () => NOOP,
|
|
41
41
|
at: () => at,
|
|
42
|
+
baseRound: () => baseRound,
|
|
42
43
|
call: () => call,
|
|
43
44
|
camelize: () => camelize,
|
|
44
45
|
cancelAnimationFrame: () => cancelAnimationFrame,
|
|
46
|
+
ceil: () => ceil,
|
|
45
47
|
chunk: () => chunk,
|
|
46
48
|
clamp: () => clamp,
|
|
47
49
|
clampArrayRange: () => clampArrayRange,
|
|
@@ -60,6 +62,7 @@ __export(src_exports, {
|
|
|
60
62
|
ensurePrefix: () => ensurePrefix,
|
|
61
63
|
ensureSuffix: () => ensureSuffix,
|
|
62
64
|
find: () => find,
|
|
65
|
+
floor: () => floor,
|
|
63
66
|
genNumberKey: () => genNumberKey,
|
|
64
67
|
genStringKey: () => genStringKey,
|
|
65
68
|
getAllParentScroller: () => getAllParentScroller,
|
|
@@ -1344,20 +1347,35 @@ function sample(arr) {
|
|
|
1344
1347
|
|
|
1345
1348
|
// src/math/round.ts
|
|
1346
1349
|
function round(val, precision = 0) {
|
|
1350
|
+
return baseRound(val, precision, Math.round);
|
|
1351
|
+
}
|
|
1352
|
+
function baseRound(val, precision = 0, fn) {
|
|
1347
1353
|
precision = clamp(precision, -292, 292);
|
|
1348
1354
|
if (!precision) {
|
|
1349
|
-
return
|
|
1355
|
+
return fn(val);
|
|
1350
1356
|
}
|
|
1351
|
-
const value =
|
|
1357
|
+
const value = fn(`${val}e${precision}`);
|
|
1352
1358
|
return +`${value}e${-precision}`;
|
|
1353
1359
|
}
|
|
1360
|
+
|
|
1361
|
+
// src/math/floor.ts
|
|
1362
|
+
function floor(val, precision = 0) {
|
|
1363
|
+
return baseRound(val, precision, Math.floor);
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1366
|
+
// src/math/ceil.ts
|
|
1367
|
+
function ceil(val, precision = 0) {
|
|
1368
|
+
return baseRound(val, precision, Math.ceil);
|
|
1369
|
+
}
|
|
1354
1370
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1355
1371
|
0 && (module.exports = {
|
|
1356
1372
|
NOOP,
|
|
1357
1373
|
at,
|
|
1374
|
+
baseRound,
|
|
1358
1375
|
call,
|
|
1359
1376
|
camelize,
|
|
1360
1377
|
cancelAnimationFrame,
|
|
1378
|
+
ceil,
|
|
1361
1379
|
chunk,
|
|
1362
1380
|
clamp,
|
|
1363
1381
|
clampArrayRange,
|
|
@@ -1376,6 +1394,7 @@ function round(val, precision = 0) {
|
|
|
1376
1394
|
ensurePrefix,
|
|
1377
1395
|
ensureSuffix,
|
|
1378
1396
|
find,
|
|
1397
|
+
floor,
|
|
1379
1398
|
genNumberKey,
|
|
1380
1399
|
genStringKey,
|
|
1381
1400
|
getAllParentScroller,
|
package/lib/index.d.cts
CHANGED
|
@@ -262,5 +262,10 @@ declare function meanBy<T>(arr: T[], fn: (val: T) => number): number;
|
|
|
262
262
|
declare function sample<T>(arr: T[]): T | undefined;
|
|
263
263
|
|
|
264
264
|
declare function round(val: number, precision?: number): number;
|
|
265
|
+
declare function baseRound(val: number, precision: number | undefined, fn: (val: number) => number): number;
|
|
265
266
|
|
|
266
|
-
|
|
267
|
+
declare function floor(val: number, precision?: number): number;
|
|
268
|
+
|
|
269
|
+
declare function ceil(val: number, precision?: number): number;
|
|
270
|
+
|
|
271
|
+
export { type BEM, type ClassName, type Classes, NOOP, type PromiseWithResolvers, type Storage, at, baseRound, call, camelize, cancelAnimationFrame, ceil, chunk, clamp, clampArrayRange, classes, cloneDeep, cloneDeepWith, copyText, createNamespaceFn, createStorage, debounce, delay, difference, differenceWith, doubleRaf, download, ensurePrefix, ensureSuffix, find, floor, genNumberKey, genStringKey, getAllParentScroller, getGlobalThis, getParentScroller, getRect, getScrollLeft, getScrollTop, getStyle, groupBy, hasOwn, inBrowser, inMobile, inViewport, intersection, intersectionWith, isArray, isArrayBuffer, isBlob, isBoolean, isDOMException, isDataView, isDate, isEmpty, isEqual, isEqualWith, isError, isFile, isFunction, isMap, isNonEmptyArray, isNullish, isNumber, isNumeric, isObject, isPlainObject, isPrimitive, isPromise, isRegExp, isSet, isString, isSymbol, isTruthy, isTypedArray, isWeakMap, isWeakSet, isWindow, kebabCase, localStorage, lowerFirst, mapObject, maxBy, mean, meanBy, merge, mergeWith, minBy, normalizeToArray, objectToString, omit, omitBy, once, pascalCase, pick, pickBy, prettyJSONObject, preventDefault, promiseWithResolvers, raf, randomColor, randomNumber, randomString, removeArrayBlank, removeArrayEmpty, removeItem, requestAnimationFrame, round, sample, sessionStorage, shuffle, slash, sum, sumBy, sumHash, supportTouch, throttle, times, toArrayBuffer, toDataURL, toNumber, toRawType, toText, toTypeString, toggleItem, tryParseJSON, uniq, uniqBy, upperFirst, xor, xorWith };
|
package/lib/index.d.ts
CHANGED
|
@@ -262,5 +262,10 @@ declare function meanBy<T>(arr: T[], fn: (val: T) => number): number;
|
|
|
262
262
|
declare function sample<T>(arr: T[]): T | undefined;
|
|
263
263
|
|
|
264
264
|
declare function round(val: number, precision?: number): number;
|
|
265
|
+
declare function baseRound(val: number, precision: number | undefined, fn: (val: number) => number): number;
|
|
265
266
|
|
|
266
|
-
|
|
267
|
+
declare function floor(val: number, precision?: number): number;
|
|
268
|
+
|
|
269
|
+
declare function ceil(val: number, precision?: number): number;
|
|
270
|
+
|
|
271
|
+
export { type BEM, type ClassName, type Classes, NOOP, type PromiseWithResolvers, type Storage, at, baseRound, call, camelize, cancelAnimationFrame, ceil, chunk, clamp, clampArrayRange, classes, cloneDeep, cloneDeepWith, copyText, createNamespaceFn, createStorage, debounce, delay, difference, differenceWith, doubleRaf, download, ensurePrefix, ensureSuffix, find, floor, genNumberKey, genStringKey, getAllParentScroller, getGlobalThis, getParentScroller, getRect, getScrollLeft, getScrollTop, getStyle, groupBy, hasOwn, inBrowser, inMobile, inViewport, intersection, intersectionWith, isArray, isArrayBuffer, isBlob, isBoolean, isDOMException, isDataView, isDate, isEmpty, isEqual, isEqualWith, isError, isFile, isFunction, isMap, isNonEmptyArray, isNullish, isNumber, isNumeric, isObject, isPlainObject, isPrimitive, isPromise, isRegExp, isSet, isString, isSymbol, isTruthy, isTypedArray, isWeakMap, isWeakSet, isWindow, kebabCase, localStorage, lowerFirst, mapObject, maxBy, mean, meanBy, merge, mergeWith, minBy, normalizeToArray, objectToString, omit, omitBy, once, pascalCase, pick, pickBy, prettyJSONObject, preventDefault, promiseWithResolvers, raf, randomColor, randomNumber, randomString, removeArrayBlank, removeArrayEmpty, removeItem, requestAnimationFrame, round, sample, sessionStorage, shuffle, slash, sum, sumBy, sumHash, supportTouch, throttle, times, toArrayBuffer, toDataURL, toNumber, toRawType, toText, toTypeString, toggleItem, tryParseJSON, uniq, uniqBy, upperFirst, xor, xorWith };
|