Can be used to look up the most specific value for a multi-part filename extension or domain name.
This module exports one function:
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.
see test/usage.mjs.
- Needs more/better tests and docs.
ISC