rattail 1.0.11 → 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 +18 -2
- package/lib/index.js +18 -2
- package/package.json +1 -1
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 };
|
package/lib/index.global.js
CHANGED
|
@@ -40,9 +40,11 @@ var Rattail = (() => {
|
|
|
40
40
|
__export(src_exports, {
|
|
41
41
|
NOOP: () => NOOP,
|
|
42
42
|
at: () => at,
|
|
43
|
+
baseRound: () => baseRound,
|
|
43
44
|
call: () => call,
|
|
44
45
|
camelize: () => camelize,
|
|
45
46
|
cancelAnimationFrame: () => cancelAnimationFrame,
|
|
47
|
+
ceil: () => ceil,
|
|
46
48
|
chunk: () => chunk,
|
|
47
49
|
clamp: () => clamp,
|
|
48
50
|
clampArrayRange: () => clampArrayRange,
|
|
@@ -61,6 +63,7 @@ var Rattail = (() => {
|
|
|
61
63
|
ensurePrefix: () => ensurePrefix,
|
|
62
64
|
ensureSuffix: () => ensureSuffix,
|
|
63
65
|
find: () => find,
|
|
66
|
+
floor: () => floor,
|
|
64
67
|
genNumberKey: () => genNumberKey,
|
|
65
68
|
genStringKey: () => genStringKey,
|
|
66
69
|
getAllParentScroller: () => getAllParentScroller,
|
|
@@ -1344,12 +1347,25 @@ var Rattail = (() => {
|
|
|
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
|
return __toCommonJS(src_exports);
|
|
1355
1371
|
})();
|
package/lib/index.js
CHANGED
|
@@ -1199,19 +1199,34 @@ function sample(arr) {
|
|
|
1199
1199
|
|
|
1200
1200
|
// src/math/round.ts
|
|
1201
1201
|
function round(val, precision = 0) {
|
|
1202
|
+
return baseRound(val, precision, Math.round);
|
|
1203
|
+
}
|
|
1204
|
+
function baseRound(val, precision = 0, fn) {
|
|
1202
1205
|
precision = clamp(precision, -292, 292);
|
|
1203
1206
|
if (!precision) {
|
|
1204
|
-
return
|
|
1207
|
+
return fn(val);
|
|
1205
1208
|
}
|
|
1206
|
-
const value =
|
|
1209
|
+
const value = fn(`${val}e${precision}`);
|
|
1207
1210
|
return +`${value}e${-precision}`;
|
|
1208
1211
|
}
|
|
1212
|
+
|
|
1213
|
+
// src/math/floor.ts
|
|
1214
|
+
function floor(val, precision = 0) {
|
|
1215
|
+
return baseRound(val, precision, Math.floor);
|
|
1216
|
+
}
|
|
1217
|
+
|
|
1218
|
+
// src/math/ceil.ts
|
|
1219
|
+
function ceil(val, precision = 0) {
|
|
1220
|
+
return baseRound(val, precision, Math.ceil);
|
|
1221
|
+
}
|
|
1209
1222
|
export {
|
|
1210
1223
|
NOOP,
|
|
1211
1224
|
at,
|
|
1225
|
+
baseRound,
|
|
1212
1226
|
call,
|
|
1213
1227
|
camelize,
|
|
1214
1228
|
cancelAnimationFrame,
|
|
1229
|
+
ceil,
|
|
1215
1230
|
chunk,
|
|
1216
1231
|
clamp,
|
|
1217
1232
|
clampArrayRange,
|
|
@@ -1230,6 +1245,7 @@ export {
|
|
|
1230
1245
|
ensurePrefix,
|
|
1231
1246
|
ensureSuffix,
|
|
1232
1247
|
find,
|
|
1248
|
+
floor,
|
|
1233
1249
|
genNumberKey,
|
|
1234
1250
|
genStringKey,
|
|
1235
1251
|
getAllParentScroller,
|