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

sculpt

Package Overview
Dependencies
Maintainers
3
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sculpt - npm Package Compare versions

Comparing version 0.1.6 to 0.1.7

5

lib/byteLength.js

@@ -58,5 +58,4 @@ // Copyright 2014. A Medium Corporation

var flush = function (cb) {
this.push(cache)
cb()
var flush = function () {
return cache
}

@@ -63,0 +62,0 @@

51

lib/map.js

@@ -13,5 +13,5 @@ // Copyright 2014. A Medium Corporation

* @param {Function} mapper
* @param {Function=} flush
* @param {Function=} flusher
*/
function Mapper(mapper, flush) {
function Mapper(mapper, flusher) {
Transform.call(this, {

@@ -25,5 +25,3 @@ objectMode: true,

this.mapper = mapper
if (flush) {
this._flush = flush
}
this.flusher = flusher
}

@@ -41,2 +39,13 @@ util.inherits(Mapper, Transform)

/**
* @override
*/
Mapper.prototype._flush = function (callback) {
// If we don't have a flusher, bail.
if (! this.flusher) return callback()
var method = this.isAsync() ? '_asyncFlush' : '_syncFlush'
this[method].call(this, callback)
}
/**
* Apply a syncronous transformation.

@@ -72,2 +81,28 @@ * @param {*} chunk

/**
* Synchronously flush the stream.
* @param {Function} callback
*/
Mapper.prototype._syncFlush = function (callback) {
try {
this.push(this.flusher())
callback()
} catch (e) {
callback(e)
}
}
/**
* Asynchronously flush the stream.
* @param {Function} callback
*/
Mapper.prototype._asyncFlush = function (callback) {
this.flusher(function (err, data) {
if (err) return callback(err)
this.push(data)
callback(null)
}.bind(this))
}
/**
* Set the stream to be async. This is only relevant for map and filter streams, and not

@@ -158,3 +193,7 @@ * for the built in streams that implement them.

} else {
return data.every(push.bind(this))
var needMoreData = false
for (var i = 0; i < data.length; ++i) {
needMoreData = push.call(this, data[i])
}
return needMoreData
}

@@ -161,0 +200,0 @@ }

@@ -23,5 +23,4 @@ // Copyright 2014. A Medium Corporation

var flush = function (cb) {
this.push([cache])
cb()
var flush = function () {
return [cache]
}

@@ -28,0 +27,0 @@

{
"name": "sculpt",
"version": "0.1.6",
"version": "0.1.7",
"description": "Generate Node 0.10-friendly transform streams to manipulate other streams.",

@@ -16,8 +16,10 @@ "main": "index.js",

"zuul": "bin/zuul-tests",
"test": "npm run jshint && npm run jscs && npm run ensure-tests && npm run mocha && npm run zuul"
"test": "bin/test"
},
"devDependencies": {
"es5-shim": "^4.0.3",
"jscs": "~1.3.0",
"jshint": "~2.4.4",
"mocha": "~1.17.1",
"phantomjs": "^1.9.10",
"zuul": "^1.11.0"

@@ -24,0 +26,0 @@ },

Sorry, the diff of this file is not supported yet

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