Utility TypeScript @ 2.0.0-beta
    Preparing search index...

    Function arrayUnique

    • Uses Array.filter() to create a unique array.

      Filters out any item that is not the first instance of that item in the array.

      Type Parameters

      • T_ArrayItem

        Array item type.

      Parameters

      Returns T_ArrayItem[]

      Unique array.

      export function arrayUnique<T_ArrayItem>( arr: T_ArrayItem[] ): T_ArrayItem[] {

      // returns
      if ( !Array.isArray( arr ) ) { return arr; }

      return [ ...arr ].filter( ( v, i, a ) => a.indexOf( v ) === i );
      }

      0.1.0