Skip to content

squelch-irc/string-args

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

string-args Build Status

Simple parser for space delimited arguments, like the arguments of an IRC command.

Installing

npm install string-args

Example usage

var parse = require('string-args');

// 1st parameter is a list of names
// 2nd parameter is the actual string of arguments
// string-args will attempt to map the names to their corresponding arguments
parse('one two three', 'uno dos tres')
parse('one two three', 'uno dos tres quatro') // extra args ignored
/* These both output:
{
    one: 'uno',
    two: 'dos',
    three: 'tres'
}
*/


// Missing arguments will be undefined
parse('one two three', 'uno dos')
/* Output:
{
    one: 'uno',
    two: 'dos'
}
*/


// Use '...' at the end of the last name to get the rest of the arguments
parse('one two three...', 'uno dos tres quatro cinco')
/* Output:
{
    one: 'uno',
    two: 'dos',
    three: 'tres quatro cinco'
}
*/

About

Simple parser for space delimited arguments.

Resources

License

Stars

Watchers

Forks

Packages

No packages published