You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
492 B

7 years ago
  1. /*!
  2. * depd
  3. * Copyright(c) 2014 Douglas Christopher Wilson
  4. * MIT Licensed
  5. */
  6. /**
  7. * Module exports.
  8. */
  9. module.exports = bufferConcat
  10. /**
  11. * Concatenate an array of Buffers.
  12. */
  13. function bufferConcat(bufs) {
  14. var length = 0
  15. for (var i = 0, len = bufs.length; i < len; i++) {
  16. length += bufs[i].length
  17. }
  18. var buf = new Buffer(length)
  19. var pos = 0
  20. for (var i = 0, len = bufs.length; i < len; i++) {
  21. bufs[i].copy(buf, pos)
  22. pos += bufs[i].length
  23. }
  24. return buf
  25. }