A tiny library to be used with browserify that gives arrays rather than NodeLists from DOM queries.
$ npm install @artcommacode/q --save
q wraps querySelector and querySelectorAll in one function. It returns arrays rather than NodeLists except when there is a single element in which case it returns the element itself.
var q = require('@artcommacode/q')
q('ul li')
// => [ <li>...</li>, <li>...</li>, <li>...</li> ]
q('ul li')[0].textContent
// => $1
q('ul li')[0] === q('ul li:first-of-type')
// => true
Pass an element in as the second argument to run a query on it:
var ul = q('ul')
q('li', ul)
// => [ <li>...</li>, <li>...</li>, <li>...</li> ]
q will return an empty array if no elements are found:
q('ul div')
// => []
$ npm install && npm test
This will open a tab in your browser to run tests against test/index.html
with the results displayed in your terminal. If you see # ok
then it all went well, if there's any errors please submit an issue.