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

vise

Package Overview
Dependencies
Maintainers
2
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vise - npm Package Compare versions

Comparing version 1.0.0 to 2.0.0

2

CONTRIBUTING.md

@@ -13,5 +13,5 @@ # How to contribute

* Fork the repository on GitHub.
* Fix the issue ensuring that your code follows the [style guide](https://github.com/hapijs/hapi/blob/master/docs/Style.md).
* Fix the issue ensuring that your code follows the [style guide](https://github.com/hapijs/contrib/blob/master/Style.md).
* Add tests for your new code ensuring that you have 100% code coverage (we can help you reach 100% but will not merge without it).
* Run `npm test` to generate a report of test coverage
* [Pull requests](http://help.github.com/send-pull-requests/) should be made to the [master branch](https://github.com/hapijs/vise/tree/master).

@@ -0,4 +1,6 @@

'use strict';
// Load modules
var Hoek = require('hoek');
const Hoek = require('hoek');

@@ -8,3 +10,3 @@

var internals = {};
const internals = {};

@@ -20,3 +22,3 @@

chunks = [].concat(chunks);
for (var i = 0, il = chunks.length; i < il; ++i) {
for (let i = 0; i < chunks.length; ++i) {
this.push(chunks[i]);

@@ -32,3 +34,3 @@ }

var item = {
const item = {
data: chunk,

@@ -51,6 +53,6 @@ length: chunk.length,

var prevOffset = this._offset;
var item = this._chunkAt(length);
const prevOffset = this._offset;
const item = this._chunkAt(length);
var dropTo = this._chunks.length;
let dropTo = this._chunks.length;
this._offset = 0;

@@ -65,5 +67,5 @@

var chunks = [];
for (var i = 0; i < dropTo; ++i) {
var chunk = this._chunks.shift();
const chunks = [];
for (let i = 0; i < dropTo; ++i) {
const chunk = this._chunks.shift();
if (i === 0 &&

@@ -86,6 +88,6 @@ prevOffset) {

this.length = 0;
for (var j = 0, jl = this._chunks.length; j < jl; ++j) {
var chunk = this._chunks[j];
for (let i = 0, jl = this._chunks.length; i < jl; ++i) {
const chunk = this._chunks[i];
chunk.offset = this.length,
chunk.index = j;
chunk.index = i;

@@ -103,3 +105,3 @@ this.length += chunk.length;

var item = this._chunkAt(pos);
const item = this._chunkAt(pos);
return item ? item.chunk.data[item.offset] : undefined;

@@ -117,5 +119,5 @@ };

for (var i = 0, il = this._chunks.length; i < il; ++i) {
var chunk = this._chunks[i];
var offset = pos - chunk.offset;
for (let i = 0; i < this._chunks.length; ++i) {
const chunk = this._chunks[i];
const offset = pos - chunk.offset;
if (offset < chunk.length) {

@@ -132,6 +134,6 @@ return { chunk: chunk, offset: offset };

var chunks = [];
const chunks = [];
for (var i = 0, il = this._chunks.length; i < il; ++i) {
var chunk = this._chunks[i];
for (let i = 0; i < this._chunks.length; ++i) {
const chunk = this._chunks[i];
if (i === 0 &&

@@ -160,3 +162,3 @@ this._offset) {

var start = this._chunkAt(pos);
const start = this._chunkAt(pos);
if (!start) {

@@ -166,8 +168,9 @@ return false;

for (var k = start.chunk.index, kl = this._chunks.length, j = 0; k < kl && j < length; ++k) {
var chunk = this._chunks[k];
let j = start.chunk.index;
for (let i = 0; j < this._chunks.length && i < length; ++j) {
const chunk = this._chunks[j];
var offset = (k === start.chunk.index ? start.offset : 0);
for (var i = offset, il = chunk.length; i < il && j < length; ++i, ++j) {
if (chunk.data[i] !== value[j]) {
const offset = (j === start.chunk.index ? start.offset : 0);
for (let k = offset; k < chunk.length && i < length; ++k, ++i) {
if (chunk.data[k] !== value[i]) {
return false;

@@ -179,2 +182,2 @@ }

return true;
};
};
{
"name": "vise",
"description": "Treat multiple buffers as one",
"version": "1.0.0",
"version": "2.0.0",
"repository": "git://github.com/hapijs/vise",
"main": "index",
"main": "lib/index.js",
"keywords": [

@@ -14,19 +14,16 @@ "buffer",

"engines": {
"node": ">=0.10.32"
"node": ">=4.0.0"
},
"dependencies": {
"hoek": "2.x.x"
"hoek": "3.x.x"
},
"devDependencies": {
"lab": "4.x.x"
"code": "2.x.x",
"lab": "7.x.x"
},
"scripts": {
"test": "make test-cov"
"test": "lab -a code -t 100 -L",
"test-cov-html": "lab -a code -r html -o coverage.html"
},
"licenses": [
{
"type": "BSD",
"url": "http://github.com/hapijs/vise/raw/master/LICENSE"
}
]
"license": "BSD-3-Clause"
}

@@ -7,2 +7,2 @@ #vise

Lead Maintainer - [Eran Hammer](https://github.com/hueniverse)
Lead Maintainer - [Anna Luisa Patiño West](https://github.com/aisapatino)

@@ -0,5 +1,8 @@

'use strict';
// Load modules
var Lab = require('lab');
var Vise = require('..');
const Code = require('code');
const Lab = require('lab');
const Vise = require('..');

@@ -9,3 +12,3 @@

var internals = {};
const internals = {};

@@ -15,11 +18,11 @@

var lab = exports.lab = Lab.script();
var describe = lab.describe;
var it = lab.it;
var expect = Lab.expect;
const lab = exports.lab = Lab.script();
const describe = lab.describe;
const it = lab.it;
const expect = Code.expect;
describe('Vise', function () {
describe('Vise', () => {
var validate = function (vise, content) {
const validate = function (vise, content) {

@@ -33,7 +36,7 @@ expect(vise.length).to.equal(content.length);

for (var i = 0, il = content.length; i < il; ++i) {
for (let i = 0; i < content.length; ++i) {
expect(vise.at(i)).to.equal(content.charCodeAt(i));
}
for (i = content.length - 1; i >= 0; --i) {
for (let i = content.length - 1; i >= 0; --i) {
expect(vise.at(i)).to.equal(content.charCodeAt(i));

@@ -43,6 +46,6 @@ }

it('combines buffers', function (done) {
it('combines buffers', (done) => {
var data = [new Buffer('abcde'), new Buffer('fgh'), new Buffer('ijk')];
var vise = new Vise(data);
const data = [new Buffer('abcde'), new Buffer('fgh'), new Buffer('ijk')];
const vise = new Vise(data);
validate(vise, 'abcdefghijk');

@@ -52,6 +55,6 @@ done();

it('combines single buffer', function (done) {
it('combines single buffer', (done) => {
var data = new Buffer('abcde');
var vise = new Vise(data);
const data = new Buffer('abcde');
const vise = new Vise(data);
expect(vise.length).to.equal(5);

@@ -62,5 +65,5 @@ validate(vise, 'abcde');

it('allows empty input', function (done) {
it('allows empty input', (done) => {
var vise = new Vise();
const vise = new Vise();
expect(vise.length).to.equal(0);

@@ -71,5 +74,5 @@ expect(vise.at(0)).to.equal(undefined);

it('throws on invalid input', function (done) {
it('throws on invalid input', (done) => {
expect(function () {
expect(() => {

@@ -82,7 +85,7 @@ new Vise(123);

describe('length', function () {
describe('length', () => {
it('reflects total legnth', function (done) {
it('reflects total legnth', (done) => {
var vise = new Vise([new Buffer('abcdefghijklmn'), new Buffer('opqrstuvwxyz')]);
const vise = new Vise([new Buffer('abcdefghijklmn'), new Buffer('opqrstuvwxyz')]);
expect(vise.length).to.equal(26);

@@ -93,8 +96,8 @@ done();

describe('push()', function () {
describe('push()', () => {
it('adds a string', function (done) {
it('adds a string', (done) => {
var data = [new Buffer('abcde'), new Buffer('fgh')];
var vise = new Vise(data);
const data = [new Buffer('abcde'), new Buffer('fgh')];
const vise = new Vise(data);
validate(vise, 'abcdefgh');

@@ -107,5 +110,5 @@

it('adds to empty array', function (done) {
it('adds to empty array', (done) => {
var vise = new Vise();
const vise = new Vise();
expect(vise.length).to.equal(0);

@@ -119,8 +122,8 @@ expect(vise.at(0)).to.equal(undefined);

describe('shift()', function (done) {
describe('shift()', (done) => {
it('removes chunks', function (done) {
it('removes chunks', (done) => {
var data = [new Buffer('abcde'), new Buffer('fgh'), new Buffer('ijk')];
var vise = new Vise(data);
const data = [new Buffer('abcde'), new Buffer('fgh'), new Buffer('ijk')];
const vise = new Vise(data);
validate(vise, 'abcdefghijk');

@@ -149,5 +152,5 @@

it('keeps track of chunks offset', function (done) {
it('keeps track of chunks offset', (done) => {
var vise = new Vise();
const vise = new Vise();

@@ -164,6 +167,6 @@ vise.push(new Buffer('acb123de'));

it('removes multiple chunks', function (done) {
it('removes multiple chunks', (done) => {
var data = [new Buffer('abcde'), new Buffer('fgh'), new Buffer('ijk')];
var vise = new Vise(data);
const data = [new Buffer('abcde'), new Buffer('fgh'), new Buffer('ijk')];
const vise = new Vise(data);
validate(vise, 'abcdefghijk');

@@ -178,8 +181,8 @@

describe('chunks()', function (done) {
describe('chunks()', (done) => {
it('returns remaining chunks', function (done) {
it('returns remaining chunks', (done) => {
var data = [new Buffer('abcde'), new Buffer('fgh'), new Buffer('ijk')];
var vise = new Vise(data);
const data = [new Buffer('abcde'), new Buffer('fgh'), new Buffer('ijk')];
const vise = new Vise(data);
expect(vise.chunks()).to.deep.equal(data);

@@ -209,7 +212,7 @@

describe('startsWith()', function () {
describe('startsWith()', () => {
it('compares single chunk (smaller)', function (done) {
it('compares single chunk (smaller)', (done) => {
var vise = new Vise(new Buffer('abcdefghijkl'));
const vise = new Vise(new Buffer('abcdefghijkl'));
expect(vise.startsWith(new Buffer('abcd'))).to.equal(true);

@@ -219,5 +222,5 @@ done();

it('compares single chunk (subset)', function (done) {
it('compares single chunk (subset)', (done) => {
var vise = new Vise(new Buffer('abcdefghijkl'));
const vise = new Vise(new Buffer('abcdefghijkl'));
expect(vise.startsWith(new Buffer('abce'), 0, 3)).to.equal(true);

@@ -227,5 +230,5 @@ done();

it('compares single chunk (different)', function (done) {
it('compares single chunk (different)', (done) => {
var vise = new Vise(new Buffer('abcdefghijkl'));
const vise = new Vise(new Buffer('abcdefghijkl'));
expect(vise.startsWith(new Buffer('asd'))).to.equal(false);

@@ -235,5 +238,5 @@ done();

it('compares single chunk (offset)', function (done) {
it('compares single chunk (offset)', (done) => {
var vise = new Vise(new Buffer('abcdefghijkl'));
const vise = new Vise(new Buffer('abcdefghijkl'));
expect(vise.startsWith(new Buffer('bcd'), 1)).to.equal(true);

@@ -243,5 +246,5 @@ done();

it('compares single chunk (same)', function (done) {
it('compares single chunk (same)', (done) => {
var vise = new Vise(new Buffer('abcdefghijkl'));
const vise = new Vise(new Buffer('abcdefghijkl'));
expect(vise.startsWith(new Buffer('abcdefghijkl'))).to.equal(true);

@@ -251,5 +254,5 @@ done();

it('compares single chunk (bigger)', function (done) {
it('compares single chunk (bigger)', (done) => {
var vise = new Vise(new Buffer('abcdefghijkl'));
const vise = new Vise(new Buffer('abcdefghijkl'));
expect(vise.startsWith(new Buffer('abcdefghijklx'))).to.equal(false);

@@ -259,5 +262,5 @@ done();

it('compares multiple chunks', function (done) {
it('compares multiple chunks', (done) => {
var vise = new Vise([new Buffer('a'), new Buffer('b'), new Buffer('cdefghijkl')]);
const vise = new Vise([new Buffer('a'), new Buffer('b'), new Buffer('cdefghijkl')]);
expect(vise.startsWith(new Buffer('abcd'))).to.equal(true);

@@ -267,5 +270,5 @@ done();

it('compares multiple chunks (mismatch)', function (done) {
it('compares multiple chunks (mismatch)', (done) => {
var vise = new Vise([new Buffer('a'), new Buffer('b'), new Buffer('cdefghijkl')]);
const vise = new Vise([new Buffer('a'), new Buffer('b'), new Buffer('cdefghijkl')]);
expect(vise.startsWith(new Buffer('acd'))).to.equal(false);

@@ -275,5 +278,5 @@ done();

it('compares with invalid offset', function (done) {
it('compares with invalid offset', (done) => {
var vise = new Vise(new Buffer('abcdefghijkl'));
const vise = new Vise(new Buffer('abcdefghijkl'));
expect(vise.startsWith(new Buffer('bcd'), -1)).to.equal(false);

@@ -280,0 +283,0 @@ done();

Sorry, the diff of this file is not supported yet

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