# burl

> Compute `hal-json:_links` `previous` and `next` values

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

## Install

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

## 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-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Maintainers | yoshuawuyts |
| Keywords | hal, links, json, api, compose |

## Links

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

## Dependencies (1)

- [linkstash](https://npm.io/package/linkstash.md) ^1.0.0

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

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

## README

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

Compute `hal-json:_links` `previous` and `next` values. Useful when urls need
to be processed before being ready to use.

## Installation
```bash
npm install burl
```

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

var links = burl({
  next: function(val) {
    return 'http://mysite.com/api?from=' + val;
  },
  previous: function(val) {
    return 'http://mysite.com/api?until=' + val;
  },
  normalize: function(val) {
    return val.splice(13)[1];
  }
});

links.set({
  previous: 'until=12345677',
  next: 'from=12345677'
});

links.get();
// => {
//   previous: 'http://mysite.com/api?until=12345677',
//   next: 'http://mysite.com/api?from=12345677'
// }
```

## API
#### var links = burl()
Create a new `burl` instance. Takes a single option with optional
`previous`, `next` and `normalize` functions. The functions must return their
containing value.
```js
var burl = require('burl');

var links = burl({
  next: function(val) {
    return 'http://mysite.com/api?from=' + val;
  },
  previous: function(val) {
    return 'http://mysite.com/api?until=' + val;
  },
  normalize: function(val) {
    return val.splice(13)[1];
  }
});
```

#### .set()
Save links to burl. Gets passed through the `normalize` function before
performing a comparison to keep the lowest value for `previous` and the heighest
value for `next`. Uses [`linkstash`][linkstash] under the hood.
```js
links.set({
  previous: 'until=12345677',
  next: 'from=12345677'
});
```

#### .get()
Get the composed urls for `previous` and `next` back in an object.
```js
links.get();
// => {
//   previous: 'http://mysite.com/api?until=12345677',
//   next: 'http://mysite.com/api?from=12345677'
// }
```

## See also
- [linkstash][linkstash]
- [burl-invert][burl-invert]

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

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

[linkstash]: http://github.com/yoshuawuyts/linkstash
[burl-invert]: https://github.com/yoshuawuyts/burl-invert

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