basic-parser
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -67,6 +67,7 @@ var _extends = Object.assign || function (target) { | ||
return function (_ref2) { | ||
var text = _ref2.text; | ||
var data = _ref2.data, | ||
text = _ref2.text; | ||
var contexts = parse({ renderers: normalizedRenderers, text: text }); | ||
return render({ contexts: contexts, text: text }); | ||
return render({ contexts: contexts, data: data, text: text }); | ||
}; | ||
@@ -131,2 +132,3 @@ }; | ||
var contexts = _ref4.contexts, | ||
data = _ref4.data, | ||
text = _ref4.text; | ||
@@ -194,2 +196,3 @@ | ||
children: contexts.slice(currentIndex + 1, nextContextIndex), | ||
data: data, | ||
startMatches: currentContext.matches, | ||
@@ -196,0 +199,0 @@ endMatches: nextContext.matches |
@@ -17,9 +17,9 @@ // @flow | ||
renderers: Array<RendererType> | ||
}) => ({ text: string }) => mixed[] | ||
}) => ({ data?: Object, text: string }) => mixed[] | ||
const parser: ParserType = ({ renderers }) => { | ||
const normalizedRenderers = normalizeRenderers({ renderers }) | ||
return ({ text }) => { | ||
return ({ data, text }) => { | ||
const contexts = parse({ renderers: normalizedRenderers, text }) | ||
return render({ contexts, text }) | ||
return render({ contexts, data, text }) | ||
} | ||
@@ -91,6 +91,7 @@ } | ||
contexts: ContextType[], | ||
data?: Object, | ||
text: string, | ||
}) => mixed[] | ||
const render: RenderType = ({ contexts, text }) => { | ||
const render: RenderType = ({ contexts, data, text }) => { | ||
@@ -160,2 +161,3 @@ const tree = [] | ||
children: contexts.slice(currentIndex + 1, nextContextIndex), | ||
data, | ||
startMatches: currentContext.matches, | ||
@@ -162,0 +164,0 @@ endMatches: nextContext.matches, |
@@ -73,6 +73,7 @@ (function (global, factory) { | ||
return function (_ref2) { | ||
var text = _ref2.text; | ||
var data = _ref2.data, | ||
text = _ref2.text; | ||
var contexts = parse({ renderers: normalizedRenderers, text: text }); | ||
return render({ contexts: contexts, text: text }); | ||
return render({ contexts: contexts, data: data, text: text }); | ||
}; | ||
@@ -137,2 +138,3 @@ }; | ||
var contexts = _ref4.contexts, | ||
data = _ref4.data, | ||
text = _ref4.text; | ||
@@ -200,2 +202,3 @@ | ||
children: contexts.slice(currentIndex + 1, nextContextIndex), | ||
data: data, | ||
startMatches: currentContext.matches, | ||
@@ -202,0 +205,0 @@ endMatches: nextContext.matches |
{ | ||
"name": "basic-parser", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "An extremely basic token-based parser", | ||
@@ -9,3 +9,4 @@ "repository": "https://github.com/amsul/basic-parser", | ||
"scripts": { | ||
"build": "rm -rf dist/ && yarn build:native && yarn build:rollup", | ||
"build": "rm -rf dist/ && yarn build:native && yarn build:rollup && yarn build:examples", | ||
"build:examples": "cp -a dist/. examples/src/dist/", | ||
"build:native": "cp -a lib/. dist/ && mv dist/index.js dist/basic-parser.native.js", | ||
@@ -12,0 +13,0 @@ "build:rollup": "rollup -c", |
22191
580