{"_id":"memcpy","_rev":"63131","name":"memcpy","description":"Copies data between node Buffers and/or ArrayBuffers up to ~75 times faster than in pure JS.","dist-tags":{"latest":"0.6.0"},"maintainers":[{"name":"dcode","email":""}],"time":{"modified":"2021-06-03T10:21:22.000Z","created":"2013-12-31T17:37:57.219Z","0.6.0":"2015-07-14T21:16:57.099Z","0.5.0":"2014-06-27T14:00:23.273Z","0.4.0":"2014-01-02T00:52:52.484Z","0.3.0":"2014-01-01T22:40:20.847Z","0.2.0":"2014-01-01T18:46:42.752Z","0.1.0":"2013-12-31T17:37:57.219Z"},"users":{"andr":true,"arover":true,"jackblackjack":true},"author":{"name":"Daniel Wirtz","email":"dcode@dcode.io"},"repository":{"type":"git","url":"git+https://github.com/dcodeIO/node-memcpy.git"},"versions":{"0.6.0":{"name":"memcpy","version":"0.6.0","author":{"name":"Daniel Wirtz","email":"dcode@dcode.io"},"contributors":[{"name":"Denys Khanzhiyev","email":"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":"git+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"},"gitHead":"5bd6b5fa536e14b88c735e0ce92c6aa11898cc0d","homepage":"https://github.com/dcodeIO/node-memcpy#readme","_id":"memcpy@0.6.0","_shasum":"e4fd93e47a9266d389bcc67cb2baafa2b44a46e6","_from":".","_npmVersion":"2.11.3","_nodeVersion":"0.12.7","_npmUser":{"name":"dcode","email":"dcode@dcode.io"},"maintainers":[{"name":"dcode","email":""}],"dist":{"shasum":"e4fd93e47a9266d389bcc67cb2baafa2b44a46e6","size":8616,"noattachment":false,"key":"/memcpy/-/memcpy-0.6.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/memcpy/download/memcpy-0.6.0.tgz"},"directories":{},"publish_time":1436908617099,"_cnpm_publish_time":1436908617099,"_hasShrinkwrap":false},"0.5.0":{"name":"memcpy","version":"0.5.0","author":{"name":"Daniel Wirtz","email":"dcode@dcode.io"},"contributors":[{"name":"Denys Khanzhiyev","email":"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"},"homepage":"https://github.com/dcodeIO/node-memcpy","_id":"memcpy@0.5.0","_shasum":"1816ca5824096112209fdbb84696d69280925cf0","_from":".","_npmVersion":"1.4.9","_npmUser":{"name":"dcode","email":"dcode@dcode.io"},"maintainers":[{"name":"dcode","email":""}],"dist":{"shasum":"1816ca5824096112209fdbb84696d69280925cf0","size":8307,"noattachment":false,"key":"/memcpy/-/memcpy-0.5.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/memcpy/download/memcpy-0.5.0.tgz"},"directories":{},"publish_time":1403877623273,"_cnpm_publish_time":1403877623273,"_hasShrinkwrap":false},"0.4.0":{"name":"memcpy","version":"0.4.0","author":{"name":"Daniel Wirtz","email":"dcode@dcode.io"},"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"},"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"},"readmeFilename":"README.md","_id":"memcpy@0.4.0","dist":{"shasum":"a789c37a14fbbf6f76b3ee049d74b87fef544644","size":8165,"noattachment":false,"key":"/memcpy/-/memcpy-0.4.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/memcpy/download/memcpy-0.4.0.tgz"},"_from":".","_npmVersion":"1.2.32","_npmUser":{"name":"dcode","email":"dcode@dcode.io"},"maintainers":[{"name":"dcode","email":""}],"directories":{},"publish_time":1388623972484,"_cnpm_publish_time":1388623972484,"_hasShrinkwrap":false},"0.3.0":{"name":"memcpy","version":"0.3.0","author":{"name":"Daniel Wirtz","email":"dcode@dcode.io"},"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"},"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"},"readmeFilename":"README.md","_id":"memcpy@0.3.0","dist":{"shasum":"1e7ceeb067650db2fa328b3d1a58b19a81b90978","size":8053,"noattachment":false,"key":"/memcpy/-/memcpy-0.3.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/memcpy/download/memcpy-0.3.0.tgz"},"_from":".","_npmVersion":"1.2.32","_npmUser":{"name":"dcode","email":"dcode@dcode.io"},"maintainers":[{"name":"dcode","email":""}],"directories":{},"publish_time":1388616020847,"_cnpm_publish_time":1388616020847,"_hasShrinkwrap":false},"0.2.0":{"name":"memcpy","version":"0.2.0","author":{"name":"Daniel Wirtz","email":"dcode@dcode.io"},"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"},"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"},"readmeFilename":"README.md","_id":"memcpy@0.2.0","dist":{"shasum":"acf1d1588c5a1d68f1219f56e662277adc41b687","size":7818,"noattachment":false,"key":"/memcpy/-/memcpy-0.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/memcpy/download/memcpy-0.2.0.tgz"},"_from":".","_npmVersion":"1.2.32","_npmUser":{"name":"dcode","email":"dcode@dcode.io"},"maintainers":[{"name":"dcode","email":""}],"directories":{},"publish_time":1388602002752,"_cnpm_publish_time":1388602002752,"_hasShrinkwrap":false},"0.1.0":{"name":"memcpy","version":"0.1.0","author":{"name":"Daniel Wirtz","email":"dcode@dcode.io"},"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"},"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"},"readmeFilename":"README.md","_id":"memcpy@0.1.0","dist":{"shasum":"7d86f165885ee36ef7638f36a1b4cd4b96cc093e","size":7756,"noattachment":false,"key":"/memcpy/-/memcpy-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/memcpy/download/memcpy-0.1.0.tgz"},"_from":".","_npmVersion":"1.2.32","_npmUser":{"name":"dcode","email":"dcode@dcode.io"},"maintainers":[{"name":"dcode","email":""}],"directories":{},"publish_time":1388511477219,"_cnpm_publish_time":1388511477219,"_hasShrinkwrap":false}},"readme":"node-memcpy\r\n===========\r\nCopies data between node Buffers and/or ArrayBuffers up to ~75 times faster than in pure JS.\r\n\r\nWait, what?\r\n-----------\r\nnode.js utilizes a non-standard concept of I/O buffers and thus has both its Buffer as well as ArrayBuffer support.\r\nWhile Buffers are nice because they are a lot faster than V8's ArrayBuffers, transferring data between those two\r\ntypes can be ridiculously slow. This is where a node module like memcpy comes into play.\r\n\r\n```\r\n// C++ binding\r\n\r\n i memcpy.100k > cc Buffer -> Buffer: 22.756ms\r\n i memcpy.100k > cc Buffer -> ArrayBuffer: 23.861ms\r\n\r\n i memcpy.100k > cc ArrayBuffer -> Buffer: 22.955ms\r\n i memcpy.100k > cc ArrayBuffer -> ArrayBuffer: 23.273ms\r\n\r\n// Native JS\r\n\r\n i memcpy.100k > js Buffer -> Buffer: 21.617ms\r\n i memcpy.100k > js Buffer -> ArrayBuffer: 993.361ms\r\n\r\n i memcpy.100k > js ArrayBuffer -> Buffer: 940.273ms\r\n i memcpy.100k > js ArrayBuffer -> ArrayBuffer: 1626.182ms\r\n```\r\n\r\nAPI\r\n---\r\n##### memcpy(target[, targetStart=0], source[, sourceStart=0[, sourceEnd=source.length]):bytesCopied\r\n\r\n| Argument     | Type                      | Optional  | Description\r\n|--------------|---------------------------|-----------|------------------------------------------------------------------\r\n| target       | Buffer &#124; ArrayBuffer |           | Target buffer to copy to\r\n| targetStart  | number                    | omittable | Target offset to begin copying to, defaults to `0`\r\n| source       | Buffer &#124; ArrayBuffer |           | Source buffer to copy from\r\n| sourceStart  | number                    | optional  | Source offset to begin copying from, defaults to `0`\r\n| sourceEnd    | number                    | optional  | Source offset to end copying from, defaults ot `source.length`\r\n| **@returns** | number                    |           | Number of bytes copied\r\n\r\nSource and target regions may overlap.\r\n\r\nUsage\r\n-----\r\n* `npm install memcpy`\r\n\r\n```js\r\nvar memcpy = require(\"memcpy\"), // C++ binding if available, else native JS\r\n    memcpy_binding = memcpy.binding, // C++ binding or NULL if not available\r\n    memcpy_native = memcpy.native; // Native JS\r\n...\r\n```\r\n\r\nPlease keep in mind that - besides the nice numbers - this is still to be considered experimental. I'd love if you'd\r\nreview the C++ code to validate that it's safe. I can't yet think of a sane use case, though, as just sticking with\r\nBuffers on node.js and ArrayBuffers in the browser should be best practice.\r\n\r\nContributors\r\n------------\r\n[Denys Khanzhiyev](https://github.com/xdenser) (node 0.11.13+ support with nan)\r\n\r\n**License:** [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.html)\r\n","_attachments":{},"homepage":"https://github.com/dcodeIO/node-memcpy#readme","bugs":{"url":"https://github.com/dcodeIO/node-memcpy/issues"},"license":"Apache-2.0"}