@trenskow/parse 0.1.3 → 0.1.5

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 +24 -11
  2. package/package.json +4 -4
package/README.md CHANGED
@@ -10,23 +10,18 @@ Below is an example on how to use the library.
10
10
  ````javascript
11
11
  import parse from '@trenskow/parse';
12
12
 
13
- parse('${', '}', {
14
- ignoreInside: ['"', '\'']
15
- }).do('This ${\'is\' ${my ${"nested" ${string}}}}');
13
+ parse('${', '}', { /* options */ }).do('This ${is ${my ${nested ${string}}}}');
16
14
  ````
17
15
 
18
16
  The above example will return the following structure
19
17
 
20
18
  ````JSON
21
19
  [
22
- "This ",
23
- [
24
- "is ",
25
- [
26
- "my ",
27
- [
28
- "nested ",
29
- "string"
20
+ 'This ', [
21
+ 'is ', [
22
+ 'my ', [
23
+ 'nested ',
24
+ 'string'
30
25
  ]
31
26
  ]
32
27
  ]
@@ -35,6 +30,24 @@ The above example will return the following structure
35
30
 
36
31
  > One caveat: opening and closing token cannot be the same.
37
32
 
33
+ ## Options
34
+
35
+ The following options are available.
36
+
37
+ | Name | Description | Type | Default value |
38
+ | -------------- | ------------------------------------------------------------ | ------------------------- | ------------- |
39
+ | `maxDepth` | Do not parse under a certain depth. | Number | `Infinity` |
40
+ | `ignoreInside` | A string (or array of strings) indicating characters at which to ignore parsing in between (see example [below](#ignoreInside)). | String or Array of String | `[]` |
41
+
42
+ ### `ignoreInside`
43
+
44
+ An example of ignore inside is this.
45
+
46
+ ````javascript
47
+ parse('[', ']', { ignoreInside: '"' }).do('This is ["my custom [string]"]')
48
+ // ➡ [ 'This is ', '"my custom [string]"' ]
49
+ ````
50
+
38
51
  # License
39
52
 
40
53
  See license in LICENSE.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trenskow/parse",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "A small library for parsing a string into a tree.",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -23,8 +23,8 @@
23
23
  },
24
24
  "homepage": "https://github.com/trenskow/parse#readme",
25
25
  "devDependencies": {
26
- "chai": "^4.3.6",
27
- "eslint": "^8.14.0",
28
- "mocha": "^10.0.0"
26
+ "chai": "^4.3.7",
27
+ "eslint": "^8.35.0",
28
+ "mocha": "^10.2.0"
29
29
  }
30
30
  }