Socket
Book a DemoInstallSign in
Socket

burl

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

burl

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

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

burl

NPM version build status Test coverage Downloads

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

Installation

npm install burl

Usage

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

Create a new burl instance. Takes a single option with optional previous, next and normalize functions. The functions must return their containing value.

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 under the hood.

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

.get()

Get the composed urls for previous and next back in an object.

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

See also

License

MIT

Keywords

hal

FAQs

Package last updated on 14 Oct 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts