Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Command line arguments parser. This one doesn't do much. But it feets in a tweet.
$ npm install 140-opts
Alternately, to just copy the file into your repo and avoid an additional package.json
dependency:
$ curl https://cdn.rawgit.com/mklabs/140-opts/master/opts.js > 140-opts.js
# or maybe
$ git clone https://github.com/mklabs/140-opts.git lib/140-opts
module.exports = function(a){return a.map(function(c,d){return{n:c.match(/^--?(.+)/),v:a[d+1]||!0}}).reduce(function(a,b){b.n&&(a[b.n[1]]=b.v);return a},{})}
in a sligtly more readable way
// 242-opts
module.exports = function (a) {
return a
.map(function (c, d) {
return {
n: c.match(/^--?(.+)/),
v: a[d+1]||!0
};
})
.reduce(function (a, b) {
b.n&&(a[b.n[1]]=b.v);
return a;
}, {})
};
var opts = require('140-opts')(process.argv.slice(2));
console.log(opts);
Takes a single argument, an array of String to parse, usually process.argv.slice(2)
.
var opts = require('140-opts');
var argv = opts(['--foo', 'foo', '--bar', 'bar', '-b', 'baz', '-o', 'woot', '--blah']);
assert.deepEqual(argv, {
foo: 'foo',
bar: 'bar',
b: 'baz',
o: 'woot',
blah: true
});
$ node test
Success!
$ --foo foo --bar bar -b baz -o woot --blah
{ foo: 'foo', bar: 'bar', b: 'baz', o: 'woot', blah: true }
\o/\o/\o/\o/\o/\o/\o/\o/\o/\o/\o/\o/\o/\o/\o/\o/\o/\o/\o/\o/
\o/\o/\o/\o/\o/\o/\o/\o/\o/\o/\o/\o/\o/\o/\o/\o/\o/\o/\o/\o/
\o/\o/\o/\o/\o/ \o/\o/\o/\o/\o/\o/\o/
\o/\o/\o/\o/\o/ \o/\o/\o/\o/\o/\o/\o/
\o/\o/\o/\o/\o/ We did it! \o/\o/\o/\o/\o/\o/\o/
\o/\o/\o/\o/\o/ \o/\o/\o/\o/\o/\o/\o/
\o/\o/\o/\o/\o/ \o/\o/\o/\o/\o/\o/\o/
\o/\o/\o/\o/\o/\o/\o/\o/\o/\o/\o/\o/\o/\o/\o/\o/\o/\o/\o/\o/
\o/\o/\o/\o/\o/\o/\o/\o/\o/\o/\o/\o/\o/\o/\o/\o/\o/\o/\o/\o/
\o/\o/\o/\o/\o/\o/\o/\o/\o/\o/\o/\o/\o/\o/\o/\o/\o/\o/\o/\o/
educational and experimental, doing 140bytes snippet of node code is kinda silly... But it's fun! And it's a good opportunity to learn some super-interesting byte saving techniques
FAQs
140 bytes fancy options parsing
The npm package 140-opts receives a total of 7 weekly downloads. As such, 140-opts popularity was classified as not popular.
We found that 140-opts 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
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.