Comparing version 0.0.3 to 0.0.4
24
index.js
@@ -12,19 +12,29 @@ module.exports = Buffers; | ||
Buffers.prototype.push = function () { | ||
var res = this.buffers.push.apply(this.buffers, arguments); | ||
for (var i = 0; i < arguments.length; i++) { | ||
var buf = arguments[i]; | ||
if (!Buffer.isBuffer(buf)) { | ||
if (!Buffer.isBuffer(arguments[i])) { | ||
throw new TypeError('Tried to push a non-buffer'); | ||
} | ||
} | ||
for (var i = 0; i < arguments.length; i++) { | ||
var buf = arguments[i]; | ||
this.buffers.push(buf); | ||
this.length += buf.length; | ||
} | ||
return res; | ||
return this.length; | ||
}; | ||
Buffers.prototype.unshift = function () { | ||
var res = this.buffers.unshift.apply(this.buffers, arguments); | ||
for (var i = 0; i < arguments.length; i++) { | ||
this.length += arguments[i].length; | ||
if (!Buffer.isBuffer(arguments[i])) { | ||
throw new TypeError('Tried to unshift a non-buffer'); | ||
} | ||
} | ||
return res; | ||
for (var i = 0; i < arguments.length; i++) { | ||
var buf = arguments[i]; | ||
this.buffers.unshift(buf); | ||
this.length += buf.length; | ||
} | ||
return this.length; | ||
}; | ||
@@ -31,0 +41,0 @@ |
{ | ||
"name" : "buffers", | ||
"description" : "Treat a collection of Buffers as a single contiguous partially mutable Buffer.", | ||
"version" : "0.0.3", | ||
"version" : "0.0.4", | ||
"repository" : "http://github.com/substack/node-buffers.git", | ||
@@ -6,0 +6,0 @@ "author" : "James Halliday <mail@substack.net> (http://substack.net)", |
@@ -142,2 +142,7 @@ var assert = require('assert'); | ||
); | ||
assert.throws(function () { | ||
bufs.push(new Buffer([11,12]), 'moo'); | ||
}); | ||
assert.eql(bufs.buffers.length, 4); | ||
}; | ||
@@ -155,2 +160,6 @@ | ||
); | ||
assert.throws(function () { | ||
bufs.unshift(new Buffer([-2,-1]), 'moo'); | ||
}); | ||
assert.eql(bufs.buffers.length, 4); | ||
}; | ||
@@ -157,0 +166,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
AI-detected possible typosquat
Supply chain riskAI has identified this package as a potential typosquat of a more popular package. This suggests that the package may be intentionally mimicking another package's name, description, or other metadata.
Found 1 instance in 1 package
14247
351
0