Remove process._byteLength
authorRyan Dahl <ry@tinyclouds.org>
Fri, 17 Sep 2010 08:06:44 +0000 (01:06 -0700)
committerRyan Dahl <ry@tinyclouds.org>
Fri, 17 Sep 2010 08:06:44 +0000 (01:06 -0700)
src/node.cc
src/node.js
test/simple/test-buffer.js
test/simple/test-byte-length.js [deleted file]

index 8aa33cb0f525c9b9907233e65b367f5c0d0023be..7b29eea4eebb6d37955f0a5d482425dd5493ce17 100644 (file)
@@ -994,17 +994,6 @@ Local<Value> ExecuteString(Local<String> source, Local<Value> filename) {
   return scope.Close(result);
 }
 
-static Handle<Value> ByteLength(const Arguments& args) {
-  HandleScope scope;
-
-  if (args.Length() < 1 || !args[0]->IsString()) {
-    return ThrowException(Exception::Error(String::New("Bad argument.")));
-  }
-
-  Local<Integer> length = Integer::New(DecodeBytes(args[0], ParseEncoding(args[1], UTF8)));
-
-  return scope.Close(length);
-}
 
 static Handle<Value> 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);
index 6435a0e22da5c0921370fd65cf86a95108432571..1562289dfad88a2c10aea9f7a1d8d0dcf8b63669 100644 (file)
@@ -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");
index abc234b83548592fe6bacbe293bb90a926ef1126..78a2106a4abb86ac5c8a7d037188e97ff4e22d43 100644 (file)
@@ -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 (file)
index 9f7da8c..0000000
+++ /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);
-});