nodelist2array

1.0.2 • Public • Published

What it does

Nodelists are array like object and not proper javascript arrays which makes it impossible to use Array functions like reduce(), map(), filter(), sort() etc in them. This package convert array like object to array

It extends to anything which has .length property but is not a an Array.

Benchmark

[https://jsperf.com/nodelist-to-array/27]

Code and usage

document.querySelectorAll('div').map(...) //WON'T WORK!!!

var divSelectorArray = nodelist2array(document.querySelectorAll('div'))
divSelectorArray.map(...); //It will work properly

Instalation

npm install nodelist2array

Package Sidebar

Install

npm i nodelist2array

Weekly Downloads

3

Version

1.0.2

License

ISC

Unpacked Size

1.54 kB

Total Files

3

Last publish

Collaborators

  • silentlad