From 5f6579d3661b5a55ccefdcbc4e24d4b1ebea6588 Mon Sep 17 00:00:00 2001 From: Sakthipriyan Vairamani Date: Mon, 14 Sep 2015 22:26:35 +0530 Subject: [PATCH] buffer: remove raw & raws encoding As `raw` and `raws` encodings are deprecated for such a long time, and they both are undocumented, this patch removes the support for those encodings completely. Previous discussion: https://github.com/nodejs/node/pull/2829 PR-URL: https://github.com/nodejs/node/pull/2859 Reviewed-By: Brian White Reviewed-By: Trevor Norris Reviewed-By: Ben Noordhuis --- lib/buffer.js | 4 ---- src/node.cc | 12 ------------ test/parallel/test-buffer-bytelength.js | 4 ++-- test/parallel/test-file-read-noexist.js | 2 +- 4 files changed, 3 insertions(+), 19 deletions(-) diff --git a/lib/buffer.js b/lib/buffer.js index 26b51a888ffb71..e6b348d933ce56 100644 --- a/lib/buffer.js +++ b/lib/buffer.js @@ -194,7 +194,6 @@ Buffer.isEncoding = function(encoding) { case 'ucs-2': case 'utf16le': case 'utf-16le': - case 'raw': return true; default: @@ -260,9 +259,6 @@ function byteLength(string, encoding) { switch (encoding) { case 'ascii': case 'binary': - // Deprecated - case 'raw': - case 'raws': return len; case 'utf8': diff --git a/src/node.cc b/src/node.cc index f763f67b368f05..d59cdeb55dbe13 100644 --- a/src/node.cc +++ b/src/node.cc @@ -1217,18 +1217,6 @@ enum encoding ParseEncoding(const char* encoding, return BUFFER; } else if (strcasecmp(encoding, "hex") == 0) { return HEX; - } else if (strcasecmp(encoding, "raw") == 0) { - if (!no_deprecation) { - fprintf(stderr, "'raw' (array of integers) has been removed. " - "Use 'binary'.\n"); - } - return BINARY; - } else if (strcasecmp(encoding, "raws") == 0) { - if (!no_deprecation) { - fprintf(stderr, "'raws' encoding has been renamed to 'binary'. " - "Please update your code.\n"); - } - return BINARY; } else { return default_encoding; } diff --git a/test/parallel/test-buffer-bytelength.js b/test/parallel/test-buffer-bytelength.js index c136c62808e8fc..b292970f94184a 100644 --- a/test/parallel/test-buffer-bytelength.js +++ b/test/parallel/test-buffer-bytelength.js @@ -5,9 +5,9 @@ var assert = require('assert'); var Buffer = require('buffer').Buffer; // coerce values to string -assert.equal(Buffer.byteLength(32, 'raw'), 2); +assert.equal(Buffer.byteLength(32, 'binary'), 2); assert.equal(Buffer.byteLength(NaN, 'utf8'), 3); -assert.equal(Buffer.byteLength({}, 'raws'), 15); +assert.equal(Buffer.byteLength({}, 'binary'), 15); assert.equal(Buffer.byteLength(), 9); // special case: zero length string diff --git a/test/parallel/test-file-read-noexist.js b/test/parallel/test-file-read-noexist.js index 47c8d256e3ba18..5c63df321f5ba7 100644 --- a/test/parallel/test-file-read-noexist.js +++ b/test/parallel/test-file-read-noexist.js @@ -6,7 +6,7 @@ var fs = require('fs'); var got_error = false; var filename = path.join(common.fixturesDir, 'does_not_exist.txt'); -fs.readFile(filename, 'raw', function(err, content) { +fs.readFile(filename, 'binary', function(err, content) { if (err) { got_error = true; } else {