@@ -7,6 +7,7 @@ A utility function for converting command-line arguments to a key-value object.
77- [ Installation] ( #installation )
88- [ Importing] ( #importing )
99- [ Usage] ( #usage )
10+ - [ Dual Module Support] ( #dual-module-support )
1011- [ Examples] ( #examples )
1112 - [ Simple key-value pairs] ( #simple-key-value-pairs )
1213 - [ Unix-style command-line options] ( #unix-style-command-line-options )
@@ -61,34 +62,49 @@ console.log(args.name); // "John"
6162
6263```
6364
65+ ## Dual Module Support
66+
67+ This package supports both:
68+
69+ - ES Modules: ` import argv2object from 'argv2object' `
70+ - CommonJS: ` const argv2object = require('argv2object') `
71+
72+ The architecture uses separate entry points while sharing the same implementation.
73+
74+ ## System Requirements
75+
76+ - ** Node.js 14+** (Recommended for full support)
77+ - ** Node.js 12.x** (Experimental support)
78+ - ** Versiones anteriores** : Use version 1.x of this package
79+
6480## Examples
6581
6682### Simple key-value pairs
6783
6884``` sh
6985# Command line input:
70- node script.js task=some-task name=John level=admin
86+ node script.js task=some-task age=30 name=John level=admin
7187
7288```
7389
7490``` js
7591const args = argv2Object ();
7692console .log (args);
77- // Output: { name: 'John', age: '30' , level: 'admin' }
93+ // Output: { name: 'John', age: 30 , level: 'admin' }
7894```
7995
8096### Unix-style command-line options
8197
8298``` sh
8399# Command line input:
84- node --watch script.js -h --name=John --is-admin
100+ node --watch script.js -h --help -- name=John --is-admin
85101
86102```
87103
88104``` js
89105const args = argv2Object (true );
90106console .log (args);
91- // Output: { h: true, name: 'John', is_admin: true }
107+ // Output: { h: true, help: true, name: 'John', is_admin: true }
92108```
93109
94110## API
@@ -113,11 +129,12 @@ Returns an `Object` with keys and values corresponding to the provided arguments
113129
114130Throws
115131
116- | Type | Description |
117- | ---------| ---------------------------------------------------------------------------------------------|
118- | ` Error ` | If no arguments are provided from command line. |
119- | ` Error ` | If ` unixmode ` is ` true ` and an argument does not follow the Unix-style command-line format. |
120- | ` Error ` | If ` unixmode ` is ` false ` and an argument does not follow the "key=value" format. |
132+ | Type | Description |
133+ | ---------| -------------------------------------------------------------------------------------------------|
134+ | ` TypeError ` | If ` unixmode ` is not of type ` boolean ` . |
135+ | ` Error ` | If no arguments are provided from command line. |
136+ | ` Error ` | If ` unixmode ` is ` true ` and an argument does not follow the Unix-style command-line format. |
137+ | ` Error ` | If ` unixmode ` is ` false ` and an argument does not follow the "key=value" format. |
121138
122139## Contributing
123140
0 commit comments