extract-from-argv 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +26 -5
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,11 +1,32 @@
1
1
  # extract-from-argv
2
2
 
3
- This library was generated with [Nx](https://nx.dev).
3
+ ## Usage
4
4
 
5
- ## Building
5
+ **Pass arguments to the node process and read it**
6
6
 
7
- Run `nx build extract-from-argv` to build the library.
7
+ ```node my-script.js --port=4200```
8
+ ```ts
9
+ const port = extractFromArgv('--port'); // Returns '4200'
10
+ ```
8
11
 
9
- ## Running unit tests
12
+ **Custom separator**
10
13
 
11
- Run `nx test extract-from-argv` to execute the unit tests via [Jest](https://jestjs.io).
14
+ ```node my-script.js --port:4200```
15
+ ```ts
16
+ const port = extractFromArgv('--port', { valueSeparator: ':' }); // Returns '4200'
17
+ ```
18
+ **Custom argv object**
19
+ ```ts
20
+ const port = extractFromArgv('--port', { argv: ['/usr/node', '--port=5000'] }); // Returns '5000'
21
+ ```
22
+
23
+ **Arguments without values**
24
+
25
+ ```node my-script.js --fun-mode```
26
+ ```ts
27
+ // If an argument without an value is found it returns an empty string
28
+ extractFromArgv('--fun-mode'); // Returns ''
29
+
30
+ // If a argument was not found the function returns null
31
+ extractFromArgv('--angry-mode'); // Returns null'
32
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "extract-from-argv",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "dependencies": {
5
5
  "tslib": "^2.3.0"
6
6
  },