Socket
Socket
Sign inDemoInstall

pull-stream

Package Overview
Dependencies
Maintainers
1
Versions
87
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pull-stream - npm Package Compare versions

Comparing version 2.2.0 to 2.3.0

test/unique.js

11

docs/throughs.md

@@ -45,2 +45,13 @@ # Throughs

## unique (prop)
Filter items that have a repeated value for `prop()`,
by default, `prop = function (it) {return it }`, if prop is a string,
it will filter nodes which have repeated values for that property.
## nonUnique (prop)
filter unique items -- get the duplicates.
The inverse of `unique`
## take (test)

@@ -47,0 +58,0 @@

2

package.json
{
"name": "pull-stream",
"description": "minimal pull stream",
"version": "2.2.0",
"version": "2.3.0",
"homepage": "https://github.com/dominictarr/pull-stream",

@@ -6,0 +6,0 @@ "repository": {

@@ -0,1 +1,13 @@

function prop (map) {
if('string' == typeof map) {
var key = map
return function (data) { return data[key] }
}
return map
}
function id (item) {
return item
}
var k = 0

@@ -5,7 +17,3 @@ var map = exports.map =

var _k = k++
if('string' == typeof map) {
var key = map
map = function (data) { return data[key] }
}
map = map || function (e) {return e}
map = prop(map) || id
return function (end, cb) {

@@ -25,3 +33,3 @@ read(end, function (end, data) {

test = test.test.bind(test)
test = test || function (data) {return !!data}
test = prop(test) || id
return function next (end, cb) {

@@ -75,2 +83,17 @@ read(end, function (end, data) {

var unique = exports.unique = function (read, field, invert) {
field = prop(field) || id
var seen = {}
return filter(read, function (data) {
var key = field(data)
if(seen[key]) return !!invert //false, by default
else seen[key] = true
return !invert //true by default
})
}
var nonUnique = exports.nonUnique = function (read, field) {
return unique(read, field, true)
}
var nextTick = process.nextTick

@@ -77,0 +100,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc