Options
All
  • Public
  • Public/Protected
  • All
Menu

ko-utils-tiny

Index

Functions

Functions

uniq

  • uniq(array: any[]): any[]
  • 数组去重

    example

    ts

     uniq([2, 1, 2]) // => [2, 1]
    

    Parameters

    • array: any[]

      要处理的数组

    Returns any[]

    返回新数组

uniqBy

  • uniqBy(array: any[], iteratee: Function | string): any[]
  • 数组去重,每一个数组的元素调用 iteratee 产生唯一性计算标准

    example

    ts

     uniqBy([2.1, 1.2, 2.3], Math.floor) // => [2.1, 1.2]
    

    Parameters

    • array: any[]

      要处理的数组

    • iteratee: Function | string

      迭代函数

    Returns any[]

    返回新数组

uniqWith

  • uniqWith(array: any[], comparator: Function): any[]
  • 数组去重,数组每一个元素都接受一个 comparator 函数做对比

    example

    ts

     const objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }]
     uniqWith(objects, isEqual) // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
    

    Parameters

    • array: any[]
    • comparator: Function

      对比函数,传入两个参数 (value , otherValue),return true为去重

    Returns any[]

    返回新数组

Generated using TypeDoc