Skip to content

francoischalifour/selectors-to-array

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

selectors-to-array

Converts CSS selectors, DOM elements and NodeLists into arrays

Install

$ npm install --save selectors-to-array

Usage

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