Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/francoischalifour/selectors-to-array
Converts CSS selectors, DOM elements and NodeLists into arrays
https://github.com/francoischalifour/selectors-to-array
array css-selector dom-element javascript nodelist selector
Last synced: about 1 month ago
JSON representation
Converts CSS selectors, DOM elements and NodeLists into arrays
- Host: GitHub
- URL: https://github.com/francoischalifour/selectors-to-array
- Owner: francoischalifour
- License: mit
- Created: 2016-07-31T13:40:58.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-07-31T15:04:50.000Z (over 8 years ago)
- Last Synced: 2024-09-24T18:17:42.389Z (about 2 months ago)
- Topics: array, css-selector, dom-element, javascript, nodelist, selector
- Language: JavaScript
- Homepage: https://npm.im/selectors-to-array
- Size: 2.93 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# selectors-to-array
> Converts [CSS selectors](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors), [DOM elements](https://developer.mozilla.org/en-US/docs/Web/HTML/Element) and [NodeLists](https://developer.mozilla.org/en-US/docs/Web/API/NodeList) into arrays
## Install
```console
$ npm install --save selectors-to-array
```## Usage
```js
const selectorsToArray = require('selectors-to-array')selectorsToArray('input, button')
// => [input#player-1, input#player-2, button]selectorsToArray(document.querySelector('input'))
// => [input#player-1]selectorsToArray(document.querySelectorAll('input'))
// => [input#player-1, input#player-2]const elements = [
document.querySelector('#player-1'),
...document.querySelectorAll('button')
]
selectorsToArray(elements)
// => [input#player-1, button]
```## License
MIT © [François Chalifour](http://francoischalifour.com)