@antfu/utils
Advanced tools
+20
-1
@@ -98,2 +98,17 @@ /** | ||
| declare function range(start: number, stop: number, step?: number): number[]; | ||
| /** | ||
| * Move element in an Array | ||
| * | ||
| * @category Array | ||
| * @param arr | ||
| * @param from | ||
| * @param to | ||
| */ | ||
| declare function move<T>(arr: T[], from: number, to: number): T[]; | ||
| /** | ||
| * Clamp a number to the index ranage of an array | ||
| * | ||
| * @category Array | ||
| */ | ||
| declare function clampArrayRange(n: number, arr: readonly unknown[]): number; | ||
@@ -107,2 +122,3 @@ declare const assert: (condition: boolean, ...infos: any[]) => void; | ||
| * | ||
| * @category Guards | ||
| * @example array.filter(notNullish) | ||
@@ -114,2 +130,3 @@ */ | ||
| * | ||
| * @category Guards | ||
| * @example array.filter(noNull) | ||
@@ -121,2 +138,3 @@ */ | ||
| * | ||
| * @category Guards | ||
| * @example array.filter(notUndefined) | ||
@@ -128,2 +146,3 @@ */ | ||
| * | ||
| * @category Guards | ||
| * @example array.filter(isTruthy) | ||
@@ -249,2 +268,2 @@ */ | ||
| export { ArgumentsType, Arrayable, Awaitable, DeepMerge, ElementOf, Fn, MergeInsertions, Nullable, SingletonPromiseReturn, UnionToIntersection, assert, at, batchInvoke, clamp, createSingletonPromise, deepMerge, flattenArrayable, invoke, isBoolean, isBrowser, isDef, isFunction, isKeyOf, isNumber, isObject, isString, isTruthy, isWindow, last, mergeArrayable, noNull, noop, notNullish, notUndefined, objectEntries, objectKeys, objectMap, objectPick, partition, range, remove, slash, sleep, sum, timestamp, toArray, toString, uniq }; | ||
| export { ArgumentsType, Arrayable, Awaitable, DeepMerge, ElementOf, Fn, MergeInsertions, Nullable, SingletonPromiseReturn, UnionToIntersection, assert, at, batchInvoke, clamp, clampArrayRange, createSingletonPromise, deepMerge, flattenArrayable, invoke, isBoolean, isBrowser, isDef, isFunction, isKeyOf, isNumber, isObject, isString, isTruthy, isWindow, last, mergeArrayable, move, noNull, noop, notNullish, notUndefined, objectEntries, objectKeys, objectMap, objectPick, partition, range, remove, slash, sleep, sum, timestamp, toArray, toString, uniq }; |
+19
-10
@@ -1,2 +0,10 @@ | ||
| "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/array.ts | ||
| "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/math.ts | ||
| function clamp(n, min, max) { | ||
| return Math.min(max, Math.max(min, n)); | ||
| } | ||
| function sum(...args) { | ||
| return flattenArrayable(args).reduce((a, b) => a + b, 0); | ||
| } | ||
| // src/array.ts | ||
| function toArray(array) { | ||
@@ -61,2 +69,9 @@ array = array || []; | ||
| } | ||
| function move(arr, from, to) { | ||
| arr.splice(to, 0, arr.splice(from, 1)[0]); | ||
| return arr; | ||
| } | ||
| function clampArrayRange(n, arr) { | ||
| return clamp(n, 0, arr.length - 1); | ||
| } | ||
@@ -96,10 +111,2 @@ // src/base.ts | ||
| // src/math.ts | ||
| function clamp(n, min, max) { | ||
| return Math.min(max, Math.max(min, n)); | ||
| } | ||
| function sum(...args) { | ||
| return flattenArrayable(args).reduce((a, b) => a + b, 0); | ||
| } | ||
| // src/path.ts | ||
@@ -227,2 +234,4 @@ function slash(str) { | ||
| exports.assert = assert; exports.at = at; exports.batchInvoke = batchInvoke; exports.clamp = clamp; exports.createSingletonPromise = createSingletonPromise; exports.deepMerge = deepMerge; exports.flattenArrayable = flattenArrayable; exports.invoke = invoke; exports.isBoolean = isBoolean; exports.isBrowser = isBrowser; exports.isDef = isDef; exports.isFunction = isFunction; exports.isKeyOf = isKeyOf; exports.isNumber = isNumber; exports.isObject = isObject; exports.isString = isString; exports.isTruthy = isTruthy; exports.isWindow = isWindow; exports.last = last; exports.mergeArrayable = mergeArrayable; exports.noNull = noNull; exports.noop = noop; exports.notNullish = notNullish; exports.notUndefined = notUndefined; exports.objectEntries = objectEntries; exports.objectKeys = objectKeys; exports.objectMap = objectMap; exports.objectPick = objectPick; exports.partition = partition; exports.range = range; exports.remove = remove; exports.slash = slash; exports.sleep = sleep; exports.sum = sum; exports.timestamp = timestamp; exports.toArray = toArray; exports.toString = toString2; exports.uniq = uniq; | ||
| exports.assert = assert; exports.at = at; exports.batchInvoke = batchInvoke; exports.clamp = clamp; exports.clampArrayRange = clampArrayRange; exports.createSingletonPromise = createSingletonPromise; exports.deepMerge = deepMerge; exports.flattenArrayable = flattenArrayable; exports.invoke = invoke; exports.isBoolean = isBoolean; exports.isBrowser = isBrowser; exports.isDef = isDef; exports.isFunction = isFunction; exports.isKeyOf = isKeyOf; exports.isNumber = isNumber; exports.isObject = isObject; exports.isString = isString; exports.isTruthy = isTruthy; exports.isWindow = isWindow; exports.last = last; exports.mergeArrayable = mergeArrayable; exports.move = move; exports.noNull = noNull; exports.noop = noop; exports.notNullish = notNullish; exports.notUndefined = notUndefined; exports.objectEntries = objectEntries; exports.objectKeys = objectKeys; exports.objectMap = objectMap; exports.objectPick = objectPick; exports.partition = partition; exports.range = range; exports.remove = remove; exports.slash = slash; exports.sleep = sleep; exports.sum = sum; exports.timestamp = timestamp; exports.toArray = toArray; exports.toString = toString2; exports.uniq = uniq; |
+17
-8
@@ -0,1 +1,9 @@ | ||
| // src/math.ts | ||
| function clamp(n, min, max) { | ||
| return Math.min(max, Math.max(min, n)); | ||
| } | ||
| function sum(...args) { | ||
| return flattenArrayable(args).reduce((a, b) => a + b, 0); | ||
| } | ||
| // src/array.ts | ||
@@ -61,2 +69,9 @@ function toArray(array) { | ||
| } | ||
| function move(arr, from, to) { | ||
| arr.splice(to, 0, arr.splice(from, 1)[0]); | ||
| return arr; | ||
| } | ||
| function clampArrayRange(n, arr) { | ||
| return clamp(n, 0, arr.length - 1); | ||
| } | ||
@@ -96,10 +111,2 @@ // src/base.ts | ||
| // src/math.ts | ||
| function clamp(n, min, max) { | ||
| return Math.min(max, Math.max(min, n)); | ||
| } | ||
| function sum(...args) { | ||
| return flattenArrayable(args).reduce((a, b) => a + b, 0); | ||
| } | ||
| // src/path.ts | ||
@@ -193,2 +200,3 @@ function slash(str) { | ||
| clamp, | ||
| clampArrayRange, | ||
| createSingletonPromise, | ||
@@ -210,2 +218,3 @@ deepMerge, | ||
| mergeArrayable, | ||
| move, | ||
| noNull, | ||
@@ -212,0 +221,0 @@ noop, |
+1
-1
| { | ||
| "name": "@antfu/utils", | ||
| "version": "0.1.3", | ||
| "version": "0.1.4", | ||
| "description": "Opinionated collection of common JavaScript / TypeScript utils by @antfu", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
21087
4.23%666
5.71%