I wrote this for a project that didn't want to import additional libraries just for this functionality.
It could probably be more efficient and it only supports direct attributes of the item in question.
It would be nice to add support for attr.subattr.etc
at some point. (Maybe using AngularJS's $parse()
?)
Other similar functions:
- lodash.js' (successor to underscore.js)
_.uniqBy()
or_.uniqWith()
: https://lodash.com/docs - "Standard" JS' own
Array.reduce()
method, as explained by: http://elijahmanor.com/reducing-filter-and-map-down-to-reduce/ - angular-filter's
uniq
orunique
filter: https://github.com/a8m/angular-filter