1.0.2 • Published 4 years ago
dict-lookup-key-suffix-parts-200120-pmb v1.0.2
dict-lookup-key-suffix-parts-200120-pmb
Can be used to look up the most specific value for a multi-part filename extension or domain name.
API
This module exports one function:
dictLookupKeySuffixParts(dict, parts, opts)
Returns false
if no dict
entry matches.
If a matching entry is found, returns an object with these properties:
key
andval
: The matching entry.partsUsed
: An array of theparts
that were used.nUsed
: The number of parts used.nSkip
: The number of parts skipped.
opts
is an optional options object that supports these keys (all optional):
glue
: A string to put between parts. For lookups of domains or file name extensions, you'll probably want to set this to'.'
.keyPrefix
: A string to put in front of the glued-together key parts.keySuffix
: A string to append to the glued-together key parts.
Usage
see test/usage.mjs.
Known issues
- Needs more/better tests and docs.
License
ISC
1.0.2
4 years ago
0.0.1-security
4 years ago