$
This commit is contained in:
21
node_modules/bianco.dom-to-array/LICENSE
generated
vendored
Normal file
21
node_modules/bianco.dom-to-array/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Gianluca Guarini
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
62
node_modules/bianco.dom-to-array/README.md
generated
vendored
Normal file
62
node_modules/bianco.dom-to-array/README.md
generated
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
# bianco.dom-to-array
|
||||
|
||||
[![Build Status][ci-image]][ci-url]
|
||||
[![NPM version][npm-version-image]][npm-url]
|
||||
[![NPM downloads][npm-downloads-image]][npm-url]
|
||||
[![MIT License][license-image]][license-url]
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import domToArray from 'bianco.dom-to-array'
|
||||
|
||||
var div = document.createElement('div')
|
||||
div.innerHTML = `
|
||||
<ul>
|
||||
<li>one</li>
|
||||
<li>two</li>
|
||||
</ul>
|
||||
`
|
||||
body.appendChild(div)
|
||||
|
||||
// It can convert node list
|
||||
const lis = document.querySelectorAll('li')
|
||||
const $lis = domToArray(lis)
|
||||
$lis.length // => 2
|
||||
Array.isArray($lis) // => true
|
||||
|
||||
// It can convert a single node
|
||||
const li = document.querySelector('li')
|
||||
const $li = domToArray(li)
|
||||
$li.length // => 1
|
||||
Array.isArray($li) // => true
|
||||
```
|
||||
|
||||
[ci-image]:https://img.shields.io/github/workflow/status/biancojs/dom-to-array/test?style=flat-square
|
||||
[ci-url]:https://github.com/biancojs/dom-to-array/actions
|
||||
|
||||
[license-image]: http://img.shields.io/badge/license-MIT-000000.svg?style=flat-square
|
||||
[license-url]: LICENSE.txt
|
||||
|
||||
[npm-version-image]: http://img.shields.io/npm/v/bianco.dom-to-array.svg?style=flat-square
|
||||
[npm-downloads-image]: http://img.shields.io/npm/dm/bianco.dom-to-array.svg?style=flat-square
|
||||
[npm-url]: https://npmjs.org/package/bianco.dom-to-array
|
||||
|
||||
## API
|
||||
|
||||
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
|
||||
|
||||
#### Table of Contents
|
||||
|
||||
- [domToArray](#domtoarray)
|
||||
- [Parameters](#parameters)
|
||||
|
||||
### domToArray
|
||||
|
||||
Converts any DOM node/s to a loopable array
|
||||
|
||||
#### Parameters
|
||||
|
||||
- `els` **([HTMLElement](https://developer.mozilla.org/docs/Web/HTML/Element) \| [NodeList](https://developer.mozilla.org/docs/Web/API/NodeList))** single html element or a node list
|
||||
|
||||
Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** always a loopable object
|
4
node_modules/bianco.dom-to-array/index.d.ts
generated
vendored
Normal file
4
node_modules/bianco.dom-to-array/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
type DOMElement = Window | Document | Element
|
||||
|
||||
export default function domToArray<T extends DOMElement, R extends DOMElement[]>(els: T | T[]): R[];
|
||||
|
27
node_modules/bianco.dom-to-array/index.js
generated
vendored
Normal file
27
node_modules/bianco.dom-to-array/index.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Converts any DOM node/s to a loopable array
|
||||
* @param { HTMLElement|NodeList } els - single html element or a node list
|
||||
* @returns { Array } always a loopable object
|
||||
*/
|
||||
function domToArray(els) {
|
||||
// can this object be already looped?
|
||||
if (!Array.isArray(els)) {
|
||||
// is it a node list?
|
||||
if (
|
||||
/^\[object (HTMLCollection|NodeList|Object)\]$/
|
||||
.test(Object.prototype.toString.call(els))
|
||||
&& typeof els.length === 'number'
|
||||
)
|
||||
return Array.from(els)
|
||||
else
|
||||
// if it's a single node
|
||||
// it will be returned as "array" with one single entry
|
||||
return [els]
|
||||
}
|
||||
// this object could be looped out of the box
|
||||
return els
|
||||
}
|
||||
|
||||
module.exports = domToArray;
|
23
node_modules/bianco.dom-to-array/index.next.js
generated
vendored
Normal file
23
node_modules/bianco.dom-to-array/index.next.js
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* Converts any DOM node/s to a loopable array
|
||||
* @param { HTMLElement|NodeList } els - single html element or a node list
|
||||
* @returns { Array } always a loopable object
|
||||
*/
|
||||
export default function domToArray(els) {
|
||||
// can this object be already looped?
|
||||
if (!Array.isArray(els)) {
|
||||
// is it a node list?
|
||||
if (
|
||||
/^\[object (HTMLCollection|NodeList|Object)\]$/
|
||||
.test(Object.prototype.toString.call(els))
|
||||
&& typeof els.length === 'number'
|
||||
)
|
||||
return Array.from(els)
|
||||
else
|
||||
// if it's a single node
|
||||
// it will be returned as "array" with one single entry
|
||||
return [els]
|
||||
}
|
||||
// this object could be looped out of the box
|
||||
return els
|
||||
}
|
49
node_modules/bianco.dom-to-array/package.json
generated
vendored
Normal file
49
node_modules/bianco.dom-to-array/package.json
generated
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
{
|
||||
"name": "bianco.dom-to-array",
|
||||
"version": "1.1.0",
|
||||
"description": "Converts any DOM node/s to a loopable array",
|
||||
"main": "index.js",
|
||||
"jsnext:main": "index.next.js",
|
||||
"module": "index.next.js",
|
||||
"types": "index.d.ts",
|
||||
"scripts": {
|
||||
"prepare": "npm run build && npm test",
|
||||
"lint": "eslint index.next.js test.js rollup.config.js",
|
||||
"build": "rollup -c",
|
||||
"doc": "documentation readme index.next.js -s API",
|
||||
"test": "npm run lint && mocha test.js"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.next.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/biancojs/dom-to-array.git"
|
||||
},
|
||||
"keywords": [
|
||||
"es6",
|
||||
"es2015",
|
||||
"dom",
|
||||
"array",
|
||||
"iterator",
|
||||
"dom loops",
|
||||
"nodes"
|
||||
],
|
||||
"author": "Gianluca Guarini <gianluca.guarini@gmail.com> (http://gianlucaguarini.com)",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/biancojs/dom-to-array/issues"
|
||||
},
|
||||
"homepage": "https://github.com/biancojs/dom-to-array#readme",
|
||||
"devDependencies": {
|
||||
"@gianlucaguarini/eslint-config": "^2.0.0",
|
||||
"eslint": "^8.10.0",
|
||||
"jsdom": "19.0.0",
|
||||
"jsdom-global": "3.0.2",
|
||||
"mocha": "^9.2.1",
|
||||
"rollup": "^2.70.0",
|
||||
"rollup-plugin-node-resolve": "^3.4.0"
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user