Check if argv has a specific flag
<!-- hop.js - Package: has-flag Version: 5.0.1 --> <script type="text/javascript" src="https://cdn.hopjs.net/npm/has-flag@5.0.1/index.js" crossorigin="anonymous" referrerpolicy="no-referrer"> </script> <!-- End of package -->Copy the code below and paste it into your HTML file.The package version has been scanned for malware
Check if
argvhas a specific flag
$ npm install has-flag
// foo.js
import hasFlag from 'has-flag';
hasFlag('unicorn');
//=> true
hasFlag('--unicorn');
//=> true
hasFlag('f');
//=> true
hasFlag('-f');
//=> true
hasFlag('foo=bar');
//=> true
hasFlag('foo');
//=> false
hasFlag('rainbow');
//=> false
$ node foo.js -f --unicorn --foo=bar -- --rainbow
Returns a boolean for whether the flag exists.
It correctly stops looking after an -- argument terminator.
Type: string
CLI flag to look for. The -- prefix is optional.
Type: string[]
Default: process.argv
CLI arguments.
Include has-flag into your own domain?
Try bunny.net
has-flag does not depend on any external packages.
hop.js is a privacy-first CDN service powered by bunny.net, designed to offer a free, industry-leading performance with zero logging.