wrap-node.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. Copyright 2013-2014 Daniel Wirtz <dcode@dcode.io>
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. //? NODE = true;
  14. /**
  15. * @license bytebuffer.js (c) 2015 Daniel Wirtz <dcode@dcode.io>
  16. * Backing buffer / Accessor: node Buffer
  17. * Released under the Apache License, Version 2.0
  18. * see: https://github.com/dcodeIO/bytebuffer.js for details
  19. */
  20. module.exports = (function() {
  21. "use strict";
  22. var buffer = require("buffer"),
  23. Buffer = buffer["Buffer"],
  24. Long = require("long"),
  25. memcpy = null; try { memcpy = require("memcpy"); } catch (e) {}
  26. //? include("ByteBuffer.js");
  27. /**
  28. * node-memcpy. This is an optional binding dependency and may not be present.
  29. * @function
  30. * @param {!(Buffer|ArrayBuffer|Uint8Array)} target Destination
  31. * @param {number|!(Buffer|ArrayBuffer)} targetStart Destination start, defaults to 0.
  32. * @param {(!(Buffer|ArrayBuffer|Uint8Array)|number)=} source Source
  33. * @param {number=} sourceStart Source start, defaults to 0.
  34. * @param {number=} sourceEnd Source end, defaults to capacity.
  35. * @returns {number} Number of bytes copied
  36. * @throws {Error} If any index is out of bounds
  37. * @expose
  38. */
  39. ByteBuffer.memcpy = memcpy;
  40. return ByteBuffer;
  41. })();