@varlet/shared 2.19.2 → 2.19.3-alpha.1701190302604
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.d.ts +4 -3
- package/lib/index.js +3 -0
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
declare const uniq: (arr: Array<any>) => any[];
|
|
2
2
|
declare const normalizeToArray: <T>(value: T | T[]) => T[];
|
|
3
|
-
declare const removeItem: (arr:
|
|
4
|
-
declare const toggleItem: (arr:
|
|
3
|
+
declare const removeItem: <T>(arr: T[], item: T) => T[] | undefined;
|
|
4
|
+
declare const toggleItem: <T>(arr: T[], item: T) => T[];
|
|
5
|
+
declare const removeArrayBlank: <T>(arr: (T | null | undefined)[]) => T[];
|
|
5
6
|
declare const find: <T>(arr: T[], callback: (item: T, index: number, array: T[]) => any, from?: 'start' | 'end') => [T, number] | [null, -1];
|
|
6
7
|
type ClassName = string | undefined | null;
|
|
7
8
|
type Classes = (ClassName | [any, ClassName, ClassName?])[];
|
|
@@ -53,4 +54,4 @@ declare function createNamespaceFn<N extends string>(namespace: N): <C extends s
|
|
|
53
54
|
classes: (...classes: Classes) => any[];
|
|
54
55
|
};
|
|
55
56
|
|
|
56
|
-
export { BEM, ClassName, Classes, bigCamelize, call, camelize, cancelAnimationFrame, clamp, clampArrayRange, classes, createNamespaceFn, debounce, doubleRaf, find, getGlobalThis, getRect, getScrollLeft, getScrollTop, getStyle, hasOwn, inBrowser, inViewport, isArray, isBoolean, isEmpty, isFunction, isNumber, isNumeric, isObject, isPlainObject, isString, isURL, isWindow, kebabCase, normalizeToArray, preventDefault, raf, removeItem, requestAnimationFrame, supportTouch, throttle, toDataURL, toNumber, toggleItem, uniq };
|
|
57
|
+
export { BEM, ClassName, Classes, bigCamelize, call, camelize, cancelAnimationFrame, clamp, clampArrayRange, classes, createNamespaceFn, debounce, doubleRaf, find, getGlobalThis, getRect, getScrollLeft, getScrollTop, getStyle, hasOwn, inBrowser, inViewport, isArray, isBoolean, isEmpty, isFunction, isNumber, isNumeric, isObject, isPlainObject, isString, isURL, isWindow, kebabCase, normalizeToArray, preventDefault, raf, removeArrayBlank, removeItem, requestAnimationFrame, supportTouch, throttle, toDataURL, toNumber, toggleItem, uniq };
|
package/lib/index.js
CHANGED
|
@@ -53,7 +53,9 @@ var removeItem = (arr, item) => {
|
|
|
53
53
|
};
|
|
54
54
|
var toggleItem = (arr, item) => {
|
|
55
55
|
arr.includes(item) ? removeItem(arr, item) : arr.push(item);
|
|
56
|
+
return arr;
|
|
56
57
|
};
|
|
58
|
+
var removeArrayBlank = (arr) => arr.filter((item) => item != null);
|
|
57
59
|
var find = (arr, callback, from = "start") => {
|
|
58
60
|
let i = from === "start" ? 0 : arr.length - 1;
|
|
59
61
|
while (arr.length > 0 && i >= 0 && i <= arr.length - 1) {
|
|
@@ -269,6 +271,7 @@ export {
|
|
|
269
271
|
normalizeToArray,
|
|
270
272
|
preventDefault,
|
|
271
273
|
raf,
|
|
274
|
+
removeArrayBlank,
|
|
272
275
|
removeItem,
|
|
273
276
|
requestAnimationFrame,
|
|
274
277
|
supportTouch,
|