- Notifications
You must be signed in to change notification settings - Fork3
yargs/argsert
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
an argument validator [originally] for
yargs
importargsertfrom'argsert';letpassed;try{passed=argsert([configurationString],arguments);}catch(err){if(errinstanceofTypeError){// a type was missing or incorrectly given}else{// otherwise, there was something wrong with the configuration// or the number of args passed in.}}
importargsertPromisefrom'argsert/promise';argsertPromise([configurationString],arguments).then(passed=>passed).catch(err=>{// same error as above});
arraybooleanbuffererrorfunctionnullnumberobjectpromise[that passes then/is-promise]stringsymbolundefined
allows for any type.
space-separated entries with the following syntax:
'[string|number] [object]':
- the first argument can be a string OR a number, or undefined
- the second argument can be an object literal, or undefined.
'<object> <*>':
- the first argumentmust be an object literal
- the second argument can be any type, butmust be provided.
The following leveragesargsert best because it is the most performant and easiest to read by:
functionnodeStyleCallback(err,result){// ...argsert.apply('<error|undefined|null> [object|string]',arguments);// ...}
You can also look atthe example tests for other ways to invokeargsert.To learn more you can read about JS' function methods:apply,bind, andcall.
About
another argument parser, [originally] for yargs
Topics
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
No releases published
Packages0
No packages published
Uh oh!
There was an error while loading.Please reload this page.
Contributors2
Uh oh!
There was an error while loading.Please reload this page.