From 94f429baf0d6a2cdaa5a065d45c849d68bcddc27 Mon Sep 17 00:00:00 2001 From: Unknown Date: Mon, 30 Jul 2018 16:07:40 +0200 Subject: [PATCH] ensure using newer implementation of `Buffer.from` Prior to Node v5.10 (and v4.5) it's impossible to use `Buffer.from` for creating buffers from string. Existence of `Buffer.alloc` implies the newer implementation of `Buffer.from` and possibility to use it with strings. --- lib/index.js | 2 +- src/index.ls | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/index.js b/lib/index.js index d3f903584..97db315cf 100644 --- a/lib/index.js +++ b/lib/index.js @@ -28,7 +28,7 @@ parser.lexer = { return ''; } }; -bufferFrom = Buffer.from || function(it){ +bufferFrom = Buffer.alloc && Buffer.from || function(it){ return new Buffer(it); }; exports.VERSION = '1.5.0'; diff --git a/src/index.ls b/src/index.ls index d9495294f..6aaa30d65 100644 --- a/src/index.ls +++ b/src/index.ls @@ -26,7 +26,7 @@ parser <<< @tokens = it upcoming-input: -> '' -bufferFrom = Buffer.from or -> new Buffer it +bufferFrom = Buffer.alloc and Buffer.from or -> new Buffer it exports <<< VERSION: '1.5.0'