throw new TypeError('obj must be an Object');
if (util.isBuffer(obj))
throw new TypeError('obj cannot be a Buffer');
+ if (smalloc.isTypedArray(obj))
+ throw new TypeError('obj cannot be a typed array');
if (!smalloc.hasExternalData(obj))
throw new Error('obj has no external array data');
return obj->HasIndexedPropertiesInExternalArrayData();
}
+void IsTypedArray(const FunctionCallbackInfo<Value>& args) {
+ args.GetReturnValue().Set(args[0]->IsTypedArray());
+}
void AllocTruncate(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
env->SetMethod(exports, "truncate", AllocTruncate);
env->SetMethod(exports, "hasExternalData", HasExternalData);
+ env->SetMethod(exports, "isTypedArray", IsTypedArray);
exports->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "kMaxLength"),
Uint32::NewFromUnsigned(env->isolate(), kMaxLength));
smalloc.dispose(new Buffer());
});
+assert.throws(function() {
+ smalloc.dispose(new Uint8Array(new ArrayBuffer(1)));
+});
+
assert.throws(function() {
smalloc.dispose({});
});