Comparing version 0.0.2 to 0.0.3
26
index.js
@@ -157,1 +157,27 @@ module.exports = Buffers; | ||
}; | ||
Buffers.prototype.get = function get (i) { | ||
if (i < 0 || i >= this.length) throw new Error('oob'); | ||
var l = i, bi = 0, bu = null; | ||
for (;;) { | ||
bu = this.buffers[bi++]; | ||
if (l < bu.length) { | ||
return bu.get(l); | ||
} else { | ||
l -= bu.length; | ||
} | ||
} | ||
}; | ||
Buffers.prototype.set = function set (i, b) { | ||
if (i < 0 || i >= this.length) throw new Error('oob'); | ||
var l = i, bi = 0, bu = null; | ||
for (;;) { | ||
bu = this.buffers[bi++]; | ||
if (l < bu.length) { | ||
return bu.set(l, b); | ||
} else { | ||
l -= bu.length; | ||
} | ||
} | ||
}; |
{ | ||
"name" : "buffers", | ||
"description" : "Treat a collection of Buffers as a single contiguous partially mutable Buffer.", | ||
"version" : "0.0.2", | ||
"version" : "0.0.3", | ||
"repository" : "http://github.com/substack/node-buffers.git", | ||
@@ -6,0 +6,0 @@ "author" : "James Halliday <mail@substack.net> (http://substack.net)", |
var assert = require('assert'); | ||
var Buffers = require('buffers'); | ||
var Buffers = require('../'); | ||
@@ -155,1 +155,30 @@ function create (xs, split) { | ||
}; | ||
exports.get = function () { | ||
var bufs = Buffers(); | ||
bufs.unshift(new Buffer([6,7,8,9])); | ||
bufs.unshift(new Buffer([4,5])); | ||
bufs.unshift(new Buffer([1,2,3])); | ||
bufs.unshift(new Buffer([0])); | ||
assert.eql( bufs.get(0), 0 ); | ||
assert.eql( bufs.get(1), 1 ); | ||
assert.eql( bufs.get(2), 2 ); | ||
assert.eql( bufs.get(3), 3 ); | ||
assert.eql( bufs.get(4), 4 ); | ||
assert.eql( bufs.get(5), 5 ); | ||
assert.eql( bufs.get(6), 6 ); | ||
assert.eql( bufs.get(7), 7 ); | ||
assert.eql( bufs.get(8), 8 ); | ||
assert.eql( bufs.get(9), 9 ); | ||
}; | ||
exports.set = function () { | ||
var bufs = Buffers(); | ||
bufs.push(new Buffer("Hel")); | ||
bufs.push(new Buffer("lo")); | ||
bufs.push(new Buffer("!")); | ||
bufs.set(0, 'h'.charCodeAt(0) ); | ||
bufs.set(3, 'L'.charCodeAt(0) ); | ||
bufs.set(5, '.'.charCodeAt(0) ); | ||
assert.eql( bufs.slice(0).toString(), 'helLo.' ); | ||
}; |
Sorry, the diff of this file is not supported yet
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
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
13759
335
99
1