GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - yargs/argsert: another argument parser, [originally] for yargs

BranchesTags
Open more actions menu

Latest commit

 

History

46 Commits
46 Commits

Folders and files

NameName
Last commit message
Last commit date
src
src
 
 
.editorconfig
.editorconfig
 
 
.gitignore
.gitignore
 
 
.prettierignore
.prettierignore
 
 
.travis.yml
.travis.yml
 
 
README.md
README.md
 
 
index.test.js
index.test.js
 
 
package.json
package.json
 
 
promise.test.js
promise.test.js
 
 
renovate.json
renovate.json
 
 
yarn.lock
yarn.lock
 
 

Repository files navigation

argsert Build Status Coverage Status

an argument validator [originally] for yargs

API

import argsert from 'argsert';

let passed;

try {
  passed = argsert([configurationString], arguments);
} catch (err) {
  if (err instanceof TypeError) {
    // 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

import argsertPromise from 'argsert/promise';

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

Available Types

  • array
  • boolean
  • buffer
  • error
  • function
  • null
  • number
  • object
  • promise [that passes then/is-promise]
  • string
  • symbol
  • undefined

* wildcard:

allows for any type.

Configuration via configurationString

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 argument must be an object literal
  • the second argument can be any type, but must be provided.

Live Example

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

setting argsert's this to the configurationString

function nodeStyleCallback(err, result) {
  // ...
  argsert.apply('<error|undefined|null> [object|string]', arguments);
  // ...
}

You can also look at the example tests for other ways to invoke argsert. To learn more you can read about JS' function methods: apply, bind, and call.

About

another argument parser, [originally] for yargs

Topics

argument-parserjavascriptnodejsvalidation

Resources

Readme

Contributing

Contributing
Activity
Custom properties

Stars

6 stars

Watchers

1 watching

Forks

3 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.