regexp-map
v0.3.1
Published
Curried function which takes a map of `RegExp` string keys which when successfully matched given string, resolves to mapped value.
Downloads
22
Maintainers
Readme
regexp-map
Curried function which takes a map of
RegExp
string keys which when successfully matched given string, resolves to mapped value.
npm install regexp-map --save
You can also use Duo, Bower or download the files manually.
npm stats
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 ofRegExp
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