Comparing version 0.5.0 to 0.6.0
{ | ||
"name": "memcpy", | ||
"version": "0.5.0", | ||
"author": "Daniel Wirtz <dcode@dcode.io>", | ||
"contributors": [ | ||
"Denys Khanzhiyev <xdenser@gmail.com>" | ||
], | ||
"description": "Copies data between node Buffers and/or ArrayBuffers up to ~75 times faster than in pure JS.", | ||
"main": "src/memcpy.js", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/dcodeIO/node-memcpy.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/dcodeIO/node-memcpy/issues" | ||
}, | ||
"keywords": [ | ||
"array", | ||
"buffer", | ||
"arraybuffer", | ||
"typed array" | ||
], | ||
"dependencies": { | ||
"bindings": "~1.1", | ||
"nan": "~1.2.0" | ||
}, | ||
"devDependencies": { | ||
"testjs": "latest" | ||
}, | ||
"license": "Apache-2.0", | ||
"engines": { | ||
"node": ">=0.8" | ||
}, | ||
"scripts": { | ||
"prepublish": "npm test", | ||
"test": "node node_modules/testjs/bin/testjs tests/suite.js", | ||
"make": "node-gyp configure build && npm test", | ||
"install": "node-gyp configure build" | ||
} | ||
"name": "memcpy", | ||
"version": "0.6.0", | ||
"author": "Daniel Wirtz <dcode@dcode.io>", | ||
"contributors": [ | ||
"Denys Khanzhiyev <xdenser@gmail.com>" | ||
], | ||
"description": "Copies data between node Buffers and/or ArrayBuffers up to ~75 times faster than in pure JS.", | ||
"main": "src/memcpy.js", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/dcodeIO/node-memcpy.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/dcodeIO/node-memcpy/issues" | ||
}, | ||
"keywords": [ | ||
"array", | ||
"buffer", | ||
"arraybuffer", | ||
"typed array" | ||
], | ||
"dependencies": { | ||
"bindings": "~1.1", | ||
"nan": "~1.2.0", | ||
"node-arraybuffer": "^1.0.11" | ||
}, | ||
"devDependencies": { | ||
"testjs": "latest" | ||
}, | ||
"license": "Apache-2.0", | ||
"engines": { | ||
"node": ">=0.8 <=0.12" | ||
}, | ||
"scripts": { | ||
"prepublish": "npm test", | ||
"test": "node node_modules/testjs/bin/testjs tests/suite.js", | ||
"make": "node-gyp configure build && npm test", | ||
"install": "node-gyp configure build" | ||
} | ||
} |
@@ -16,12 +16,6 @@ node-memcpy | ||
i memcpy.100k > cc Buffer -> ArrayBuffer: 23.861ms | ||
i memcpy.100k > cc Buffer -> Uint8Array: 22.953ms | ||
i memcpy.100k > cc ArrayBuffer -> Buffer: 22.955ms | ||
i memcpy.100k > cc ArrayBuffer -> ArrayBuffer: 23.273ms | ||
i memcpy.100k > cc ArrayBuffer -> Uint8Array: 22.685ms | ||
i memcpy.100k > cc Uint8Array -> Buffer: 23.472ms | ||
i memcpy.100k > cc Uint8Array -> ArrayBuffer: 22.975ms | ||
i memcpy.100k > cc Uint8Array -> Uint8Array: 22.953ms | ||
// Native JS | ||
@@ -31,11 +25,5 @@ | ||
i memcpy.100k > js Buffer -> ArrayBuffer: 993.361ms | ||
i memcpy.100k > js Buffer -> Uint8Array: 410.010ms | ||
i memcpy.100k > js ArrayBuffer -> Buffer: 940.273ms | ||
i memcpy.100k > js ArrayBuffer -> ArrayBuffer: 1626.182ms | ||
i memcpy.100k > js ArrayBuffer -> Uint8Array: 1084.790ms | ||
i memcpy.100k > js Uint8Array -> Buffer: 386.218ms | ||
i memcpy.100k > js Uint8Array -> ArrayBuffer: 1107.530ms | ||
i memcpy.100k > js Uint8Array -> Uint8Array: 502.653ms | ||
``` | ||
@@ -49,5 +37,5 @@ | ||
|--------------|---------------------------|-----------|------------------------------------------------------------------ | ||
| target | Buffer | ArrayBuffer | Uint8Array | | Target buffer to copy to | ||
| target | Buffer | ArrayBuffer | | Target buffer to copy to | ||
| targetStart | number | omittable | Target offset to begin copying to, defaults to `0` | ||
| source | Buffer | ArrayBuffer | Uint8Array | | Source buffer to copy from | ||
| source | Buffer | ArrayBuffer | | Source buffer to copy from | ||
| sourceStart | number | optional | Source offset to begin copying from, defaults to `0` | ||
@@ -54,0 +42,0 @@ | sourceEnd | number | optional | Source offset to end copying from, defaults ot `source.length` |
@@ -22,6 +22,7 @@ /* | ||
*/ // | ||
(function(module) { | ||
(function (module) { | ||
"use strict"; | ||
var path = require("path"), | ||
Buffer = require('buffer').Buffer, | ||
binding = null; | ||
@@ -31,32 +32,2 @@ try { binding = require('bindings')('memcpy.node'); } catch (e) {} | ||
/** | ||
* @type {number} | ||
* @inner | ||
*/ | ||
var i = 0; | ||
/** | ||
* @type {number} | ||
* @inner | ||
*/ | ||
var j = 0; | ||
/** | ||
* @type {?Uint8Array} | ||
* @inner | ||
*/ | ||
var k = null; | ||
/** | ||
* @type {?Uint8Array} | ||
* @inner | ||
*/ | ||
var l = null; | ||
/** | ||
* @type {number} | ||
* @inner | ||
*/ | ||
var len = 0; | ||
/** | ||
* Copies data between Buffers and/or ArrayBuffers in a uniform way. | ||
@@ -66,5 +37,5 @@ * @exports memcpy | ||
* @name memcpy | ||
* @param {!(Buffer|ArrayBuffer|Uint8Array)} target Destination | ||
* @param {!(Buffer|ArrayBuffer)} target Destination | ||
* @param {number|!(Buffer|ArrayBuffer)} targetStart Destination start, defaults to 0. | ||
* @param {(!(Buffer|ArrayBuffer|Uint8Array)|number)=} source Source | ||
* @param {(!(Buffer|ArrayBuffer)|number)=} source Source | ||
* @param {number=} sourceStart Source start, defaults to 0. | ||
@@ -83,2 +54,5 @@ * @param {number=} sourceEnd Source end, defaults to capacity. | ||
sourceStart = sourceStart || 0; | ||
var i, j, k, l; | ||
if (target instanceof Buffer) { | ||
@@ -89,51 +63,45 @@ | ||
sourceEnd = sourceEnd || source.length; | ||
len = sourceEnd - sourceStart; | ||
if (targetStart+len > target.length) { | ||
throw(new Error("Buffer overrun")); | ||
} | ||
l = sourceEnd - sourceStart; | ||
if (targetStart + l > target.length) | ||
throw Error("illegal source range: target capacity overrun"); | ||
source.copy(target, targetStart, sourceStart, sourceEnd); | ||
// ArrayBuffer|Uint8Array source -> Buffer target (the binding is about 45 times faster) | ||
} else { | ||
// ArrayBuffer source -> Buffer target (the binding is about 45 times faster) | ||
} else if (source instanceof ArrayBuffer) { | ||
sourceEnd = sourceEnd || source.byteLength; | ||
len = sourceEnd - sourceStart; | ||
if (targetStart+len > target.length) { | ||
throw(new Error("Buffer overrun")); | ||
} | ||
for (i=sourceStart, j=targetStart, | ||
k=source instanceof Uint8Array ? source : new Uint8Array(source); | ||
i<sourceEnd; ++i, ++j) target[j] = k[i]; | ||
k = null; | ||
} | ||
l = sourceEnd - sourceStart; | ||
if (targetStart + l > target.length) | ||
throw Error("Buffer overrun"); | ||
for (i = sourceStart, j = targetStart, k = new Uint8Array(source); i < sourceEnd; ++i, ++j) | ||
target[j] = k[i]; | ||
} else | ||
throw Error("illegal source: not an ArrayBuffer or Buffer"); | ||
} else { | ||
} else if (target instanceof ArrayBuffer) { | ||
// Buffer source -> ArrayBuffer|Uint8Array target (the binding is about 45 times faster) | ||
// Buffer source -> ArrayBuffer target (the binding is about 45 times faster) | ||
if (source instanceof Buffer) { | ||
sourceEnd = sourceEnd || source.length; | ||
len = sourceEnd - sourceStart; | ||
if (targetStart+len > target.byteLength) { | ||
throw(new Error("Buffer overrun")); | ||
} | ||
for (i=sourceStart, j=targetStart, | ||
k=target instanceof Uint8Array ? target : new Uint8Array(target); | ||
i<sourceEnd; ++i, ++j) k[j] = source[i]; | ||
k = null; | ||
l = sourceEnd - sourceStart; | ||
if (targetStart + l > target.byteLength) | ||
throw Error("buffer overrun"); | ||
for (i = sourceStart, j = targetStart, k = new Uint8Array(target); i < sourceEnd; ++i, ++j) | ||
k[j] = source[i]; | ||
// ArrayBuffer|Uint8Array source -> ArrayBuffer|Uint8Array target (the binding is up to about 75 times faster) | ||
} else { | ||
// ArrayBuffer source -> ArrayBuffer target (the binding is up to about 75 times faster) | ||
} else if (source instanceof ArrayBuffer) { | ||
sourceEnd = sourceEnd || source.byteLength; | ||
len = sourceEnd-sourceStart; | ||
if (targetStart+len > target.byteLength) { | ||
throw(new Error("Buffer overrun")); | ||
} | ||
for (i=sourceStart, j=targetStart, | ||
k=target instanceof Uint8Array ? target : new Uint8Array(target), | ||
l=source instanceof Uint8Array ? source : new Uint8Array(source); | ||
i<sourceEnd; ++i, ++j) k[j] = l[i]; | ||
k = l = null; | ||
} | ||
l = sourceEnd - sourceStart; | ||
if (targetStart + l > target.byteLength) | ||
throw Error("buffer overrun"); | ||
for (i = sourceStart, j = targetStart, k = new Uint8Array(target), l = new Uint8Array(source); i < sourceEnd; ++i, ++j) | ||
k[j] = l[i]; | ||
l = sourceEnd - sourceStart; | ||
} else | ||
throw Error("illegal source: not an ArrayBuffer or Buffer"); | ||
} | ||
return len; | ||
} else | ||
throw Error("illegal target: not an ArrayBuffer or Buffer"); | ||
return l; | ||
} | ||
@@ -150,2 +118,2 @@ | ||
} | ||
})(module); | ||
})(module); |
@@ -29,4 +29,4 @@ function fill(buf) { | ||
[memcpy.binding, memcpy.native].forEach(function(memcpy) { | ||
[Buffer, ArrayBuffer, Uint8Array].forEach(function(Type1) { | ||
[Buffer, ArrayBuffer, Uint8Array].forEach(function(Type2) { | ||
[Buffer, ArrayBuffer].forEach(function(Type1) { | ||
[Buffer, ArrayBuffer].forEach(function(Type2) { | ||
var b1 = new Type1(8), | ||
@@ -56,3 +56,3 @@ b2 = new Type2(8); | ||
[memcpy.binding, memcpy.native].forEach(function(memcpy) { | ||
[Buffer, ArrayBuffer, Uint8Array].forEach(function(Type) { | ||
[Buffer, ArrayBuffer].forEach(function(Type) { | ||
var b = new Type(8); | ||
@@ -80,4 +80,4 @@ test.log((memcpy === memcpy.binding ? "cc".cyan : "js".green)+" "+b.constructor.name); | ||
[memcpy.binding, memcpy.native].forEach(function(memcpy) { | ||
[Buffer, ArrayBuffer, Uint8Array].forEach(function(Type1) { | ||
[Buffer, ArrayBuffer, Uint8Array].forEach(function(Type2) { | ||
[Buffer, ArrayBuffer].forEach(function(Type1) { | ||
[Buffer, ArrayBuffer].forEach(function(Type2) { | ||
var b1 = new Type1(1024), | ||
@@ -84,0 +84,0 @@ b2 = new Type2(1024); |
Sorry, the diff of this file is not supported yet
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
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
30279
10
3
187
64
+ Addednode-arraybuffer@^1.0.11
+ Addednode-arraybuffer@1.0.12(transitive)