Observed since 20 Oct, 18:14 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
140-opts
140 bytes fancy options parsing
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
Download counts and popularity will appear here as the collector receives them.
Declarations describe requirements; they are not a resolved dependency graph.
Source distribution
{
"shasum": "1cfdc81630d3dd47e9ae07ecc945a58c0d9c234d",
"tarball": "https://registry.npmjs.org/140-opts/-/140-opts-1.2.0.tgz",
"integrity": "sha512-ThmeA1WbH5wsiiFwIYDF1Uu+ceQKZixhlVTnr27F1UXdqHoz8nVSvNwp3z0AtcE7o2beKVGsH0zbRkmFIJBN7g==",
"signatures": [
{
"keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
"sig": "MEUCIQCu3K/lxbYXhEDMYc+7OQp5PpLviCDbtAyyFUee6+BbIAIgBaE9RBRGiRoj0sL8AyFNW8eF6wVlQ2Sp2uqeR2qEIjU="
}
]
}Observed since 20 Oct, 18:14 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package_version:d2f69e205671f08eee013d949cfed8be42dd3a9495a01704e34a5cff17ed3d80