# 对象

  1. shuffle

打乱数组

定义:

export declare const shuffle: <T = any>(arr: T[]) => T[];
  1. arrToObj

数组转对象

定义:

export declare const arrToObj: <T, K = T>(arr: ArrayLike<any>, { mapValue, keyName, valueName, }?: ArrToObjOptions<T, K>) => {
    [key: string]: K;
};
  1. deDuplication

数组去重 (数据顺序会保留)

定义:

export declare const deDuplication: <T = any>(arr: T[]) => T[];
  1. copy/shallowCopy/deepCopy

拷贝(不拷贝无法序列化的数据) - 默认浅拷贝,深拷贝设 deep 深度,设-1无限深(深拷贝自引用会导致死循环)

定义:

export declare const copy: <T>(origin: T, deep?: number) => T | undefined;

export const shallowCopy = <T>(origin: T) => copy<T>(origin) as T;
export const deepCopy = <T>(origin: T) => copy<T>(origin, -1) as T;
更新于: 10/22/2020, 9:01:50 PM