component-type
Advanced tools
Comparing version
14
index.js
@@ -29,9 +29,19 @@ /** | ||
if (typeof Buffer != 'undefined' && Buffer.isBuffer(val)) return 'buffer'; | ||
if (isBuffer(val)) return 'buffer'; | ||
val = val.valueOf | ||
? val.valueOf() | ||
: Object.prototype.valueOf.apply(val) | ||
: Object.prototype.valueOf.apply(val); | ||
return typeof val; | ||
}; | ||
// code borrowed from https://github.com/feross/is-buffer/blob/master/index.js | ||
function isBuffer(obj) { | ||
return !!(obj != null && | ||
(obj._isBuffer || // For Safari 5-7 (missing Object.prototype.constructor) | ||
(obj.constructor && | ||
typeof obj.constructor.isBuffer === 'function' && | ||
obj.constructor.isBuffer(obj)) | ||
)) | ||
} |
{ | ||
"name": "component-type", | ||
"description": "Cross-browser type assertions (less broken typeof)", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"keywords": [ | ||
@@ -6,0 +6,0 @@ "typeof", |
@@ -76,6 +76,7 @@ var type = require('type') | ||
assert('object' === type(b)); | ||
window.Buffer = { isBuffer: function(val){ return val === b } }; | ||
assert('buffer' === type(b)); | ||
delete window.Buffer; | ||
if (window.Buffer) { | ||
var val = new Buffer(4); | ||
assert('buffer' === type(val)); | ||
} | ||
}); | ||
}); |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
119654
0.23%4669
0.21%1
Infinity%