@trenskow/parse 0.1.9 → 0.1.10

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 (3) hide show
  1. package/index.js +4 -4
  2. package/package.json +1 -1
  3. package/test.js +3 -3
package/index.js CHANGED
@@ -113,9 +113,9 @@ export default (...args) => {
113
113
 
114
114
  if (typeof boundary !== 'undefined') {
115
115
 
116
- if (maxDepth > depth) {
116
+ foundBoundaries.push(boundary);
117
117
 
118
- foundBoundaries.push(boundary);
118
+ if (maxDepth > depth) {
119
119
 
120
120
  let value;
121
121
 
@@ -132,9 +132,9 @@ export default (...args) => {
132
132
 
133
133
  } else if (typeof nextBoundary !== 'undefined' && text.substring(idx, idx + nextBoundary[1].length) === nextBoundary[1]) {
134
134
 
135
- if (ignoredDepths === 0) {
135
+ foundBoundaries.pop();
136
136
 
137
- foundBoundaries.pop();
137
+ if (ignoredDepths === 0) {
138
138
 
139
139
  if (depth > 0 && options.boundaries === 'include') {
140
140
  if (Array.isArray(result[0])) result[0] = [nextBoundary[0]].concat(result[0]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trenskow/parse",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "description": "A small library for parsing a string into a tree.",
5
5
  "main": "index.js",
6
6
  "type": "module",
package/test.js CHANGED
@@ -73,10 +73,10 @@ describe('parser', () => {
73
73
  ]);
74
74
  });
75
75
  it ('should come back with parsed tree (max depth = 1).', () => {
76
- expect(parse('[', ']', { maxDepth: 1 }).do('This [is [my nested string]].')).to.eql([
76
+ expect(parse([['${', '}'], ['$[', ']']], { boundaries: 'include', maxDepth: 1 }).do('This ${is $[a]} test')).to.eql([
77
77
  'This ',
78
- 'is [my nested string]',
79
- '.'
78
+ '${is $[a]}',
79
+ ' test'
80
80
  ]);
81
81
  });
82
82
  it ('should come back with parsed tree (max depth = 0).', () => {