Gathering detailed insights and metrics for resolve-options
Gathering detailed insights and metrics for resolve-options
Gathering detailed insights and metrics for resolve-options
Gathering detailed insights and metrics for resolve-options
npm install resolve-options
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
9 Stars
15 Commits
7 Forks
5 Watching
1 Branches
4 Contributors
Updated on 10 Dec 2023
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-5.4%
380,703
Compared to previous day
Last week
4.8%
2,065,934
Compared to previous week
Last month
19.3%
8,154,507
Compared to previous month
Last year
13.1%
87,225,481
Compared to previous year
1
6
Resolve an options object based on configuration.
1// This example assumes a Vinyl file 2 3var createResolver = require('resolve-options'); 4 5var config = { 6 cwd: { 7 type: 'string', 8 default: process.cwd, 9 }, 10 sourcemaps: { 11 type: 'boolean', 12 default: false, 13 }, 14 since: { 15 type: ['date', 'number'], 16 }, 17 read: { 18 type: 'boolean', 19 }, 20}; 21 22var options = { 23 sourcemaps: true, 24 since: Date.now(), 25 read: function (file) { 26 return file.extname !== '.mp4'; 27 }, 28}; 29 30var resolver = createResolver(config, options); 31 32var cwd = resolver.resolve('cwd', file); 33// cwd === process.cwd() 34 35var sourcemaps = resolver.resolve('sourcemaps', file); 36// sourcemaps === true 37 38var read = resolver.resolve('read', file); 39// Given .mp4, read === false 40// 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:
1config { 2 [optionKey] { 3 type // string, array or function 4 default // any value or function 5 } 6}
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
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
security policy file detected
Details
Reason
Found 4/14 approved changesets -- score normalized to 2
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More