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

flexbuffer

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

flexbuffer - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

8

flexbuffer.js

@@ -64,2 +64,3 @@

FlexBuffer.prototype.delete = function(start, end) {
checkParams(start, end, this.tail);
var copy = this.buffer.slice(end, this.tail).copy(this.buffer, start)

@@ -69,2 +70,9 @@ this.tail = this.tail - end + start

var checkParams = function (start, end, size) {
if (end > size || start > size || start < 0 || end < 0 || start > end) {
throw new Error("Start and end not valid. start:["+start+"], end:["+end+"], size:["+size+"]");
}
}
FlexBuffer.prototype.deleteAndGet = function(start, end) {

@@ -71,0 +79,0 @@ var b = new Buffer(end - start);

2

package.json

@@ -6,3 +6,3 @@ {

"description": "Buffer optimized",
"version": "0.0.2",
"version": "0.0.3",
"main" : "./flexbuffer",

@@ -9,0 +9,0 @@ "homepage": "https://github.com/mercadolibre/flexbuffer-node",

@@ -286,2 +286,87 @@ var should = require('should');

it ("exception con start y end erroneos", function (done) {
var flexbuffer = new fbuffers.FlexBuffer();
flexbuffer.write("123456789");
try {
flexbuffer.deleteAndGet(0,10);
} catch (e) {
done();
return;
}
should.fail('expected an error!');
});
it ("exception con start negativo", function (done) {
var flexbuffer = new fbuffers.FlexBuffer();
flexbuffer.write("123456789");
try {
flexbuffer.deleteAndGet(-1,10);
} catch (e) {
done();
return;
}
should.fail('expected an error!');
});
it ("exception con end negativo", function (done) {
var flexbuffer = new fbuffers.FlexBuffer();
flexbuffer.write("123456789");
try {
flexbuffer.deleteAndGet(0,-1);
} catch (e) {
done();
return;
}
should.fail('expected an error!');
});
it ("exception con start y end erroneos", function (done) {
var flexbuffer = new fbuffers.FlexBuffer();
flexbuffer.write("123456789");
try {
flexbuffer.deleteAndGet(0,10);
} catch (e) {
done();
return;
}
should.fail('expected an error!');
});
it ("exception start > end", function (done) {
var flexbuffer = new fbuffers.FlexBuffer();
flexbuffer.write("123456789");
try {
flexbuffer.deleteAndGet(9,8);
} catch (e) {
done();
return;
}
should.fail('expected an error!');
});
it ("exception con start muy grande", function (done) {
var flexbuffer = new fbuffers.FlexBuffer();
flexbuffer.write("123456789");
try {
flexbuffer.deleteAndGet(10,11);
} catch (e) {
done();
return;
}
should.fail('expected an error!');
});
it ("no errores con start and end validos", function (done) {
var flexbuffer = new fbuffers.FlexBuffer();
flexbuffer.write("123456789");
try {
flexbuffer.deleteAndGet(0,9);
} catch (e) {
should.fail('No deberia dar error!', e);
return;
}
done();
});
});
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