Skip to content

Commit ca65b89

Browse files
committed
Refactor prose
1 parent f79143b commit ca65b89

File tree

1 file changed

+34
-33
lines changed

1 file changed

+34
-33
lines changed

readme.md

+34-33
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,17 @@
55
[![Downloads][downloads-badge]][downloads]
66
[![Size][size-badge]][size]
77

8-
Transform a “database” / simple (word, phrase) list from plain-text to
9-
JSON.
8+
Transform a “database” / basic (word, phrase) list from plain text to JSON.
109

11-
## Installation
10+
## Install
1211

1312
[npm][]:
1413

15-
```bash
14+
```sh
1615
npm install plain-text-data-to-json
1716
```
1817

19-
## Usage
18+
## Use
2019

2120
```js
2221
var fs = require('fs')
@@ -33,8 +32,9 @@ fs.writeFileSync('output.json', JSON.stringify(data, null, 2) + '\n')
3332

3433
### `toJSON(value[, options])`
3534

36-
Transforms the given value (string) to JSON. Don’t like the default
37-
comment and property-value pair delimiters? Specify your own:
35+
Transforms the given value (string) to JSON.
36+
Don’t like the default comment and property-value pair delimiters?
37+
Specify your own:
3838

3939
##### `options`
4040

@@ -45,34 +45,35 @@ Character to use for line-comments, `false` turns off comments (`string` or
4545

4646
###### `options.delimiter`
4747

48-
Character to use as delimiter between property-value pairs (`string`,
49-
default: `':'`)
48+
Character to use as delimiter between property-value pairs (`string`, default:
49+
`':'`)
5050

5151
###### `options.forgiving`
5252

53-
How relaxed to be (`string` or `boolean`, default: `false`). When `true`,
54-
doesn’t throw for duplicate keys. When `"fix"`, doesn’t throw for
55-
property-value pairs and overwrites (see [errors][]).
53+
How relaxed to be (`'fix'` or `boolean`, default: `false`).
54+
When `true`, doesn’t throw for duplicate keys.
55+
When `'fix'`, doesn’t throw for property-value pairs and overwrites (see
56+
[errors][]).
5657

5758
###### `options.log`
5859

5960
Whether to log when `forgiving` ignores an error (`boolean`, default: `true`).
6061

6162
## Why
6263

63-
I found myself rewriting a simple transformation over and over. This
64-
(verbosely named) project fixes that. It might not be useful, or too
65-
simple for others, but suites my use cases.
64+
I found myself rewriting a simple transformation over and over.
65+
This (verbosely named) project fixes that.
66+
It might not be useful, or too simple for others, but suites my use cases.
6667

67-
## “Plain-text”
68+
## “Plain text”
6869

69-
The term plain-text might be confusing. It’s actually more of some
70-
(sparingly specified) standard.
70+
The term plain text might be confusing.
71+
It’s actually more of some (sparingly specified) standard.
7172

7273
### Comments
7374

74-
Use a percentage sign (by default) to specify a comment. The comment
75-
will last until the end of line.
75+
Use a percentage sign (by default) to specify a comment.
76+
The comment will last until the end of line.
7677

7778
```txt
7879
% This is a completely commented line.
@@ -81,11 +82,11 @@ unicorn % This is a partially commented line.
8182

8283
Yields:
8384

84-
```json
85-
["unicorn"]
85+
```js
86+
['unicorn']
8687
```
8788

88-
### White Space
89+
### Whitespace
8990

9091
Initial or final white space (`\s`) is trimmed from values.
9192

@@ -95,14 +96,14 @@ Initial or final white space (`\s`) is trimmed from values.
9596

9697
Yields:
9798

98-
```json
99-
["unicorn"]
99+
```js
100+
['unicorn']
100101
```
101102

102103
### Empty lines
103104

104-
Empty lines will be striped. This includes blank (white space only)
105-
lines.
105+
Empty lines are striped.
106+
This includes blank (whitespace only) lines.
106107

107108
```txt
108109
%%% this file contains a value. %%%
@@ -112,8 +113,8 @@ unicorn
112113

113114
Yields:
114115

115-
```json
116-
["unicorn"]
116+
```js
117+
['unicorn']
117118
```
118119

119120
### Property-value pairs
@@ -126,8 +127,8 @@ unicorn : magic creature
126127

127128
Yields:
128129

129-
```json
130-
{"unicorn":"magic creature"}
130+
```js
131+
{unicorn: 'magic creature'}
131132
```
132133

133134
### Values
@@ -151,8 +152,8 @@ Some errors are thrown when malformed “plain-text” is found, such as:
151152
* When lines both with and without colons exist
152153
* In arrays, when duplicate values exist (unless `forgiving: true`)
153154
* In objects, when duplicate properties exist (unless `forgiving: true`)
154-
* In objects, when duplicate properties with different values exist
155-
(unless `forgiving: "fix"`)
155+
* In objects, when duplicate properties with different values exist (unless
156+
`forgiving: "fix"`)
156157

157158
## License
158159

0 commit comments

Comments
 (0)