Skip to content

Commit

Permalink
[readme] add description of ECMAScript
Browse files Browse the repository at this point in the history
 - also add examples
  • Loading branch information
unikounio authored and ljharb committed Mar 11, 2024
1 parent 6715df1 commit 1d79fd9
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
6 changes: 5 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,9 @@
"camelcase": 0,
},
},
]
{
"files": "example/**",
"extends": "@ljharb/eslint-config/node/latest",
},
],
}
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,15 @@ fanciful decoration.

# example

Example files: [example/parse.js](./example/parse.js) (CJS) / [example/parse.mjs](./example/parse.mjs) (ESM)

``` js
var argv = require('minimist')(process.argv.slice(2));
// for CJS
const argv = require('minimist')(process.argv.slice(2));

// for ESM
// import minimist from 'minimist';
// const argv = minimist(process.argv.slice(2));
console.log(argv);
```

Expand All @@ -42,10 +49,11 @@ $ node example/parse.js -x 3 -y 4 -n5 -abc --beep=boop --no-ding foo bar baz
# methods

``` js
var parseArgs = require('minimist')
const parseArgs = require('minimist');
```

## var argv = parseArgs(args, opts={})
<a name="var-argv--parseargsargs-opts"></a>
## const argv = parseArgs(args, opts={})

Return an argument object `argv` populated with the array arguments from `args`.

Expand Down
2 changes: 1 addition & 1 deletion example/parse.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'use strict';

var argv = require('../')(process.argv.slice(2));
const argv = require('minimist')(process.argv.slice(2));
console.log(argv);
4 changes: 4 additions & 0 deletions example/parse.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import minimist from 'minimist';

const argv = minimist(process.argv.slice(2));
console.log(argv);

0 comments on commit 1d79fd9

Please sign in to comment.