mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-04 02:09:22 +02:00
node_modules
This commit is contained in:
parent
6fa46f4e34
commit
680eb33f0d
4375 changed files with 1042080 additions and 6 deletions
35
node_modules/argparse/examples/sum.js
generated
vendored
Normal file
35
node_modules/argparse/examples/sum.js
generated
vendored
Normal file
|
@ -0,0 +1,35 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
'use strict';
|
||||
|
||||
|
||||
var ArgumentParser = require('../lib/argparse').ArgumentParser;
|
||||
var parser = new ArgumentParser({ description: 'Process some integers.' });
|
||||
|
||||
|
||||
function sum(arr) {
|
||||
return arr.reduce(function (a, b) {
|
||||
return a + b;
|
||||
}, 0);
|
||||
}
|
||||
function max(arr) {
|
||||
return Math.max.apply(Math, arr);
|
||||
}
|
||||
|
||||
|
||||
parser.addArgument(['integers'], {
|
||||
metavar: 'N',
|
||||
type: 'int',
|
||||
nargs: '+',
|
||||
help: 'an integer for the accumulator'
|
||||
});
|
||||
parser.addArgument(['--sum'], {
|
||||
dest: 'accumulate',
|
||||
action: 'storeConst',
|
||||
constant: sum,
|
||||
defaultValue: max,
|
||||
help: 'sum the integers (default: find the max)'
|
||||
});
|
||||
|
||||
var args = parser.parseArgs('--sum 1 2 -1'.split(' '));
|
||||
console.log(args.accumulate(args.integers));
|
Loading…
Add table
Add a link
Reference in a new issue