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;
// 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);
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");
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"));
+++ /dev/null
-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);
-});