Skip to content

Commit 9163663

Browse files
committed
fix: use star import in the examples
Does not require esModuleInterop: true in tsconfig
1 parent 07f82f5 commit 9163663

File tree

1 file changed

+34
-34
lines changed

1 file changed

+34
-34
lines changed

README.md

+34-34
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ npm install js-java-properties
2020
Parses correctly file contents as a string into lines.
2121

2222
```ts
23-
import properties from 'js-java-properties';
23+
import * as properties from 'js-java-properties'
2424

25-
const props = properties.parse('key1=value1\nkey2 = value2\nkey3: value3');
26-
console.log(props);
25+
const props = properties.parse('key1=value1\nkey2 = value2\nkey3: value3')
26+
console.log(props)
2727
// { lines: [ 'key1=value1', 'key2 = value2', 'key3: value3' ] }
2828
```
2929

@@ -32,13 +32,13 @@ console.log(props);
3232
Formats property lines into string.
3333

3434
```ts
35-
import properties from 'js-java-properties';
35+
import * as properties from 'js-java-properties'
3636

37-
const props = properties.empty();
38-
props.lines.push('key1=value1', 'key2 = value2', 'key3: value3');
37+
const props = properties.empty()
38+
props.lines.push('key1=value1', 'key2 = value2', 'key3: value3')
3939

40-
const output = properties.stringify(props);
41-
console.log(output);
40+
const output = properties.stringify(props)
41+
console.log(output)
4242
// 'key1=value1\nkey2 = value2\nkey3: value3\n'
4343
```
4444

@@ -48,7 +48,7 @@ Iterate over every key-value pair. Note that if file contains duplicate keys,
4848
they are returned here as well.
4949

5050
```ts
51-
import properties from 'js-java-properties';
51+
import * as properties from 'js-java-properties'
5252

5353
const props = properties.empty()
5454
props.lines.push('key1=value1', 'key2 = value2', 'key3: value3')
@@ -69,27 +69,27 @@ Use `toObject` or `toMap` methods to convert it into readable object.
6969
In case there are duplicate keys, last one is returned.
7070

7171
```ts
72-
import properties from 'js-java-properties';
72+
import * as properties from 'js-java-properties'
7373

74-
const props = properties.empty();
75-
props.lines.push('key1=value1', 'key2 = value2', 'key3: value3');
74+
const props = properties.empty()
75+
props.lines.push('key1=value1', 'key2 = value2', 'key3: value3')
7676

77-
console.log(properties.get(props, 'key2'));
77+
console.log(properties.get(props, 'key2'))
7878
// 'value2'
7979
```
8080

8181
### Converting to object or map
8282

8383
```ts
84-
import properties from 'js-java-properties';
84+
import * as properties from 'js-java-properties'
8585

86-
const props = properties.empty();
87-
props.lines.push('key1=value1', 'key2 = value2', 'key3: value3');
86+
const props = properties.empty()
87+
props.lines.push('key1=value1', 'key2 = value2', 'key3: value3')
8888

89-
console.log(properties.toObject(props));
89+
console.log(properties.toObject(props))
9090
// { key1: 'value1', key2: 'value2', key3: 'value3' }
9191

92-
console.log(properties.toMap(props));
92+
console.log(properties.toMap(props))
9393
// Map(3) { 'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3' }
9494
```
9595

@@ -101,25 +101,25 @@ Empty string still counts as a value.
101101
If there are duplicate keys in the list, all but first one are removed.
102102

103103
```ts
104-
import properties from 'js-java-properties';
104+
import * as properties from 'js-java-properties'
105105

106-
const props = properties.empty();
107-
props.lines.push('key1=value1', 'key2 = value2', 'key3: value3');
106+
const props = properties.empty()
107+
props.lines.push('key1=value1', 'key2 = value2', 'key3: value3')
108108

109-
properties.set(props, 'key2', 'new-value');
110-
console.log(properties.stringify(props));
109+
properties.set(props, 'key2', 'new-value')
110+
console.log(properties.stringify(props))
111111
// 'key1=value1\nkey2 = new-value\nkey3: value3\n'
112112

113-
properties.set(props, 'new-key', 'new-value');
114-
console.log(properties.stringify(props));
113+
properties.set(props, 'new-key', 'new-value')
114+
console.log(properties.stringify(props))
115115
// 'key1=value1\nkey2 = new-value\nkey3: value3\nnew-key=new-value\n'
116116

117-
properties.set(props, 'new-key', 'new-value', {separator: ':'});
118-
console.log(properties.stringify(props));
117+
properties.set(props, 'new-key', 'new-value', {separator: ':'})
118+
console.log(properties.stringify(props))
119119
// 'key1=value1\nkey2 = new-value\nkey3: value3\nnew-key:new-value\n'
120120

121-
properties.set(props, 'key3', undefined);
122-
console.log(properties.stringify(props));
121+
properties.set(props, 'key3', undefined)
122+
console.log(properties.stringify(props))
123123
// 'key1=value1\nkey2 = new-value\n'
124124
```
125125

@@ -128,13 +128,13 @@ console.log(properties.stringify(props));
128128
Removes given key and value. If there are duplicate keys in the list, all are removed.
129129

130130
```ts
131-
import properties from 'js-java-properties';
131+
import * as properties from 'js-java-properties'
132132

133-
const props = properties.empty();
134-
props.lines.push('key1=value1', 'key2 = value2', 'key3: value3');
133+
const props = properties.empty()
134+
props.lines.push('key1=value1', 'key2 = value2', 'key3: value3')
135135

136-
properties.remove(props, 'key2');
137-
console.log(properties.stringify(props));
136+
properties.remove(props, 'key2')
137+
console.log(properties.stringify(props))
138138
// 'key1=value1\nkey3: value3\n'
139139
```
140140

0 commit comments

Comments
 (0)