js-commons/UniqueList.js

20 lines
278 B
JavaScript
Raw Permalink Normal View History

2019-05-23 12:17:22 +00:00
/**
* List of unique values (Set)
*/
class UniqueList {
constructor() {
this.list = {}
}
add(key) {
this.list[key] = 1
}
toArray() {
return Object.keys(this.list)
}
static filter(value, index, self) {
return self.indexOf(value) === index
}
}