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

bytebuffer

Package Overview
Dependencies
Maintainers
1
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bytebuffer - npm Package Compare versions

Comparing version 3.1.1 to 3.2.0

2

bower.json
{
"name": "bytebuffer",
"version": "3.1.1",
"version": "3.2.0",
"author": "Daniel Wirtz <dcode@dcode.io>",

@@ -5,0 +5,0 @@ "description": "A full-featured ByteBuffer implementation using typed arrays.",

@@ -8,3 +8,3 @@ /*

(function(r){function s(l){function d(a,b,c){"undefined"===typeof a&&(a=d.DEFAULT_CAPACITY);"undefined"===typeof b&&(b=d.DEFAULT_ENDIAN);"undefined"===typeof c&&(c=d.DEFAULT_NOASSERT);if(!c){a|=0;if(0>a)throw new RangeError("Illegal capacity: 0 <= "+a);if("boolean"!==typeof b)throw new TypeError("Illegal littleEndian: Not a boolean");if("boolean"!==typeof c)throw new TypeError("Illegal noAssert: Not a boolean");}this.buffer=0===a?r:new ArrayBuffer(a);this.view=0===a?null:new DataView(this.buffer);
this.offset=0;this.markedOffset=-1;this.limit=a;this.littleEndian="undefined"!==typeof b?!!b:!1;this.noAssert=!!c}d.VERSION="3.1.1";d.LITTLE_ENDIAN=!0;d.BIG_ENDIAN=!1;d.DEFAULT_CAPACITY=16;d.DEFAULT_ENDIAN=d.BIG_ENDIAN;d.DEFAULT_NOASSERT=!1;d.Long=l||null;var r=new ArrayBuffer(0);d.allocate=function(a,b,c){return new d(a,b,c)};d.concat=function(a,b,c,e){if("boolean"===typeof b||"string"!==typeof b)e=c,c=b,b=void 0;for(var h=0,f=0,g=a.length,n;f<g;++f)d.isByteBuffer(a[f])||(a[f]=d.wrap(a[f],b)),n=
this.offset=0;this.markedOffset=-1;this.limit=a;this.littleEndian="undefined"!==typeof b?!!b:!1;this.noAssert=!!c}d.VERSION="3.2.0";d.LITTLE_ENDIAN=!0;d.BIG_ENDIAN=!1;d.DEFAULT_CAPACITY=16;d.DEFAULT_ENDIAN=d.BIG_ENDIAN;d.DEFAULT_NOASSERT=!1;d.Long=l||null;var r=new ArrayBuffer(0);d.allocate=function(a,b,c){return new d(a,b,c)};d.concat=function(a,b,c,e){if("boolean"===typeof b||"string"!==typeof b)e=c,c=b,b=void 0;for(var h=0,f=0,g=a.length,n;f<g;++f)d.isByteBuffer(a[f])||(a[f]=d.wrap(a[f],b)),n=
a[f].limit-a[f].offset,0<n&&(h+=n);if(0===h)return new d(0,c,e);b=new d(h,c,e);e=new Uint8Array(b.buffer);for(f=0;f<g;)c=a[f++],n=c.limit-c.offset,0>=n||(e.set((new Uint8Array(c.buffer)).subarray(c.offset,c.limit),b.offset),b.offset+=n);b.limit=b.offset;b.offset=0;return b};d.isByteBuffer=function(a){return a&&a instanceof d};d.type=function(){return ArrayBuffer};d.wrap=function(a,b,c,e){"string"!==typeof b&&(e=c,c=b,b=void 0);if("string"===typeof a)switch("undefined"===typeof b&&(b="utf8"),b){case "base64":return d.fromBase64(a,

@@ -88,2 +88,2 @@ c);case "hex":return d.fromHex(a,c);case "binary":return d.fromBinary(a,c);case "utf8":return d.fromUTF8(a,c);case "debug":return d.fromDebug(a,c);default:throw new TypeError("Unsupported encoding: "+b);}if(null===a||"object"!==typeof a)throw new TypeError("Illegal buffer: null or non-object");if(d.isByteBuffer(a))return b=d.prototype.clone.call(a),b.markedOffset=-1,b;if(a instanceof Uint8Array)b=new d(0,c,e),0<a.length&&(b.buffer=a.buffer,b.offset=a.byteOffset,b.limit=a.byteOffset+a.length,b.view=

a>>>=0;if("number"!==typeof b||0!==b%1)throw new TypeError("Illegal end: Not an integer");b>>>=0;if(0>a||a>b||b>this.buffer.byteLength)throw new RangeError("Illegal range: 0 <= "+a+" <= "+b+" <= "+this.buffer.byteLength);}var c=this,d;try{k.d(function(){return a<b?c.view.getUint8(a++):null},d=k.c())}catch(h){if(a!==b)throw new RangeError("Illegal range: Truncated data, "+a+" != "+b);}return d()};d.fromUTF8=function(a,b,c){if(!c&&"string"!==typeof a)throw new TypeError("Illegal str: Not a string");
var e=new d(k.b(k.a(a),!0)[1],b,c),h=0;k.e(k.a(a),function(a){e.view.setUint8(h++,a)});e.limit=h;return e};return d}"undefined"!=typeof module&&module.exports?module.exports=s(require("long")):"undefined"!==typeof define&&define.amd?define("ByteBuffer",["Math/Long"],function(l){return s(l)}):(r.dcodeIO||(r.dcodeIO={}),r.dcodeIO.ByteBuffer=s(r.dcodeIO.Long))})(this);
var e=new d(k.b(k.a(a),!0)[1],b,c),h=0;k.e(k.a(a),function(a){e.view.setUint8(h++,a)});e.limit=h;return e};return d}"undefined"!==typeof module&&module.exports?module.exports=s(require("long")):"function"===typeof define&&define.amd?define("ByteBuffer",["Long"],function(l){return s(l)}):(r.dcodeIO=r.dcodeIO||{}).ByteBuffer=s(r.dcodeIO.Long)})(this);

@@ -12,3 +12,3 @@ Distributions

* **[ByteBufferAB.min.js](https://raw.githubusercontent.com/dcodeIO/ByteBuffer.js/master/dist/ByteBufferAB.min.js)**
has been compiled with Closure Compiler using `--compilation_level=ADVANCED_OPTIMIZATIONS`.
has been compiled with Closure Compiler using advanced optimizations.

@@ -25,4 +25,7 @@ * **[ByteBufferAB.min.js.gz](https://raw.githubusercontent.com/dcodeIO/ByteBuffer.js/master/dist/ByteBufferAB.min.js.gz)**

uses a node Buffer as its backing buffer.
Also available as `bytebuffer` on [npm](https://www.npmjs.org/package/bytebuffer) and
[bower](http://bower.io/search/?q=bytebuffer).
When installed as an [npm package](https://www.npmjs.org/package/bytebuffer), both versions are available.
`exports` and `exports.ByteBufferNB` point at ByteBufferNB, `exports.ByteBufferAB` points at ByteBufferAB.
{
"name": "bytebuffer",
"version": "3.1.1",
"version": "3.2.0",
"author": "Daniel Wirtz <dcode@dcode.io>",

@@ -17,7 +17,7 @@ "description": "The swiss army knife for binary data in JavaScript.",

"dependencies": {
"long": "~1",
"long": "~2",
"bufferview": "~1"
},
"devDependencies": {
"utfx": "~1.0",
"utfx": "~1",
"testjs": "~1",

@@ -27,2 +27,5 @@ "metascript": "~0",

},
"optionalDependencies": {
"memcpy": "~0.5"
},
"license": "Apache-2.0",

@@ -35,8 +38,7 @@ "engines": {

"test": "node node_modules/testjs/bin/testjs tests/suite.js",
"make": "npm run-script build && npm run-script compile && npm run-script compress && npm test && npm run-script jsdoc",
"make": "npm run-script build && npm run-script compile && npm run-script compress && npm test",
"build": "node scripts/build.js",
"compile": "ccjs dist/ByteBufferAB.js --create_source_map=dist/ByteBufferAB.min.map --compilation_level=ADVANCED_OPTIMIZATIONS --externs=externs/minimal-env.js --externs=externs/Long.js > dist/ByteBufferAB.min.js",
"compress": "gzip -c -9 dist/ByteBufferAB.min.js > dist/ByteBufferAB.min.js.gz",
"jsdoc": "jsdoc -c jsdoc.json"
"compile": "ccjs dist/ByteBufferAB.js --create_source_map=dist/ByteBufferAB.min.map --compilation_level=ADVANCED_OPTIMIZATIONS --externs=externs/minimal-env.js --externs=node_modules/long/externs/Long.js > dist/ByteBufferAB.min.js",
"compress": "gzip -c -9 dist/ByteBufferAB.min.js > dist/ByteBufferAB.min.js.gz"
}
}

@@ -6,12 +6,13 @@ ![ByteBuffer.js - The swiss army knife for binary data in JavaScript.](https://raw.github.com/dcodeIO/ByteBuffer.js/master/ByteBuffer.png)

If you are looking for ByteBuffer.js 2 (ArrayBuffers only), [that's the branch](https://github.com/dcodeIO/ByteBuffer.js/tree/ByteBuffer2).
[![Build Status](https://travis-ci.org/dcodeIO/ByteBuffer.js.svg?branch=master)](https://travis-ci.org/dcodeIO/ByteBuffer.js)
[![Donate](https://raw.githubusercontent.com/dcodeIO/Long.js/master/donate.png)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=info%40code-emitter.com&item_name=Open%20Source%3A%20Long.js)
What can it do?
---------------
Features
--------
* 8, 16, 32 and 64 bit signed and unsigned integers
* 32 and 64 bit floats
* Big and little endianness
* Varints as used in protobuf (32 and 64 bit, zig-zag)
* Base64, binary, debug, hex and utf8 encodings
* Handy string and debugging utilities
* Big and little endianness
* Relative and absolute zero-copy operations wherever possible

@@ -22,74 +23,30 @@ * Transparent resizing when using unknown-length data

More
----
* CommonJS, AMD and shim compatible
* Also available via [npm](https://npmjs.org/package/bytebuffer)
* Compiled through [Closure Compiler](https://developers.google.com/closure/compiler/) using ADVANCED_OPTIMIZATIONS
(fully annotated, includes externs and source map)
* Fully documented using [jsdoc3](https://github.com/jsdoc3/jsdoc)
* Well tested through [test.js](https://github.com/dcodeIO/test.js)
* Zero production dependencies (Long.js is optional)
Usage
-----
### Node.js ###
* Install: `npm install bytebuffer`
The library is compatible with CommonJS and AMD loaders and is exposed globally as `dcodeIO.ByteBuffer` if neither is
available.
```javascript
var ByteBuffer = require("bytebuffer");
var bb = new ByteBuffer();
bb.writeIString("Hello world!").flip();
var bb = new ByteBuffer()
.writeIString("Hello world!")
.flip();
console.log(bb.readIString()+" from ByteBuffer.js");
```
### Browser ###
In the browser, 64 bit integer support is optional and present only if [Long.js](https://github.com/dcodeIO/Long.js) has
been loaded prior to ByteBuffer.js.
Optionally depends on [Long.js](https://github.com/dcodeIO/Long.js) for long (int64) support. If you do not require long
support, you can skip the Long.js include.
API
---
* [View the API documentation](https://github.com/dcodeIO/ByteBuffer.js/wiki/API)
* [Check the wiki](https://github.com/dcodeIO/ByteBuffer.js/wiki)
```html
<script src="Long.min.js"></script>
<script src="ByteBufferAB.min.js"></script>
```
```javascript
var ByteBuffer = dcodeIO.ByteBuffer;
var bb = new ByteBuffer();
bb.writeIString("Hello world!").flip();
alert(bb.readIString()+" from ByteBuffer.js");
```
### AMD ###
Optionally depends on [Long.js](https://github.com/dcodeIO/Long.js) for long (int64) support. If you do not require long
support, you can skip the Long.js config. [Require.js](http://requirejs.org/) example:
```javascript
require.config({
"paths": {
"Long": "/path/to/Long.js"
"ByteBuffer": "/path/to/ByteBufferAB.js"
}
});
require(["ByteBuffer"], function(ByteBuffer) {
var bb = new ByteBuffer();
bb.writeIString("Hello world!").flip();
alert(bb.readIString()+" from ByteBuffer.js");
});
```
Downloads
---------
* [Distributions](https://github.com/dcodeIO/ByteBuffer.js/tree/master/dist)
* [ZIP-Archive](https://github.com/dcodeIO/ByteBuffer.js/archive/master.zip)
* [Tarball](https://github.com/dcodeIO/ByteBuffer.js/tarball/master)
Documentation
-------------
* [View the API documentation](http://htmlpreview.github.com/?http://github.com/dcodeIO/ByteBuffer.js/master/docs/ByteBuffer.html)
Tests (& Examples) [![Build Status](https://travis-ci.org/dcodeIO/ByteBuffer.js.png?branch=master)](https://travis-ci.org/dcodeIO/ByteBuffer.js)
------------------
* [View source](https://github.com/dcodeIO/ByteBuffer.js/blob/master/tests/suite.js)
* [View report](https://travis-ci.org/dcodeIO/ByteBuffer.js)
Support for IE<10, FF<15, Chrome<9 etc.

@@ -96,0 +53,0 @@ ---------------------------------------

@@ -39,12 +39,9 @@ /*

// Enable module loading if available
if (typeof module != 'undefined' && module["exports"]) { // CommonJS
/* CommonJS */ if (typeof module !== 'undefined' && module["exports"])
module["exports"] = loadByteBuffer(require("long"));
} else if (typeof define !== 'undefined' && define["amd"]) { // AMD
define("ByteBuffer", ["Math/Long"], function(Long) { return loadByteBuffer(Long); });
} else { // Shim
if (!global["dcodeIO"]) global["dcodeIO"] = {};
global["dcodeIO"]["ByteBuffer"] = loadByteBuffer(global["dcodeIO"]["Long"]);
}
/* AMD */ else if (typeof define === 'function' && define["amd"])
define("ByteBuffer", ["Long"], function(Long) { return loadByteBuffer(Long); });
/* Global */ else
(global["dcodeIO"] = global["dcodeIO"] || {})["ByteBuffer"] = loadByteBuffer(global["dcodeIO"]["Long"]);
})(this);

@@ -674,4 +674,4 @@ /*

values = [
[Long.MAX_SIGNED_VALUE, Long.MAX_UNSIGNED_VALUE.subtract(Long.ONE)],
[Long.MIN_SIGNED_VALUE, Long.MAX_UNSIGNED_VALUE]
[Long.MAX_VALUE, Long.MAX_UNSIGNED_VALUE.subtract(Long.ONE)],
[Long.MIN_VALUE, Long.MAX_UNSIGNED_VALUE]
];

@@ -978,3 +978,3 @@ // NOTE: Even 64bit doubles from toNumber() fail for these values so we are using toString() here

test.equal(sandbox.define.called[0], "ByteBuffer");
test.equal(sandbox.define.called[1][0], "Math/Long");
test.equal(sandbox.define.called[1][0], "Long");
test.done();

@@ -981,0 +981,0 @@ };

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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