Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

through2-spy

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

through2-spy - npm Package Compare versions

Comparing version 1.1.1 to 1.2.0

25

index.js

@@ -0,5 +1,10 @@

"use strict";
module.exports = make
module.exports.ctor = ctor
module.exports.obj = obj
module.exports.objCtor = objCtor
var through2 = require("through2")
var xtend = require("xtend")

@@ -20,4 +25,22 @@ function ctor(options, fn) {

function objCtor(options, fn) {
if (typeof options === "function") {
fn = options
options = {}
}
options = xtend({objectMode: true, highWaterMark: 16}, options)
return ctor(options, fn)
}
function make(options, fn) {
return ctor(options, fn)()
}
}
function obj(options, fn) {
if (typeof options === "function") {
fn = options
options = {}
}
options = xtend({objectMode: true, highWaterMark: 16}, options)
return make(options, fn)
}

23

package.json
{
"name": "through2-spy",
"version": "1.1.1",
"version": "1.2.0",
"description": "A through2 wrapper to for simple stream.PassThrough spies.",

@@ -25,2 +25,12 @@ "main": "index.js",

"license": "MIT",
"jshintConfig": {
"asi": true,
"globalstrict": true,
"validthis": true,
"eqnull": true,
"node": true,
"loopfunc": true,
"newcap": false,
"eqeqeq": false
},
"bugs": {

@@ -30,10 +40,11 @@ "url": "https://github.com/brycebaril/through2-spy/issues"

"devDependencies": {
"tape": "~2.4.0",
"tap": "~0.4.8",
"stream-spigot": "~3.0.3",
"terminus": "~1.0.9"
"tape": "~2.13.3",
"tap": "~0.4.11",
"stream-spigot": "~3.0.4",
"terminus": "~1.0.10"
},
"dependencies": {
"through2": "~0.4.1"
"through2": "~0.5.1",
"xtend": "~3.0.0"
}
}

@@ -54,2 +54,25 @@ through2-spy

API
---
`require("through2-spy")([options], fn)`
---
Create a `through2-spy` instance that will call `fn(chunk)` and then silently pass through data downstream.
`require("through2-spy").ctor([options], fn)`
---
Create a `through2-spy` Type that can be instantiated via `new Type()` or `Type()` to create reusable spies.
`require("through2-spy").obj([options], fn)`
---
Create a `through2-spy` that defaults to `objectMode = true`.
`require("through2-spy").objCtor([options], fn)`
---
Create a `through2-spy` Type that defaults to `objectMode = true`.
Options

@@ -64,2 +87,2 @@ -------

MIT
MIT

@@ -0,1 +1,3 @@

"use strict";
var test = require("tape").test

@@ -36,2 +38,31 @@

test("objCtor", function (t) {
t.plan(2)
var count = 0
var Spy = spy.objCtor(function () {
count++
})
var input = [
{foo: "bar"},
{foo: "baz"},
{foo: "bif"},
{foo: "blah"},
{foo: "buzz"},
]
// Input gets consumed, so make a copy for comparison.
var copy = input.slice(0)
function combine(records) {
t.equals(count, 5, "Spied the right number of chunks")
t.deepEquals(copy, records, "Content unchanged")
}
spigot({objectMode: true}, input)
.pipe(new Spy())
.pipe(concat({objectMode: true}, combine))
})
test("ctor options", function (t) {

@@ -149,2 +180,32 @@ t.plan(2)

test("return non-error obj", function (t) {
t.plan(2)
// Non-error return is ignored.
var count = 0
var s = spy.obj(function () {
if (++count > 2) return "WUT"
})
var input = [
{foo: "bar"},
{foo: "baz"},
{foo: "bif"},
{foo: "blah"},
{foo: "buzz"},
]
// Input gets consumed, so make a copy for comparison.
var copy = input.slice(0)
function combine(records) {
t.equals(count, 5, "Spied the right number of chunks")
t.deepEquals(copy, records, "Content unchanged")
}
spigot({objectMode: true}, input)
.pipe(s)
.pipe(concat({objectMode: true}, combine))
})
test("abort", function (t) {

@@ -225,2 +286,2 @@ t.plan(2)

.pipe(concat(combine))
})
})
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