Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

use buffer-concat

  • Loading branch information...
commit 5e926d9156010571c4254130c68fb813e26aced7 1 parent a1fdc0b
@fengmk2 authored
Showing with 2 additions and 37 deletions.
  1. +1 −37 lib/expand.js
  2. +1 −0  package.json
View
38 lib/expand.js
@@ -10,6 +10,7 @@
* Module dependencies.
*/
+require('buffer-concat');
var http = require('http');
var https = require('https');
var urlutil = require('url');
@@ -141,40 +142,3 @@ function expand(url, options, callback) {
}
module.exports = expand;
-
-/**
- * Let Buffer support concat. node < 0.8
- *
- * https://github.com/joyent/node/blob/master/lib/buffer.js#L504
- */
-
-if (!Buffer.concat) {
- Buffer.concat = function (list, length) {
- if (!Array.isArray(list)) {
- throw new Error('Usage: Buffer.concat(list, [length])');
- }
-
- if (list.length === 0) {
- return new Buffer(0);
- } else if (list.length === 1) {
- return list[0];
- }
-
- if (typeof length !== 'number') {
- length = 0;
- for (var i = 0; i < list.length; i++) {
- var buf = list[i];
- length += buf.length;
- }
- }
-
- var buffer = new Buffer(length);
- var pos = 0;
- for (var i = 0; i < list.length; i++) {
- var buf = list[i];
- buf.copy(buffer, pos);
- pos += buf.length;
- }
- return buffer;
- };
-}
View
1  package.json
@@ -11,6 +11,7 @@
},
"dependencies": {
"charset": ">=0.0.1",
+ "buffer-concat": ">=0.0.1",
"iconv-lite": ">=0.2.5"
},
"devDependencies": {
Please sign in to comment.
Something went wrong with that request. Please try again.