thoughts/node_modules/body-parser/node_modules/depd/lib/compat/buffer-concat.js
node_modules/body-parser/node_modules/depd/lib/compat/buffer-concat.jsRaw
1/*!
2 * depd
3 * Copyright(c) 2014 Douglas Christopher Wilson
4 * MIT Licensed
5 */
6
7'use strict'
8
9/**
10 * Module exports.
11 */
12
13module.exports = bufferConcat
14
15/**
16 * Concatenate an array of Buffers.
17 */
18
19function bufferConcat(bufs) {
20 var length = 0
21
22 for (var i = 0, len = bufs.length; i < len; i++) {
23 length += bufs[i].length
24 }
25
26 var buf = new Buffer(length)
27 var pos = 0
28
29 for (var i = 0, len = bufs.length; i < len; i++) {
30 bufs[i].copy(buf, pos)
31 pos += bufs[i].length
32 }
33
34 return buf
35}