
Security News
ESLint Adds Official Support for Linting HTML
ESLint now supports HTML linting with 48 new rules, expanding its language plugin system to cover more of the modern web development stack.
level-option-wrap
Advanced tools
wrap opts.{{g,l}{t,e,te},start,end}
arguments with functions
With this package you can expose familiar db.createReadStream()
options like
from leveldb but without leaking information about your internal key
representations.
For example, suppose you have a list of users using a bytewise keyEncoding and
you want to let api consumers constrain the output. If you pass through
opts.gt
/opts.lt
arguments directly, you must communicate to api consumers
the internal structure of your keys, which breaks encapsulation.
However, implementing opts.{{g,l}{t,e,te},start,end}
yourself inside your library
or application code is madness! This library lets you do that:
var wrap = require('level-option-wrap');
var minimist = require('minimist');
var defined = require('defined');
var argv = minimist(process.argv.slice(2));
var opts = wrap(argv, {
gt: function (x) { return [ 'user', defined(x, null) ] },
lt: function (x) { return [ 'user', defined(x, undefined) ] }
});
console.log(opts);
Now to get all users >= 'mafintosh'
and < 'maxogden'
we can just do:
$ node example/prefix.js --gte mafintosh --lt maxogden
{ gte: [ 'user', 'mafintosh' ], lt: [ 'user', 'maxogden' ] }
This works even though we only specified gt
and lt
as our prefix functions,
because narrower ranges take precedence.
var wrap = require('level-option-wrap')
Generate newOpts
given some leveldb createReadStream-style options opts
and
an object fns
mapping key contraints {g,l}{t,e,te}
to functions. Each
function gets the relevant constraint (whether exclusive or not) and should
return the new key bound. Exclusivity for each key is determined by the
corresponding opts
key.
opts.limit
values will be passed through and can be modified by defining an
fns.limit(n)
function.
With npm do:
npm install level-option-wrap
MIT
FAQs
wrap `opts.{{g,l}{t,e,te},start,end}` arguments with functions
The npm package level-option-wrap receives a total of 80,226 weekly downloads. As such, level-option-wrap popularity was classified as popular.
We found that level-option-wrap demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint now supports HTML linting with 48 new rules, expanding its language plugin system to cover more of the modern web development stack.
Security News
CISA is discontinuing official RSS support for KEV and cybersecurity alerts, shifting updates to email and social media, disrupting automation workflows.
Security News
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.