
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.
Create a command-line argument from a string or string (key) and value.
Install with npm
$ npm i to-flag --save
var toFlag = require('to-flag');
toFlag('abc');
//=> '--abc'
toFlag('abc', true);
//=> '--abc'
toFlag('abc', 'xyz');
//=> '--abc=xyz'
toFlag('abc', 'true');
//=> '--abc=true'
toFlag('abc', 10);
//=> '--abc=10'
casing
Keys that are camelcase or contain spaces will be dash-cased:
toFlag('fooBar');
//=> '--foo-bar'
toFlag('a b c');
//=> '--a-b-c'
toFlag('A');
//=> '--a'
var obj = {
foo: 'bar',
abc: true,
xyz: 10,
one: false
};
var args = Object.keys(obj).map(function (key) {
return toFlag(key, obj[key]);
});
//=> ['--foo=bar', '--abc', '--xyz=10', '--no-one']
When the value is false
an inverted flag is created by default:
toFlag('a', false);
//=> '--no-a'
To disable inversion, pass false
on the options:
toFlag('a', false, {invert: false});
//=> '--a'
Install dev dependencies:
$ npm i -d && npm test
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue
Jon Schlinkert
This was originally inspired by grunt.option.
Copyright © 2015 Jon Schlinkert Released under the MIT license.
This file was generated by verb-cli on August 07, 2015.
FAQs
Create a command-line argument from a string or string (key) and value.
The npm package to-flag receives a total of 0 weekly downloads. As such, to-flag popularity was classified as not popular.
We found that to-flag 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.