regexpIn
Like Immutable.JS’ Iterable#getIn, but with RegExp
support.
Installation
Run npm install --save regexpin
to add regexpIn
to your project.
Usage
const Immutable = require('immutable')const regexpIn = require('regexpin')const map = Immutable.Map({ 'hello': { 'world': 3 } }) // regexpIn is curried, so you can partially-apply itconst messageGetter = regexpIn(['hello', /WO/i])const message = messageGetter(map)console.log(message) // Logs `3` // You can also provide both arguments at onceconst newMessage = regexpIn([/^(.*)lo$/, 'world'], map)console.log(newMessage) // Also logs `3`
Testing
regexpIn
includes several unit tests. After cloning the regexpIn
repo locally, run npm install
in the project folder to install dependencies, then npm test
to execute the tests.