Skip to content

Commit

Permalink
0.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
richrdkng committed Aug 19, 2016
1 parent f61abf5 commit 9c41a8a
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 26 deletions.
50 changes: 28 additions & 22 deletions dist/js-partial-is-array.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* More information on [JavaScript Open Standards]{@link https://github.com/jsopenstd/jsopenstd}.
*
* @namespace js.partial
* @version 0.0.0
* @version 0.0.1
*
* @author Richard King <richrdkng@gmail.com> [GitHub]{@link https://github.com/richrdkng}
* @license [MIT]{@link https://github.com/jsopenstd/js-partial-foreach/blob/master/license.md}
Expand Down Expand Up @@ -43,14 +43,19 @@
* @function isArray
* @memberOf js.partial
*
* @param {*} object - The object to check.
* @param {boolean} [handleTypedArrayAsArray=false] - Handle a typed array as a regular array too.
* By default a typed array is not classified as a regular array.
* @param {boolean} [handleArrayLikeAsArray=false] - Handle an array-like as a regular array too.
* An array-like is anything, that has a valid .length property
* and behaves as a collection, that stores values
* (e.g.: arguments, strings, objects based on arrays/objects).
* By default an array-like is not classified as a regular array.
* @param {*} object - The object to check.
* @param {boolean|null} [handleTypedArrayAsArray=false] - Handle a typed array as a regular array too.
* By default a typed array is not classified
* as a regular array.
* **Pass null to skip this argument** and leave its value
* with the default value.
* @param {boolean} [handleArrayLikeAsArray=false] - Handle an array-like as a regular array too.
* An array-like is anything, that has a valid .length
* property and behaves as a collection, that stores values
* such as arguments, strings, other objects based on
* arrays or objects.
* By default an array-like is not classified
* as a regular array.
*
* @returns {boolean} If the object is an array, it will return true.
*/
Expand All @@ -60,22 +65,23 @@

if (object !== null && typeof object === 'object') {

if ( ! handleTypedArray &&
! handleArrayLike) {

return Object.prototype.toString.call(object) === '[object Array]';
if (Object.prototype.toString.call(object) === '[object Array]') {
return true;
}

if (handleTypedArray) {
return object instanceof Int8Array ||
object instanceof Uint8Array ||
object instanceof Uint8ClampedArray ||
object instanceof Int16Array ||
object instanceof Uint16Array ||
object instanceof Int32Array ||
object instanceof Uint32Array ||
object instanceof Float32Array ||
object instanceof Float64Array;
if (object instanceof Int8Array ||
object instanceof Uint8Array ||
object instanceof Uint8ClampedArray ||
object instanceof Int16Array ||
object instanceof Uint16Array ||
object instanceof Int32Array ||
object instanceof Uint32Array ||
object instanceof Float32Array ||
object instanceof Float64Array) {

return true;
}
}

if (handleArrayLike) {
Expand Down
4 changes: 2 additions & 2 deletions dist/js-partial-is-array.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "js-partial-is-array",
"version": "0.0.0",
"version": "0.0.1",
"description": "A partial to check whether an object is an array.",
"main": "dist/js-partial-is-array.js",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion src/js-partial-is-array.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* More information on [JavaScript Open Standards]{@link https://github.com/jsopenstd/jsopenstd}.
*
* @namespace js.partial
* @version 0.0.0
* @version 0.0.1
*
* @author Richard King <richrdkng@gmail.com> [GitHub]{@link https://github.com/richrdkng}
* @license [MIT]{@link https://github.com/jsopenstd/js-partial-foreach/blob/master/license.md}
Expand Down

0 comments on commit 9c41a8a

Please sign in to comment.