diff --git a/doc/api/buffer.markdown b/doc/api/buffer.markdown index bfdfb91589a..923688a14ab 100644 --- a/doc/api/buffer.markdown +++ b/doc/api/buffer.markdown @@ -698,10 +698,6 @@ buffer. var b = new Buffer(50); b.fill("h"); -### buf.toArrayBuffer() - -Creates a new `ArrayBuffer` with the copied memory of the buffer instance. - ## buffer.INSPECT_MAX_BYTES * Number, Default: 50 diff --git a/src/node_buffer.cc b/src/node_buffer.cc index 64f077a6883..ee43eedc971 100644 --- a/src/node_buffer.cc +++ b/src/node_buffer.cc @@ -572,26 +572,6 @@ void WriteDoubleBE(const FunctionCallbackInfo& args) { } -void ToArrayBuffer(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); - HandleScope scope(env->isolate()); - - ARGS_THIS(args.This()); - void* adata = malloc(obj_length); - - if (adata == NULL) { - FatalError("node::Buffer::ToArrayBuffer(" - "const FunctionCallbackInfo&)", - "Out Of Memory"); - } - - memcpy(adata, obj_data, obj_length); - - Local abuf = ArrayBuffer::New(env->isolate(), adata, obj_length); - args.GetReturnValue().Set(abuf); -} - - void ByteLength(const FunctionCallbackInfo &args) { Environment* env = Environment::GetCurrent(args.GetIsolate()); HandleScope scope(env->isolate()); @@ -679,8 +659,6 @@ void SetupBufferJS(const FunctionCallbackInfo& args) { NODE_SET_METHOD(proto, "writeFloatBE", WriteFloatBE); NODE_SET_METHOD(proto, "writeFloatLE", WriteFloatLE); - NODE_SET_METHOD(proto, "toArrayBuffer", ToArrayBuffer); - NODE_SET_METHOD(proto, "copy", Copy); NODE_SET_METHOD(proto, "fill", Fill); diff --git a/test/simple/test-buffer.js b/test/simple/test-buffer.js index 140fd0b4c64..a0e9c5aceed 100644 --- a/test/simple/test-buffer.js +++ b/test/simple/test-buffer.js @@ -1006,18 +1006,6 @@ assert.throws(function() { } })(); -// Test Buffers to ArrayBuffers -var b = new Buffer(5).fill('abcdf'); -var c = b.toArrayBuffer(); -assert.equal(c.byteLength, 5); -assert.equal(Object.prototype.toString.call(c), '[object ArrayBuffer]'); -var d = new Uint8Array(c); -for (var i = 0; i < 5; i++) - assert.equal(d[i], b[i]); -b.fill('ghijk'); -for (var i = 0; i < 5; i++) - assert.notEqual(d[i], b[i]); - assert.throws(function () { new Buffer(smalloc.kMaxLength + 1);