diff --git a/src/node.cc b/src/node.cc index 8aa33cb0f5..7b29eea4ee 100644 --- a/src/node.cc +++ b/src/node.cc @@ -994,17 +994,6 @@ Local ExecuteString(Local source, Local filename) { return scope.Close(result); } -static Handle ByteLength(const Arguments& args) { - HandleScope scope; - - if (args.Length() < 1 || !args[0]->IsString()) { - return ThrowException(Exception::Error(String::New("Bad argument."))); - } - - Local length = Integer::New(DecodeBytes(args[0], ParseEncoding(args[1], UTF8))); - - return scope.Close(length); -} static Handle Loop(const Arguments& args) { HandleScope scope; @@ -1608,7 +1597,6 @@ static void Load(int argc, char *argv[]) { // define various internal methods NODE_SET_METHOD(process, "loop", Loop); NODE_SET_METHOD(process, "compile", Compile); - NODE_SET_METHOD(process, "_byteLength", ByteLength); NODE_SET_METHOD(process, "_needTickCallback", NeedTickCallback); NODE_SET_METHOD(process, "reallyExit", Exit); NODE_SET_METHOD(process, "chdir", Chdir); diff --git a/src/node.js b/src/node.js index 6435a0e22d..1562289dfa 100644 --- a/src/node.js +++ b/src/node.js @@ -21,6 +21,7 @@ process.unwatchFile = removed("process.unwatchFile() has moved to fs.unwatchFile process.mixin = removed('process.mixin() has been removed.'); process.createChildProcess = removed("childProcess API has changed. See doc/api.txt."); process.inherits = removed("process.inherits() has moved to sys.inherits."); +process._byteLength = removed("process._byteLength() has moved to Buffer.byteLength"); process.assert = function (x, msg) { if (!x) throw new Error(msg || "assertion error"); diff --git a/test/simple/test-buffer.js b/test/simple/test-buffer.js index abc234b835..78a2106a4a 100644 --- a/test/simple/test-buffer.js +++ b/test/simple/test-buffer.js @@ -318,3 +318,8 @@ assert.equal(sb, s); b = new Buffer("abcde"); assert.equal("bcde", b.slice(1).toString()); +// byte length +assert.equal(14, Buffer.byteLength("Il était tué")); +assert.equal(14, Buffer.byteLength("Il était tué", "utf8")); +assert.equal(12, Buffer.byteLength("Il était tué", "ascii")); +assert.equal(12, Buffer.byteLength("Il était tué", "binary")); diff --git a/test/simple/test-byte-length.js b/test/simple/test-byte-length.js deleted file mode 100644 index 9f7da8c31c..0000000000 --- a/test/simple/test-byte-length.js +++ /dev/null @@ -1,16 +0,0 @@ -common = require("../common"); -assert = common.assert - -assert.equal(14, process._byteLength("Il était tué")); -assert.equal(14, process._byteLength("Il était tué", "utf8")); - -assert.equal(12, process._byteLength("Il était tué", "ascii")); - -assert.equal(12, process._byteLength("Il était tué", "binary")); - -assert.throws(function() { - process._byteLength(); -}); -assert.throws(function() { - process._byteLength(5); -});