git ssb

2+

Dominic / pull-stream



Tree: c686ded11700da3bd008a1915601f189454076e5

Files: c686ded11700da3bd008a1915601f189454076e5 / throughs / unique.js

428 bytesRaw
1'use strict'
2
3function id (e) { return e }
4var prop = require('../util/prop')
5var filter = require('./filter')
6
7//drop items you have already seen.
8module.exports = function unique (field, invert) {
9 field = prop(field) || id
10 var seen = {}
11 return filter(function (data) {
12 var key = field(data)
13 if(seen[key]) return !!invert //false, by default
14 else seen[key] = true
15 return !invert //true by default
16 })
17}
18
19

Built with git-ssb-web