@tiaanduplessis/pika

3.0.0 • Public • Published

pika

Efficient DOM element selection in 427 bytes (gzipped)

npm package version npm downloads standard JS linter Greenkeeper travis ci build status project license make a pull request

Table of Contents

Install

$ npm install @tiaanduplessis/pika
# OR
$ yarn add @tiaanduplessis/pika

Usage

The most relevant method for locating a DOM element will be chosen, because some times document.querySelector won't do:

import pika from '@tiaanduplessis/pika'

pika('body') // document.body
pika('head') // document.head
pika('#foo') // document.getElementById
pika('.foo') // document.getElementsByClassName
pika('div') // document.getElementsByTagName
pika('[value]') // document.querySelectorAll

You can optionally specify your own context(defaults to document):

// find span within #foo
pika('span', { context: pika('#foo') })

By default, the first option is specified as true. This results in the a single element being returned, in case of a single match, instead of a array.

Contributing

Contributions are welcome!

  1. Fork it.
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

Or open up a issue.

License

Licensed under the MIT License.

Readme

Keywords

none

Package Sidebar

Install

npm i @tiaanduplessis/pika

Weekly Downloads

0

Version

3.0.0

License

MIT

Unpacked Size

12.8 kB

Total Files

11

Last publish

Collaborators

  • tiaanduplessis