@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.
- package/index.js +4 -4
- package/package.json +1 -1
- 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
|
-
|
|
116
|
+
foundBoundaries.push(boundary);
|
|
117
117
|
|
|
118
|
-
|
|
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
|
-
|
|
135
|
+
foundBoundaries.pop();
|
|
136
136
|
|
|
137
|
-
|
|
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
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
|
|
76
|
+
expect(parse([['${', '}'], ['$[', ']']], { boundaries: 'include', maxDepth: 1 }).do('This ${is $[a]} test')).to.eql([
|
|
77
77
|
'This ',
|
|
78
|
-
'is [
|
|
79
|
-
'
|
|
78
|
+
'${is $[a]}',
|
|
79
|
+
' test'
|
|
80
80
|
]);
|
|
81
81
|
});
|
|
82
82
|
it ('should come back with parsed tree (max depth = 0).', () => {
|