JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 685
  • Score
    100M100P100Q5689F

Merge an express-style path string with data to create a valid path.

Package Exports

  • reverend

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (reverend) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

reverend

Merge an express-style path string with data to create a valid path. Version 0.3.x adds support for Custom Match and Unnamed parameters as provided by path-to-regexp ^0.2.0. To ensure compatibility, use the version of reverend compatible with path-to-regexp which most closely matches the version your application uses.

Build Status

Usage

var reverend = require('reverend');

reverend(path, object);

  • path (String|Array) - An express-style path, or an array of paths, of which only the first element will be used.
  • object (Object) - An object with keys matching the tokens to be replaced in the route.
'use strict';

var reverend = require('reverend');


var path;

// Path params
path = reverend('/user/:id', { id: 5 });
// '/user/5';

// Optional path params
path = reverend('/user/:id/:operation?', { id: 5 });
// '/user/5/';

// Multiple path params
path = reverend('/user/:id/:operation', { id: 5, operation: address });
// '/user/5/address';

// Custom match parameters
path = reverend('/posts/:id(\\d+)', { id: 5 });
// '/post/5'

path = reverend('/posts/:id(\\d+)', { id: 'foo' }); // throws

// Unnamed params
path = reverend('/:foo/(.*)', { foo: 'foo', 0: 'bar' });
// '/foo/bar'

License

MIT

Tests, Coverage, Linting

$ npm test
$ npm run cover
$ npm run lint