Attempt two to fix bizarro buffer test in Node v0.12.

This commit is contained in:
John-David Dalton
2016-02-11 09:43:16 -08:00
parent 1c47acd040
commit 641112dd4d

View File

@@ -463,6 +463,20 @@
return !(key == 'valueOf' && this && this.valueOf === 1) && _propertyIsEnumerable.call(this, key); return !(key == 'valueOf' && this && this.valueOf === 1) && _propertyIsEnumerable.call(this, key);
}); });
if (Buffer) {
defineProperty(root, 'Buffer', {
'configurable': true,
'enumerable': true,
'get': function get() {
var caller = get.caller,
name = caller.name;
if (!(name == 'runInContext' || name.length == 1 || /\b_\.isBuffer\b/.test(caller))) {
return Buffer;
}
}
});
}
if (Map) { if (Map) {
setProperty(root, 'Map', (function() { setProperty(root, 'Map', (function() {
var count = 0; var count = 0;
@@ -470,31 +484,13 @@
if (count++) { if (count++) {
return new Map; return new Map;
} }
var result = {};
setProperty(root, 'Map', Map); setProperty(root, 'Map', Map);
return result; return {};
}; };
}())); }()));
setProperty(root.Map, 'toString', createToString('Map')); setProperty(root.Map, 'toString', createToString('Map'));
} }
defineProperty(root, 'Buffer', (function() {
var count = 0,
version = lodashStable.get(process, 'versions.node'),
limit = /^0\.12\b/.test(version) ? 2 : 0;
return {
'configurable': true,
'enumerable': true,
'get': function() {
if (++count <= limit) {
return Buffer;
}
setProperty(root, 'Buffer', undefined);
}
};
}()));
setProperty(root, 'Set', noop); setProperty(root, 'Set', noop);
setProperty(root, 'Symbol', undefined); setProperty(root, 'Symbol', undefined);
setProperty(root, 'WeakMap', noop); setProperty(root, 'WeakMap', noop);