You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Consider adding a helper function for creating duplicate-free versions of arrays.
Should only be needed for object arrays since for arrays whose items are of primitive type new Set() can be used directly.
Input of Daniel Rotter was we could also consider adding a library like Underscore.js or Ramda.js for such js utility.
/** * Produces a duplicate-free version of an object array, using `new Set()` for test equality. * Not meant to be used for array which items are of primitive type. */exportdefaultfunction<T>(input: T[]): T[] {if(!Array.isArray(input)){return[];}
return [...new Set(input.map(element =>JSON.stringify(element)))].map(element=>JSON.parse(element))asT[];}
The text was updated successfully, but these errors were encountered:
Consider adding a helper function for creating duplicate-free versions of arrays.
Should only be needed for object arrays since for arrays whose items are of primitive type
new Set()
can be used directly.Input of Daniel Rotter was we could also consider adding a library like Underscore.js or Ramda.js for such js utility.
The text was updated successfully, but these errors were encountered: