Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
resolve-options
Advanced tools
Changelog
Readme
Resolve an options object based on configuration.
// This example assumes a Vinyl file
var createResolver = require('resolve-options');
var config = {
cwd: {
type: 'string',
default: process.cwd,
},
sourcemaps: {
type: 'boolean',
default: false,
},
since: {
type: ['date', 'number'],
},
read: {
type: 'boolean',
},
};
var options = {
sourcemaps: true,
since: Date.now(),
read: function (file) {
return file.extname !== '.mp4';
},
};
var resolver = createResolver(config, options);
var cwd = resolver.resolve('cwd', file);
// cwd === process.cwd()
var sourcemaps = resolver.resolve('sourcemaps', file);
// sourcemaps === true
var read = resolver.resolve('read', file);
// Given .mp4, read === false
// Given .txt, read === true
createResolver([config,] [options])
Takes a config
object that describes the options to accept/resolve and an options
object (usually passed by a user) to resolve against the config
. Returns a resolver
that contains a resolve
method for realtime resolution of options.
The config
object takes the following structure:
config {
[optionKey] {
type // string, array or function
default // any value or function
}
}
Each option is represented by its optionKey
in the config
object. It must be an object with a type
property.
The type
property must be a string, array or function which will be passed to the value-or-function
module (functions will be bound to the resolver to allow for dependent options).
A default
property may also be specified as a fallback if the option isn't available or is invalid. The default
value can be any value or a function (functions will be bound to the resolver to allow for dependent defaults). Note: default
values are not type-validated by the value-or-function
module.
resolver.resolve(optionKey, [...arguments])
Takes an optionKey
string and any number of arguments
to apply if an option is a function. Returns the resolved value for the optionKey
.
resolver.resolveConstant(optionKey)
Like resolve
, but only returns a value if the option is constant (not a function).
MIT
FAQs
Resolve an options object based on configuration.
The npm package resolve-options receives a total of 1,485,558 weekly downloads. As such, resolve-options popularity was classified as popular.
We found that resolve-options demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.