Fixed issues with binary metadata type checking
diff --git a/src/node/ext/call.cc b/src/node/ext/call.cc
index b08a9f9..f98fe24 100644
--- a/src/node/ext/call.cc
+++ b/src/node/ext/call.cc
@@ -168,8 +168,9 @@
}
if (EndsWith(elem->key, "-bin")) {
Nan::Set(array, index_map[elem->key],
- Nan::CopyBuffer(elem->value,
- elem->value_length).ToLocalChecked());
+ MakeFastBuffer(
+ Nan::CopyBuffer(elem->value,
+ elem->value_length).ToLocalChecked()));
} else {
Nan::Set(array, index_map[elem->key],
Nan::New(elem->value).ToLocalChecked());
diff --git a/src/node/src/metadata.js b/src/node/src/metadata.js
index c1da70b..5c24e46 100644
--- a/src/node/src/metadata.js
+++ b/src/node/src/metadata.js
@@ -59,6 +59,7 @@
function validate(key, value) {
if (_.endsWith(key, '-bin')) {
if (!(value instanceof Buffer)) {
+ console.log(value.constructor.toString());
throw new Error('keys that end with \'-bin\' must have Buffer values');
}
} else {
@@ -173,7 +174,9 @@
Metadata._fromCoreRepresentation = function(metadata) {
var newMetadata = new Metadata();
if (metadata) {
- newMetadata._internal_repr = _.cloneDeep(metadata);
+ _.forOwn(metadata, function(value, key) {
+ newMetadata._internal_repr[key] = _.clone(value);
+ });
}
return newMetadata;
};