# hashbind

> Dual Binding Library For window.location.hash

Latest version **2.1.1** (published 2017-01-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install hashbind
pnpm add hashbind
yarn add hashbind
bun add hashbind
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.1.1 |
| Published | 2017-01-02 |
| First published | 2015-09-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Joshua T Corbin |
| Maintainers | jcorbin |
| Keywords | hash, bind, dual |

## Links

- npm: https://www.npmjs.com/package/hashbind
- Repository: https://github.com/jcorbin/hashbind
- Issues: https://github.com/jcorbin/hashbind/issues
- npm.io page: https://npm.io/package/hashbind

## Dependencies (1)

- [rezult](https://npm.io/package/rezult.md) ^1.1.0

## Alternatives

- [@gemini-wallet/core](https://npm.io/package/@gemini-wallet/core.md) — 515.6K weekly downloads
- [utility](https://npm.io/package/utility.md) — 416.6K weekly downloads
- [@primno/dpapi](https://npm.io/package/@primno/dpapi.md) — 7.2K weekly downloads
- [pi-readseek](https://npm.io/package/pi-readseek.md) — 3.7K weekly downloads
- [@emilia-protocol/verify](https://npm.io/package/@emilia-protocol/verify.md) — 1.1K weekly downloads

## Recent versions

- 2.1.1 (latest) — 2017-01-02
- 2.1.0 — 2015-10-07
- 2.0.3 — 2015-10-05
- 2.0.2 — 2015-10-04
- 2.0.1 — 2015-10-04
- 2.0.0 — 2015-10-01
- 1.1.0 — 2015-10-01
- 1.0.0 — 2015-09-30

## README

# [Hash Bind](//jcorbin.github.io/hashbind)

A dual-binding library for `window.location.hash`

## Example

```javascript
var Hash = require('hashbind');
var Result = require('rezult');

var hash = new Hash(window);

// Simple usage as a key-value store:
var someVal = hash.get('setting');
hash.set('setting', someVal);

// Better still, bind the value:
var bound = hash.bind('setting')
    .addListener(function onSettingChange(val) {
        console.log('the setting is', val);
    })
    ;

// Maybe you wanted an integer setting:
var bound = hash.bind('setting')
    .setParse(Result.lift(parseInt))
    .addListener(function onSettingChange(val) {
        console.log('the setting is', val);
    })
    ;

// Maybe you wanted a default:
var bound = hash.bind('setting')
    .setParse(Result.lift(parseInt))
    .setDefault('42')
    .addListener(function onSettingChange(val) {
        console.log('the setting is', val);
    })
    ;

// You can still set it by name:
hash.set('setting', 99);

// You can also set it through the bound reference:
bound.set(99);

// If you care to handle parse errors when settingy our values (rather than
have them thrown):
bound.set('XXX', function setDone(err, str, val) {
    // err is null or the parse error
    // str is the string that was parsed
    // val is the value returned by the parser
    console.error(err);
});

```

## MIT Licensed

---
_Source: https://npm.io/package/hashbind · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
