bianco.dom-to-array
Advanced tools
Comparing version 0.0.2 to 0.0.4
16
index.js
'use strict'; | ||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } | ||
var isIterable = _interopDefault(require('bianco.is-iterable')); | ||
/** | ||
* Converts any DOM node/s into a loopable array like object | ||
* Converts any DOM node/s to a loopable array | ||
* @param { HTMLElement|NodeList } els - single html element or a node list | ||
@@ -14,3 +10,3 @@ * @returns { Object } always a loopable object | ||
// can this object be already looped? | ||
if (!isIterable(els)) { | ||
if (!Array.isArray(els)) { | ||
// is it a node list? | ||
@@ -22,8 +18,8 @@ if (els.length) | ||
// it will be returned as "array" with one single entry | ||
return Array.from({ length: 1 }, _ => els) | ||
} else | ||
// this object could be looped out of the box | ||
return els | ||
return [els] | ||
} | ||
// this object could be looped out of the box | ||
return els | ||
} | ||
module.exports = domToArray; |
@@ -1,5 +0,3 @@ | ||
import isIterable from 'bianco.is-iterable' | ||
/** | ||
* Converts any DOM node/s into a loopable array like object | ||
* Converts any DOM node/s to a loopable array | ||
* @param { HTMLElement|NodeList } els - single html element or a node list | ||
@@ -10,3 +8,3 @@ * @returns { Object } always a loopable object | ||
// can this object be already looped? | ||
if (!isIterable(els)) { | ||
if (!Array.isArray(els)) { | ||
// is it a node list? | ||
@@ -18,6 +16,6 @@ if (els.length) | ||
// it will be returned as "array" with one single entry | ||
return Array.from({ length: 1 }, _ => els) | ||
} else | ||
// this object could be looped out of the box | ||
return els | ||
return [els] | ||
} | ||
// this object could be looped out of the box | ||
return els | ||
} |
{ | ||
"name": "bianco.dom-to-array", | ||
"version": "0.0.2", | ||
"description": "Covert DOM node/s into an array like object", | ||
"version": "0.0.4", | ||
"description": "Converts any DOM node/s to a loopable array", | ||
"main": "index.js", | ||
@@ -39,6 +39,3 @@ "jsnext:main": "index.next.js", | ||
"jsdom-global": "2.1.0" | ||
}, | ||
"dependencies": { | ||
"bianco.is-iterable": "^0.0.1" | ||
} | ||
} |
@@ -29,3 +29,3 @@ # bianco.dom-to-array | ||
$lis.length // => 2 | ||
typeof $lis // => 'object' | ||
Array.isArray($lis) // => true | ||
@@ -36,3 +36,3 @@ // It can convert a single node | ||
$li.length // => 1 | ||
typeof $li // => 'object' | ||
Array.isArray($li) // => true | ||
@@ -43,3 +43,3 @@ ``` | ||
- `domToArray` Converts any DOM node/s into a loopable array like object | ||
- `domToArray` Converts any DOM node/s to a loopable array | ||
@@ -46,0 +46,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
0
4464
38
- Removedbianco.is-iterable@^0.0.1
- Removedbianco.is-iterable@0.0.1(transitive)