extract-from-argv 0.0.1 → 0.1.0

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 +28 -5
  2. package/package.json +15 -2
package/README.md CHANGED
@@ -1,11 +1,34 @@
1
1
  # extract-from-argv
2
2
 
3
- This library was generated with [Nx](https://nx.dev).
3
+ Extracts arguments that were passed when the Node.js process was launched.
4
4
 
5
- ## Building
5
+ ## Usage
6
6
 
7
- Run `nx build extract-from-argv` to build the library.
7
+ **Pass arguments to the node process and read it**
8
8
 
9
- ## Running unit tests
9
+ ```node my-script.js --port=4200```
10
+ ```ts
11
+ const port = extractFromArgv('--port'); // Returns '4200'
12
+ ```
10
13
 
11
- Run `nx test extract-from-argv` to execute the unit tests via [Jest](https://jestjs.io).
14
+ **Custom separator**
15
+
16
+ ```node my-script.js --port:4200```
17
+ ```ts
18
+ const port = extractFromArgv('--port', { valueSeparator: ':' }); // Returns '4200'
19
+ ```
20
+ **Custom argv object**
21
+ ```ts
22
+ const port = extractFromArgv('--port', { argv: ['/usr/node', '--port=5000'] }); // Returns '5000'
23
+ ```
24
+
25
+ **Arguments without values**
26
+
27
+ ```node my-script.js --fun-mode```
28
+ ```ts
29
+ // If an argument without an value is found it returns an empty string
30
+ extractFromArgv('--fun-mode'); // Returns ''
31
+
32
+ // If a argument was not found the function returns null
33
+ extractFromArgv('--angry-mode'); // Returns null'
34
+ ```
package/package.json CHANGED
@@ -1,10 +1,23 @@
1
1
  {
2
2
  "name": "extract-from-argv",
3
- "version": "0.0.1",
3
+ "description": "Extracts arguments that were passed when the Node.js process was launched.",
4
+ "license": "MIT",
5
+ "version": "0.1.0",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/hansireit/angular-lib",
9
+ "directory": "libs/extract-from-argv"
10
+ },
4
11
  "dependencies": {
5
12
  "tslib": "^2.3.0"
6
13
  },
7
14
  "type": "commonjs",
8
15
  "main": "./src/index.js",
9
- "typings": "./src/index.d.ts"
16
+ "typings": "./src/index.d.ts",
17
+ "keywords": [
18
+ "node",
19
+ "argv",
20
+ "arguments",
21
+ "extract"
22
+ ]
10
23
  }