Prefix Matches
Find matching keys in a given object, for a given prefix string
Warning: experimental
Installation
npm i --save prefix-matches
then, in your scripts:
const prefixMatches = require('prefix-matches')
Example
const prefixMatches = require('prefix-matches')
prefixMatches('w', {
watch: 'watch things',
build: 'build things'
})
prefixMatches('w', {
watch: {
js: 'watch javascript',
css: 'watch css'
},
build: 'build things'
})
prefixMatches('w.j', {
watch: {
js: 'watch javascript',
css: 'watch css'
},
write: {
js: 'write javascript'
}
})
prefixMatches('b.f.j', {
build: {
frontend: {
js: 'build javascript',
css: 'build css'
}
}
})
Why?
To attempt better prefixing support for the package-scripts project.
Tests
A basic test suite has been authored in AVA, used for its terrifying speed. To run it:
npm test