From 4a805ea666e96281375dd62ad5c2c088091387bd Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Thu, 4 Feb 2016 23:59:38 -0800 Subject: [PATCH] Add `_.isArrayBuffer` and `_.isBuffer`. --- lodash.js | 23 +++++++++++++++++++++++ test/test.js | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/lodash.js b/lodash.js index e4d5a4cf2..fe05953ec 100644 --- a/lodash.js +++ b/lodash.js @@ -9444,6 +9444,27 @@ */ var isArray = Array.isArray; + /** + * Checks if `value` is classified as an `ArrayBuffer` object. + * + * @static + * @memberOf _ + * @type Function + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @example + * + * _.isArrayBuffer(new ArrayBuffer(2)); + * // => true + * + * _.isArrayBuffer(new Array(2)); + * // => false + */ + function isArrayBuffer(value) { + return isObjectLike(value) && objectToString.call(value) == arrayBufferTag; + } + /** * Checks if `value` is array-like. A value is considered array-like if it's * not a function and has a `value.length` that's an integer greater than or @@ -14250,9 +14271,11 @@ lodash.invoke = invoke; lodash.isArguments = isArguments; lodash.isArray = isArray; + lodash.isArrayBuffer = isArrayBuffer; lodash.isArrayLike = isArrayLike; lodash.isArrayLikeObject = isArrayLikeObject; lodash.isBoolean = isBoolean; + lodash.isBuffer = isBuffer; lodash.isDate = isDate; lodash.isElement = isElement; lodash.isEmpty = isEmpty; diff --git a/test/test.js b/test/test.js index 79fc83e26..4c12856f3 100644 --- a/test/test.js +++ b/test/test.js @@ -23623,7 +23623,7 @@ var acceptFalsey = lodashStable.difference(allMethods, rejectFalsey); QUnit.test('should accept falsey arguments', function(assert) { - assert.expect(289); + assert.expect(291); var emptyArrays = lodashStable.map(falsey, alwaysEmptyArray);