Skip to content

Commit d3373d5

Browse files
committed
Improve README documentation.
1 parent aa77584 commit d3373d5

File tree

1 file changed

+37
-4
lines changed

1 file changed

+37
-4
lines changed

README.md

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,55 @@
11
# Shellwords
22

3-
Shellwords provides functions to manipulate strings according to the word parsing rules of the UNIX Bourne shell. It is based on [the Ruby module of the same name](http://www.ruby-doc.org/stdlib-1.9.3/libdoc/shellwords/rdoc/Shellwords.html).
3+
Shellwords provides functions to manipulate strings according to the word parsing rules of the UNIX Bourne shell. It is based on [the Ruby module of the same name](https://docs.ruby-lang.org/en/3.1/Shellwords.html).
44

55
## Installation
66

7-
Add "shellwords" to your `package.json` file and run `npm install`.
7+
With npm:
8+
9+
```
10+
npm install shellwords
11+
```
12+
13+
With Yarn:
14+
15+
```
16+
yarn add shellwords
17+
```
18+
19+
## API
20+
21+
Shellwords exports the following functions, shown here in the TypeScript declaration file format.
22+
23+
``` typescript
24+
/**
25+
* Splits a string into an array of tokens in the same way the UNIX Bourne shell does.
26+
*
27+
* @param line A string to split.
28+
* @returns An array of the split tokens.
29+
*/
30+
export declare const split: (line?: string) => string[];
31+
32+
/**
33+
* Escapes a string so that it can be safely used in a Bourne shell command line.
34+
*
35+
* @param str A string to escape.
36+
* @returns The escaped string.
37+
*/
38+
export declare const escape: (str?: string) => string;
39+
```
840

941
## Example
1042

11-
``` javascript
12-
var shellwords = require("shellwords");
43+
``` typescript
44+
import { escape, split } from "shellwords";
1345

1446
shellwords.split("foo 'bar baz'");
1547
// ["foo", "bar baz"]
1648

1749
shellwords.escape("What's up, yo?");
1850
// 'What\\\'s\\ up,\\ yo\\?'
1951
```
52+
2053
## Legal
2154

2255
shellwords is released under the MIT license. See `LICENSE`.

0 commit comments

Comments
 (0)