regexp-map

0.3.1 • Public • Published

regexp-map

Curried function which takes a map of RegExp string keys which when successfully matched given string, resolves to mapped value.

Build Status Code Climate js-standard-style

npm install regexp-map --save

You can also use Duo, Bower or download the files manually.

npm stats

npm NPM downloads David

API Example

var remap = require('regexp-map')
var makes = remap({
  '^toyota': 'Toyota',
  '^ford': 'Ford',
  '^dodge': 'Dodge'
})
 
makes('Toyota RAV4')
//=> 'Toyota'

API

remap(map, str)

arguments
  • map (Object.<string, string>) Map of RegExp strings which when matched against string successfully, resolves to mapped value.
  • str (String) String to search.
returns
  • (String) When matched returns corresponding mapped value; otherwise, an empty string.

Contributing

SEE: contributing.md

Licenses

GitHub license

Package Sidebar

Install

npm i regexp-map

Weekly Downloads

37

Version

0.3.1

License

MIT

Last publish

Collaborators

  • wilmoore