Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

readme: add description of ECMAScript #62

Merged
merged 1 commit into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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={})
ljharb marked this conversation as resolved.
Show resolved Hide resolved

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);
Loading