util
Advanced tools
Comparing version 0.12.2 to 0.12.3
@@ -7,2 +7,7 @@ # util change log | ||
## 0.12.3 | ||
* Use robust `which-typed-array`, `is-typed-array` modules for the `util.types.isTypedArray` family of functions. ([@wbinnssmith](https://github.com/wbinnssmith) in [#47](https://github.com/browserify/node-util/pull/47)) | ||
This fixes crash in IE11 when a polyfilled `Symbol` is available in the environment. | ||
## 0.12.2 | ||
@@ -9,0 +14,0 @@ * Move `object.entries` dependency to a dev-only dependency. ([@goto-bus-stop](https://github.com/goto-bus-stop) in [622f036](https://github.com/browserify/node-util/commit/622f0361540997e7e7b8abcff9865b47b2fa658c)) |
{ | ||
"name": "util", | ||
"description": "Node.js's util module for all engines", | ||
"version": "0.12.2", | ||
"version": "0.12.3", | ||
"author": { | ||
@@ -16,6 +16,9 @@ "name": "Joyent", | ||
"is-generator-function": "^1.0.7", | ||
"safe-buffer": "^5.1.2" | ||
"is-typed-array": "^1.1.3", | ||
"safe-buffer": "^5.1.2", | ||
"which-typed-array": "^1.1.2" | ||
}, | ||
"devDependencies": { | ||
"airtap": "~1.0.0", | ||
"core-js": "^3.6.5", | ||
"is-async-supported": "~1.2.0", | ||
@@ -44,4 +47,6 @@ "object.assign": "~4.1.0", | ||
"test:browsers": "airtap test/browser/index.js", | ||
"test:browsers:with-polyfills": "airtap test/browser/with-polyfills.js", | ||
"test:browsers:with-polyfills:local": "npm run test:browsers:with-polyfills -- --local", | ||
"test:browsers:local": "npm run test:browsers -- --local" | ||
} | ||
} |
@@ -6,6 +6,6 @@ // Currently in sync with Node.js lib/internal/util/types.js | ||
var isBuffer = require('./isBuffer'); | ||
var isArgumentsObject = require('is-arguments'); | ||
var isGeneratorFunction = require('is-generator-function'); | ||
var whichTypedArray = require('which-typed-array'); | ||
var isTypedArray = require('is-typed-array'); | ||
@@ -18,16 +18,3 @@ function uncurryThis(f) { | ||
var SymbolSupported = typeof Symbol !== 'undefined'; | ||
var SymbolToStringTagSupported = SymbolSupported && typeof Symbol.toStringTag !== 'undefined'; | ||
var Uint8ArraySupported = typeof Uint8Array !== 'undefined'; | ||
var ArrayBufferSupported = typeof ArrayBuffer !== 'undefined'; | ||
if (Uint8ArraySupported && SymbolToStringTagSupported) { | ||
var TypedArrayPrototype = Object.getPrototypeOf(Uint8Array.prototype); | ||
var TypedArrayProto_toStringTag = | ||
uncurryThis( | ||
Object.getOwnPropertyDescriptor(TypedArrayPrototype, | ||
Symbol.toStringTag).get); | ||
} | ||
var ObjectToString = uncurryThis(Object.prototype.toString); | ||
@@ -60,4 +47,4 @@ | ||
exports.isArgumentsObject = isArgumentsObject; | ||
exports.isGeneratorFunction = isGeneratorFunction; | ||
exports.isTypedArray = isTypedArray; | ||
@@ -83,3 +70,3 @@ // Taken from here and modified for better browser support | ||
function isArrayBufferView(value) { | ||
if (ArrayBufferSupported && ArrayBuffer.isView) { | ||
if (typeof ArrayBuffer !== 'undefined' && ArrayBuffer.isView) { | ||
return ArrayBuffer.isView(value); | ||
@@ -95,35 +82,5 @@ } | ||
function isTypedArray(value) { | ||
if (Uint8ArraySupported && SymbolToStringTagSupported) { | ||
return TypedArrayProto_toStringTag(value) !== undefined; | ||
} else { | ||
return ( | ||
isUint8Array(value) || | ||
isUint8ClampedArray(value) || | ||
isUint16Array(value) || | ||
isUint32Array(value) || | ||
isInt8Array(value) || | ||
isInt16Array(value) || | ||
isInt32Array(value) || | ||
isFloat32Array(value) || | ||
isFloat64Array(value) || | ||
isBigInt64Array(value) || | ||
isBigUint64Array(value) | ||
); | ||
} | ||
} | ||
exports.isTypedArray = isTypedArray; | ||
function isUint8Array(value) { | ||
if (Uint8ArraySupported && SymbolToStringTagSupported) { | ||
return TypedArrayProto_toStringTag(value) === 'Uint8Array'; | ||
} else { | ||
return ( | ||
ObjectToString(value) === '[object Uint8Array]' || | ||
// If it's a Buffer instance _and_ has a `.buffer` property, | ||
// this is an ArrayBuffer based buffer; thus it's an Uint8Array | ||
// (Old Node.js had a custom non-Uint8Array implementation) | ||
isBuffer(value) && value.buffer !== undefined | ||
); | ||
} | ||
return whichTypedArray(value) === 'Uint8Array'; | ||
} | ||
@@ -133,7 +90,3 @@ exports.isUint8Array = isUint8Array; | ||
function isUint8ClampedArray(value) { | ||
if (Uint8ArraySupported && SymbolToStringTagSupported) { | ||
return TypedArrayProto_toStringTag(value) === 'Uint8ClampedArray'; | ||
} else { | ||
return ObjectToString(value) === '[object Uint8ClampedArray]'; | ||
} | ||
return whichTypedArray(value) === 'Uint8ClampedArray'; | ||
} | ||
@@ -143,7 +96,3 @@ exports.isUint8ClampedArray = isUint8ClampedArray; | ||
function isUint16Array(value) { | ||
if (Uint8ArraySupported && SymbolToStringTagSupported) { | ||
return TypedArrayProto_toStringTag(value) === 'Uint16Array'; | ||
} else { | ||
return ObjectToString(value) === '[object Uint16Array]'; | ||
} | ||
return whichTypedArray(value) === 'Uint16Array'; | ||
} | ||
@@ -153,7 +102,3 @@ exports.isUint16Array = isUint16Array; | ||
function isUint32Array(value) { | ||
if (Uint8ArraySupported && SymbolToStringTagSupported) { | ||
return TypedArrayProto_toStringTag(value) === 'Uint32Array'; | ||
} else { | ||
return ObjectToString(value) === '[object Uint32Array]'; | ||
} | ||
return whichTypedArray(value) === 'Uint32Array'; | ||
} | ||
@@ -163,7 +108,3 @@ exports.isUint32Array = isUint32Array; | ||
function isInt8Array(value) { | ||
if (Uint8ArraySupported && SymbolToStringTagSupported) { | ||
return TypedArrayProto_toStringTag(value) === 'Int8Array'; | ||
} else { | ||
return ObjectToString(value) === '[object Int8Array]'; | ||
} | ||
return whichTypedArray(value) === 'Int8Array'; | ||
} | ||
@@ -173,7 +114,3 @@ exports.isInt8Array = isInt8Array; | ||
function isInt16Array(value) { | ||
if (Uint8ArraySupported && SymbolToStringTagSupported) { | ||
return TypedArrayProto_toStringTag(value) === 'Int16Array'; | ||
} else { | ||
return ObjectToString(value) === '[object Int16Array]'; | ||
} | ||
return whichTypedArray(value) === 'Int16Array'; | ||
} | ||
@@ -183,7 +120,3 @@ exports.isInt16Array = isInt16Array; | ||
function isInt32Array(value) { | ||
if (Uint8ArraySupported && SymbolToStringTagSupported) { | ||
return TypedArrayProto_toStringTag(value) === 'Int32Array'; | ||
} else { | ||
return ObjectToString(value) === '[object Int32Array]'; | ||
} | ||
return whichTypedArray(value) === 'Int32Array'; | ||
} | ||
@@ -193,7 +126,3 @@ exports.isInt32Array = isInt32Array; | ||
function isFloat32Array(value) { | ||
if (Uint8ArraySupported && SymbolToStringTagSupported) { | ||
return TypedArrayProto_toStringTag(value) === 'Float32Array'; | ||
} else { | ||
return ObjectToString(value) === '[object Float32Array]'; | ||
} | ||
return whichTypedArray(value) === 'Float32Array'; | ||
} | ||
@@ -203,7 +132,3 @@ exports.isFloat32Array = isFloat32Array; | ||
function isFloat64Array(value) { | ||
if (Uint8ArraySupported && SymbolToStringTagSupported) { | ||
return TypedArrayProto_toStringTag(value) === 'Float64Array'; | ||
} else { | ||
return ObjectToString(value) === '[object Float64Array]'; | ||
} | ||
return whichTypedArray(value) === 'Float64Array'; | ||
} | ||
@@ -213,7 +138,3 @@ exports.isFloat64Array = isFloat64Array; | ||
function isBigInt64Array(value) { | ||
if (Uint8ArraySupported && SymbolToStringTagSupported) { | ||
return TypedArrayProto_toStringTag(value) === 'BigInt64Array'; | ||
} else { | ||
return ObjectToString(value) === '[object BigInt64Array]'; | ||
} | ||
return whichTypedArray(value) === 'BigInt64Array'; | ||
} | ||
@@ -223,7 +144,3 @@ exports.isBigInt64Array = isBigInt64Array; | ||
function isBigUint64Array(value) { | ||
if (Uint8ArraySupported && SymbolToStringTagSupported) { | ||
return TypedArrayProto_toStringTag(value) === 'BigUint64Array'; | ||
} else { | ||
return ObjectToString(value) === '[object BigUint64Array]'; | ||
} | ||
return whichTypedArray(value) === 'BigUint64Array'; | ||
} | ||
@@ -296,9 +213,2 @@ exports.isBigUint64Array = isBigUint64Array; | ||
return isWeakSetToString(value); | ||
if (typeof WeakSet === 'undefined') { | ||
return false; | ||
} | ||
return isWeakSetToString.working | ||
? isWeakSetToString(value) | ||
: value instanceof WeakSet; | ||
} | ||
@@ -424,3 +334,3 @@ exports.isWeakSet = isWeakSet; | ||
function isAnyArrayBuffer(value) { | ||
return Uint8ArraySupported && ( | ||
return typeof Uint8Array !== 'undefined' && ( | ||
isArrayBuffer(value) || | ||
@@ -427,0 +337,0 @@ isSharedArrayBuffer(value) |
34827
6
7
901
+ Addedis-typed-array@^1.1.3
+ Addedwhich-typed-array@^1.1.2
+ Addedavailable-typed-arrays@1.0.7(transitive)
+ Addedfor-each@0.3.3(transitive)
+ Addedis-callable@1.2.7(transitive)
+ Addedis-typed-array@1.1.13(transitive)
+ Addedpossible-typed-array-names@1.0.0(transitive)
+ Addedwhich-typed-array@1.1.15(transitive)