Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

another argument parser, [originally] for yargs

NotificationsYou must be signed in to change notification settings

yargs/argsert

Repository files navigation

an argument validator [originally] foryargs

API

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.}}

Promise API

importargsertPromisefrom'argsert/promise';argsertPromise([configurationString],arguments).then(passed=>passed).catch(err=>{// same error as above});

Available Types

* wildcard:

allows for any type.

Configuration viaconfigurationString

space-separated entries with the following syntax:

[optional arguments]

'[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.

<required arguments>

'<object> <*>':

  • the first argumentmust be an object literal
  • the second argument can be any type, butmust be provided.

Live Example

The following leveragesargsert best because it is the most performant and easiest to read by:

settingargsert'sthis to theconfigurationString

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

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors2

  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp