Comparing version 1.1.4 to 1.2.0
@@ -41,3 +41,3 @@ /* | ||
options: { | ||
config: "eslint.json" | ||
configFile: "eslint.json" | ||
}, | ||
@@ -44,0 +44,0 @@ target: [ "index.js", "transform.js" ] |
@@ -37,9 +37,9 @@ /* | ||
module.exports = _.extend({ | ||
/* provide an additional method which is like "buildParser", | ||
/* provide an additional method which is like "generate", | ||
but gets a grammar filename instead of the grammar text */ | ||
buildParserFromFile: function (filename, options) { | ||
generateFromFile: function (filename, options) { | ||
var source = fs.readFileSync(filename, { encoding: "utf8" }); | ||
return pegjs.buildParser(source, options); | ||
return pegjs.generate(source, options); | ||
} | ||
}, pegjs); | ||
{ | ||
"name": "pegjs-otf", | ||
"version": "1.1.4", | ||
"version": "1.2.0", | ||
"description": "On-The-Fly Compilation for PEG.js", | ||
@@ -26,7 +26,7 @@ "keywords": [ "pegjs", "browserify", "transform" ], | ||
"grunt-contrib-clean": "~1.0.0", | ||
"grunt-eslint": "~18.1.0" | ||
"grunt-eslint": "~19.0.0" | ||
}, | ||
"dependencies": { | ||
"pegjs": "~0.9.0", | ||
"lodash": "~4.13.1", | ||
"pegjs": "~0.10.0", | ||
"lodash": "~4.16.2", | ||
"static-module": "~1.3.1", | ||
@@ -33,0 +33,0 @@ "through": "~2.3.8" |
@@ -49,3 +49,3 @@ | ||
var fs = require("fs"); | ||
var parser = PEG.buildParser( | ||
var parser = PEG.generate( | ||
fs.readFileSync(__dirname + "/sample.pegjs", "utf8"), | ||
@@ -61,3 +61,3 @@ { optimize: "size" } | ||
var PEG = require("pegjs-otf"); | ||
var parser = PEG.buildParserFromFile( | ||
var parser = PEG.generateFromFile( | ||
__dirname + "/sample.pegjs", | ||
@@ -88,9 +88,9 @@ { optimize: "size" } | ||
The API returned by `require("pegjs-otf")` is really just the PEG.js | ||
API with an additional injected method `buildParserFromFile(filename, | ||
options)`. And this `buildParserFromFile(filename, options)` | ||
API with an additional injected method `generateFromFile(filename, | ||
options)`. And this `generateFromFile(filename, options)` | ||
is actually *not* really some sort of an important | ||
convenience function, because it technically is just | ||
`require("pegjs").buildParser(require("fs").readFileSync(filename), | ||
`require("pegjs").generate(require("fs").readFileSync(filename), | ||
options)` and this would not warrant an extra wrapper API, of course. | ||
Instead the `pegjs-otf` module and its distinct `buildParserFromFile` | ||
Instead the `pegjs-otf` module and its distinct `generateFromFile` | ||
method is actually a *marker*. | ||
@@ -100,3 +100,3 @@ | ||
environment it really just performs its simple | ||
`require("pegjs").buildParser(require("fs").readFileSync(filename), | ||
`require("pegjs").generate(require("fs").readFileSync(filename), | ||
options)` operation. But when the application code is transpiled | ||
@@ -106,3 +106,3 @@ for a Browser environment with the help of the excellent | ||
transform can kick in and replaces the `var xx = require("pegjs-otf")` | ||
call with nothing and the `xx.buildParserFromFile(filename, options)` | ||
call with nothing and the `xx.generateFromFile(filename, options)` | ||
call with the corresponding on-the-fly compiled parser code. | ||
@@ -123,3 +123,3 @@ | ||
regular Node environments and the only way to pass options to PEG.js' | ||
`buildParser` is via external Browserify options. | ||
`generate` is via external Browserify options. | ||
@@ -130,3 +130,3 @@ The second of the two above drawbacks cannot be resolved. The first | ||
Unfortunately, this has the same drawback as `browserify-pegjs`: it also | ||
does not allow the passing of options to the underlying `buildParser` | ||
does not allow the passing of options to the underlying `generate` | ||
method. | ||
@@ -136,3 +136,3 @@ | ||
and Browserify environments and allows the passing of options to | ||
`buildParser`. | ||
`generate`. | ||
@@ -139,0 +139,0 @@ License |
var peg = require("pegjs-otf"); | ||
var parser = peg.buildParserFromFile(__dirname + "/sample.pegjs", { optimize: "size" }); | ||
var parser = peg.generateFromFile(__dirname + "/sample.pegjs", { optimize: "size" }); | ||
console.log(parser.parse("hello world") === "world" ? "OK" : "FAIL"); | ||
@@ -43,6 +43,6 @@ /* | ||
/* act on all calls to method "buildParserFromFile" of module "pegjs-otf" */ | ||
/* act on all calls to method "generateFromFile" of module "pegjs-otf" */ | ||
return sm({ | ||
"pegjs-otf": { | ||
"buildParserFromFile": function (filename, options) { | ||
"generateFromFile": function (filename, options) { | ||
/* read the grammar definition */ | ||
@@ -55,5 +55,5 @@ var source = fs.readFileSync(filename, { encoding: "utf8" }); | ||
/* generate the parser with regular PEG.js API */ | ||
var parser = pegjs.buildParser(source, options); | ||
var parser = pegjs.generate(source, options); | ||
/* replace the "buildParserFromFile(...)" call with the generated parser */ | ||
/* replace the "generateFromFile(...)" call with the generated parser */ | ||
return "(" + parser + ")"; | ||
@@ -64,3 +64,3 @@ } | ||
vars: { | ||
/* allow "__dirname" to be used in "buildParserFromFile(...)" calls */ | ||
/* allow "__dirname" to be used in "generateFromFile(...)" calls */ | ||
__dirname: path.dirname(file) | ||
@@ -67,0 +67,0 @@ } |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21086
+ Addedlodash@4.16.6(transitive)
+ Addedpegjs@0.10.0(transitive)
- Removedlodash@4.13.1(transitive)
- Removedpegjs@0.9.0(transitive)
Updatedlodash@~4.16.2
Updatedpegjs@~0.10.0