open-index/open-npm huggingface dataset:
npm package: @pirxpilot/nanohref
Description: Tiny href click handler library
Latest version: 2.0.0

[![NPM version][npm-image]][npm-url]
[![Build Status][build-image]][build-url]
[![Dependency Status][deps-image]][deps-url]

# @pirxpilot/nanoraf

Fork of [nanohref]. Tiny href click handler library.

## Usage
```js
var nanohref = require('@pirxpilot/nanohref')

// Handler automatically attached to window.document
nanohref(function (location) {
  console.log('new location is', location.pathname)
})

// Create DOM node
var el = document.createElement('a')
el.setAttribute('href', '/my-link')
el.innerText = 'Click me'
document.body.appendChild(el)

// Trigger click
el.click()
// => "new location is /my-link"
```

## Ignoring links
By default all href links are handled. The event is not handled under the
following conditions:
- the click event had `.preventDefault()` called on it
- the link has a `data-nanohref-ignore` attribute
- the link has a `target="_blank"` attribute with `rel="noopener noreferrer"`
- a modifier key is enabled (e.g. `ctrl`, `alt`, `shift` or `meta`)
- the link's href starts with protocol handler such as `mailto:` or `dat:`
- the link points to a different host
- the link has a `download` attribute

:warning: Note that we only handle `target=_blank` if they also have
`rel="noopener"` on them. This is needed to [properly sandbox web
pages](https://mathiasbynens.github.io/rel-noopener/).

## API
### `nanohref(handler(location))`
Create a new anchor click handler.

## See Also
- [MDN/link-types](https://developer.mozilla.org/en-US/docs/Web/HTML/Link_types)
- [caniuse/rel=noopener](http://caniuse.com/#feat=rel-noopener)
- [mapbox/link-hijacker](https://github.com/mapbox/link-hijacker)

## License
[MIT](https://tldrlegal.com/license/mit-license)

[nanohref]: https://npmjs.org/package/nanohref

[npm-image]: https://img.shields.io/npm/v/@pirxpilot/nanohref
[npm-url]: https://npmjs.org/package/@pirxpilot/nanohref

[build-url]: https://github.com/pirxpilot/nanohref/actions/workflows/check.yaml
[build-image]: https://img.shields.io/github/actions/workflow/status/pirxpilot/nanohref/check.yaml?branch=main

[deps-image]: https://img.shields.io/librariesio/release/npm/@pirxpilot/nanohref
[deps-url]: https://libraries.io/npm/@pirxpilot%2Fnanohref
npm package: @pirxpilot/nanoraf
Description: Only call RAF when needed
Latest version: 1.0.0

[![NPM version][npm-image]][npm-url]
[![Build Status][build-image]][build-url]
[![Dependency Status][deps-image]][deps-url]

# @pirxpilot/nanoraf

Fork of [nanoraf]. Only call RAF when needed.

## Usage
```js
var nanoraf = require('@pirxpilot/nanoraf')
var prev = null

var frame = nanoraf(function render (state) {
  console.log(state.now)
})

updateState({ now: date.now() })
updateState({ now: date.now() })
updateState({ now: date.now() })
updateState({ now: date.now() })

function updateState (state) {
  prev = prev || {}
  frame(state, prev)
  prev = state
}
```

## API
### frame = nanoraf(render, raf?)
Wrap a `render` function that is called on every `raf` tick. If no new state is
available, it will not tick. Passes the last version of the state on every tick.

Optionally, provide an implementation of `requestAnimationFrame` via the
`raf` parameter (for example, the one provided by the [raf
package](https://www.npmjs.com/package/raf)).  If omitted, `raf` defaults to
`window.requestAnimationFrame`.

### frame([arguments])
Pass arguments into the render function, to be called on a new tick.

## Installation
```sh
$ npm install nanoraf
```

## License
[MIT](https://tldrlegal.com/license/mit-license)

[nanoraf]: https://npmjs.org/package/nanoraf

[npm-image]: https://img.shields.io/npm/v/@pirxpilot/nanoraf
[npm-url]: https://npmjs.org/package/@pirxpilot/nanoraf

[build-url]: https://github.com/pirxpilot/nanoraf/actions/workflows/check.yaml
[build-image]: https://img.shields.io/github/workflow/status/pirxpilot/nanoraf/check

[deps-image]: https://img.shields.io/librariesio/release/npm/@pirxpilot/nanoraf
[deps-url]: https://libraries.io/npm/@pirxpilot%2Fnanoraf