# linkstash

> Save hal-json _link properties and retrieve the latest link in a set.

Latest version **1.0.1** (published 2014-10-14) · MIT license · 0 weekly downloads

## Install

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

## 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 | 1.0.1 |
| Published | 2014-10-14 |
| First published | 2014-10-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | yoshuawuyts |
| Keywords | hal, links, store, link |

## Links

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

## Alternatives

- [localforage](https://npm.io/package/localforage.md) — 6.2M weekly downloads
- [localforage-observable](https://npm.io/package/localforage-observable.md) — 30.8K weekly downloads
- [@y/y](https://npm.io/package/@y/y.md) — 30.1K weekly downloads
- [@metaobjectsdev/render](https://npm.io/package/@metaobjectsdev/render.md) — 3.5K weekly downloads
- [@ledgerhq/coin-algorand](https://npm.io/package/@ledgerhq/coin-algorand.md) — 1.1K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2014-10-14
- 1.0.0 — 2014-10-13

## README

# linkstash
[![NPM version][npm-image]][npm-url]
[![build status][travis-image]][travis-url]
[![Test coverage][coveralls-image]][coveralls-url]
[![Downloads][downloads-image]][downloads-url]

Save [`hal-json`]() `_link` properties and retrieve the latest link in a set.
E.g. after multiple calls for new data in a set you keep pointers to the
oldest and newest data in your set.

## Installation
```bash
npm install linkstash
```

## Usage
```js
var linkstash = require('linkstash');

var links = linkstash(function(val) {
  return parseInt(val.split('=')[1]);
});

links.set({
  _previous: 'foo.com?until=10',
  _next: 'foo.com?from=100'
});

links.get();
// => {
//  previous: 'foo.com?until=10',
//  next: 'foo.com?from=100'
// }

links.set({
  _previous: 'foo.com?until=100',
  _next: 'foo.com?from=val=190'
});

links.get()
// => {
//  previous: 'foo.com?until=10',
//  next: 'foo.com?from=190'
// }
```

## API
#### var links = linkstash()
Create a new `linkstash` instance. Takes `normalize` function which normalizes
strings to be compared. The function
```js
var linkstash = require('linkstash');

var links = linkstash(function(val) {
  return parseInt(val.splice(10));
});
```

#### links.set()
Pass in a new object with a `previous` and `next` property (either can have an
optional `_` prepended). When setting the values will be parsed through the
earlier set `normalize` function and compared. For `previous` values, the lowest
value remains. For `next` values, the highest value remains.
```js
links({
  previous: 'mysite.com/?until=1234567',
  next: 'mysite.com/?from=7654321'
})

links({
  _previous: 'mysite.com/?until=1234568',
  _next: 'mysite.com/?from=8654321'
})
```

#### links.get()
Get the stored links. Values are returned __without__ prepending `_`.
```js
links.get();
// => {
//   previous: 'mysite.com/?until=1234567',
//   next: 'mysite.com/?from=7654321'
// }
```

## See also
- [burl][burl]

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

[npm-image]: https://img.shields.io/npm/v/linkstash.svg?style=flat-square
[npm-url]: https://npmjs.org/package/linkstash
[travis-image]: https://img.shields.io/travis/yoshuawuyts/linkstash.svg?style=flat-square
[travis-url]: https://travis-ci.org/yoshuawuyts/linkstash
[coveralls-image]: https://img.shields.io/coveralls/yoshuawuyts/linkstash.svg?style=flat-square
[coveralls-url]: https://coveralls.io/r/yoshuawuyts/linkstash?branch=master
[downloads-image]: http://img.shields.io/npm/dm/linkstash.svg?style=flat-square
[downloads-url]: https://npmjs.org/package/linkstash

[burl]: https://github.com/yoshuawuyts/burl

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