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.
object-to-argv
Advanced tools
Readme
Convert an object to an array of arguments to pass to a cli process
Note: object-to-argv
is only supported on iojs and node v4+. To use with
an older version of node, please use object-to-argv@1
.
$ npm install object-to-argv
$ npm test
If obj
is not an object, it is coerced to one.
opts
can contain the following keys:
equalSign
: will format like ['--name=evan']
vs ['--name', 'evan']
alwaysSingle
: will always use single dashes like ['-name', 'evan']
const convert = require('object-to-argv')
const input = {
name: 'evan'
, debug: true
, verbose: false // will be ignored since it is a bool and false
, test: {} // will be ignored since it is an object
, test: null // will be ignored since it is null
, b: true // single letters will only have a single dash
, n: 'evan'
}
console.log(convert(input))
// => [ '--name', 'evan', '--debug', '-b', '-n', 'evan' ]
// or use alwaysSingle option
const input2 = {
name: 'evan'
, debug: true
, verbose: false // will be ignored since it is a bool and false
, test: {} // will be ignored since it is an object
, test: null // will be ignored since it is null
, b: true // single letters will only have a single dash
, n: 'evan'
}
console.log(convert(input2, {
alwaysSingle: true
}))
// => [ '-name', 'evan', '-debug', '-b', '-n', 'evan' ]
// or use equalSign option
const input3 = {
name: 'evan'
, debug: true
, verbose: false // will be ignored since it is a bool and false
, test: {} // will be ignored since it is an object
, test: null // will be ignored since it is null
, b: true // single letters will only have a single dash
, n: 'evan'
}
console.log(convert(input3, {
equalSign: true
}))
// => [ '--name=evan', '--debug', '-b', '-n=evan' ]
// or use both options together
const input4 = {
name: 'evan'
, debug: true
, verbose: false // will be ignored since it is a bool and false
, test: {} // will be ignored since it is an object
, test: null // will be ignored since it is null
, b: true // single letters will only have a single dash
, n: 'evan'
}
console.log(convert(input4, {
alwaysSingle: true
, equalSign: true
}))
// => [ '-name=evan', '-debug', '-b', '-n=evan' ]
Evan Lucas
MIT (See LICENSE
for more info)
FAQs
Convert an object to an array of arguments to pass to a cli process
The npm package object-to-argv receives a total of 125 weekly downloads. As such, object-to-argv popularity was classified as not popular.
We found that object-to-argv 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
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.