Comparing version 1.0.9 to 1.0.10
@@ -100,6 +100,7 @@ (function (f) { | ||
* @param {string} pString - The string to parse | ||
* @param {object} pData - Data to pass in as the second argument | ||
* @return {string} The result from the parser | ||
*/ | ||
parseString(pString) { | ||
return this.StringParser.parseString(pString, this.ParseTree); | ||
parseString(pString, pData) { | ||
return this.StringParser.parseString(pString, this.ParseTree, pData); | ||
} | ||
@@ -194,7 +195,7 @@ } | ||
*/ | ||
checkPatternEnd(pParserState) { | ||
checkPatternEnd(pParserState, pData) { | ||
if (pParserState.OutputBuffer.length >= pParserState.Pattern.PatternEnd.length + pParserState.Pattern.PatternStart.length && pParserState.OutputBuffer.substr(-pParserState.Pattern.PatternEnd.length) === pParserState.Pattern.PatternEnd) { | ||
// ... this is the end of a pattern, cut off the end tag and parse it. | ||
// Trim the start and end tags off the output buffer now | ||
pParserState.OutputBuffer = pParserState.Pattern.Parse(pParserState.OutputBuffer.substr(pParserState.Pattern.PatternStart.length, pParserState.OutputBuffer.length - (pParserState.Pattern.PatternStart.length + pParserState.Pattern.PatternEnd.length))); | ||
pParserState.OutputBuffer = pParserState.Pattern.Parse(pParserState.OutputBuffer.substr(pParserState.Pattern.PatternStart.length, pParserState.OutputBuffer.length - (pParserState.Pattern.PatternStart.length + pParserState.Pattern.PatternEnd.length)), pData); | ||
// Flush the output buffer. | ||
@@ -215,3 +216,3 @@ this.flushOutputBuffer(pParserState); | ||
*/ | ||
parseCharacter(pCharacter, pParserState) { | ||
parseCharacter(pCharacter, pParserState, pData) { | ||
// (1) If we aren't in a pattern match, and we aren't potentially matching, and this may be the start of a new pattern.... | ||
@@ -233,3 +234,3 @@ if (!pParserState.PatternMatch && pParserState.ParseTree.hasOwnProperty(pCharacter)) { | ||
// ... Check if this is the end of the pattern (if we are matching a valid pattern)... | ||
this.checkPatternEnd(pParserState); | ||
this.checkPatternEnd(pParserState, pData); | ||
} | ||
@@ -248,8 +249,9 @@ } | ||
* @param {Object} pParseTree - The parse tree to begin parsing from (usually root) | ||
* @param {Object} pData - The data to pass to the function as a second paramter | ||
*/ | ||
parseString(pString, pParseTree) { | ||
parseString(pString, pParseTree, pData) { | ||
let tmpParserState = this.newParserState(pParseTree); | ||
for (var i = 0; i < pString.length; i++) { | ||
// TODO: This is not fast. | ||
this.parseCharacter(pString[i], tmpParserState); | ||
this.parseCharacter(pString[i], tmpParserState, pData); | ||
} | ||
@@ -256,0 +258,0 @@ this.flushOutputBuffer(tmpParserState); |
@@ -18,3 +18,3 @@ !function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).Precedent=t()}}((function(){return function t(e,r,n){function a(s,f){if(!r[s]){if(!e[s]){var o="function"==typeof require&&require;if(!f&&o)return o(s,!0);if(u)return u(s,!0);var i=new Error("Cannot find module '"+s+"'");throw i.code="MODULE_NOT_FOUND",i}var P=r[s]={exports:{}};e[s][0].call(P.exports,(function(t){return a(e[s][1][t]||t)}),P,P.exports,t,e,r,n)}return r[s].exports}for(var u="function"==typeof require&&require,s=0;s<n.length;s++)a(n[s]);return a}({1:[function(t,e,r){ | ||
*/ | ||
var n=t("./WordTree.js"),a=t("./StringParser.js");e.exports=class{constructor(){this.WordTree=new n,this.StringParser=new a,this.ParseTree=this.WordTree.ParseTree}addPattern(t,e,r){return this.WordTree.addPattern(t,e,r)}parseString(t){return this.StringParser.parseString(t,this.ParseTree)}}},{"./StringParser.js":3,"./WordTree.js":4}],3:[function(t,e,r){e.exports= | ||
var n=t("./WordTree.js"),a=t("./StringParser.js");e.exports=class{constructor(){this.WordTree=new n,this.StringParser=new a,this.ParseTree=this.WordTree.ParseTree}addPattern(t,e,r){return this.WordTree.addPattern(t,e,r)}parseString(t,e){return this.StringParser.parseString(t,this.ParseTree,e)}}},{"./StringParser.js":3,"./WordTree.js":4}],3:[function(t,e,r){e.exports= | ||
/** | ||
@@ -29,3 +29,3 @@ * String Parser | ||
*/ | ||
class{constructor(){}newParserState(t){return{ParseTree:t,Output:"",OutputBuffer:"",Pattern:!1,PatternMatch:!1,PatternMatchOutputBuffer:""}}assignNode(t,e){e.PatternMatch=t,e.PatternMatch.hasOwnProperty("PatternEnd")&&(e.Pattern=e.PatternMatch)}appendOutputBuffer(t,e){e.OutputBuffer+=t}flushOutputBuffer(t){t.Output+=t.OutputBuffer,t.OutputBuffer=""}checkPatternEnd(t){t.OutputBuffer.length>=t.Pattern.PatternEnd.length+t.Pattern.PatternStart.length&&t.OutputBuffer.substr(-t.Pattern.PatternEnd.length)===t.Pattern.PatternEnd&&(t.OutputBuffer=t.Pattern.Parse(t.OutputBuffer.substr(t.Pattern.PatternStart.length,t.OutputBuffer.length-(t.Pattern.PatternStart.length+t.Pattern.PatternEnd.length))),this.flushOutputBuffer(t),t.Pattern=!1,t.PatternMatch=!1)}parseCharacter(t,e){!e.PatternMatch&&e.ParseTree.hasOwnProperty(t)?(this.assignNode(e.ParseTree[t],e),this.appendOutputBuffer(t,e)):e.PatternMatch?(e.PatternMatch.hasOwnProperty(t)&&this.assignNode(e.PatternMatch[t],e),this.appendOutputBuffer(t,e),e.Pattern&&this.checkPatternEnd(e)):e.Output+=t}parseString(t,e){let r=this.newParserState(e);for(var n=0;n<t.length;n++)this.parseCharacter(t[n],r);return this.flushOutputBuffer(r),r.Output}}},{}],4:[function(t,e,r){e.exports= | ||
class{constructor(){}newParserState(t){return{ParseTree:t,Output:"",OutputBuffer:"",Pattern:!1,PatternMatch:!1,PatternMatchOutputBuffer:""}}assignNode(t,e){e.PatternMatch=t,e.PatternMatch.hasOwnProperty("PatternEnd")&&(e.Pattern=e.PatternMatch)}appendOutputBuffer(t,e){e.OutputBuffer+=t}flushOutputBuffer(t){t.Output+=t.OutputBuffer,t.OutputBuffer=""}checkPatternEnd(t,e){t.OutputBuffer.length>=t.Pattern.PatternEnd.length+t.Pattern.PatternStart.length&&t.OutputBuffer.substr(-t.Pattern.PatternEnd.length)===t.Pattern.PatternEnd&&(t.OutputBuffer=t.Pattern.Parse(t.OutputBuffer.substr(t.Pattern.PatternStart.length,t.OutputBuffer.length-(t.Pattern.PatternStart.length+t.Pattern.PatternEnd.length)),e),this.flushOutputBuffer(t),t.Pattern=!1,t.PatternMatch=!1)}parseCharacter(t,e,r){!e.PatternMatch&&e.ParseTree.hasOwnProperty(t)?(this.assignNode(e.ParseTree[t],e),this.appendOutputBuffer(t,e)):e.PatternMatch?(e.PatternMatch.hasOwnProperty(t)&&this.assignNode(e.PatternMatch[t],e),this.appendOutputBuffer(t,e),e.Pattern&&this.checkPatternEnd(e,r)):e.Output+=t}parseString(t,e,r){let n=this.newParserState(e);for(var a=0;a<t.length;a++)this.parseCharacter(t[a],n,r);return this.flushOutputBuffer(n),n.Output}}},{}],4:[function(t,e,r){e.exports= | ||
/** | ||
@@ -32,0 +32,0 @@ * Word Tree |
181
gulpfile.js
'use strict'; | ||
// We aren't abstracting this yet but here's the ... "Config" | ||
const _CONFIG = ( | ||
{ | ||
// The input source file that should be passed to browserify: | ||
// (if you need to auto-instantiate an object, for instance) | ||
EntrypointInputSourceFile: `${__dirname}/source/Precedent-Browser-Shim.js`, | ||
/* | ||
After hours of reading and trying various ways of using gulp-env, environment variables | ||
and babel browesrslistrc / package.json environments it is clear that the state of using | ||
these tools is a mess. There are ways of getting it to work but none of them feel like | ||
they will work well in the long term (all of the examples seem to be in bands of about | ||
a year or two of working before the pattern changes entirely). | ||
// The name of the packaged object to be passed to browserify: | ||
// (browserify sets this to global scope and window.SOMEOBJECTNAMEHERE where SOMEOBJECTNAMEHERE is the string below) | ||
LibraryObjectName: `Precedent`, | ||
WHY did we need such a crazy compatible version? wkhtmltopdf is why. It uses a very | ||
old incompatible version of the QT browser. | ||
// The folder to write the library files and maps out to: | ||
LibraryOutputFolder: `${__dirname}/dist/`, | ||
Therefore, we will use a very old and simple method. | ||
// The name of the unminified version of the packaged library, for easy debugging: | ||
LibraryUniminifiedFileName: `precedent.js`, | ||
1) There is a config file (gulpfile-config.json), documented here, describing the inputs and outputs for the build operation. | ||
// The name of the minified version of the packaged library, for production release: | ||
LibraryMinifiedFileName: `precedent.min.js` | ||
}); | ||
const _CONFIG = ( | ||
{ | ||
// The input source file that should be passed to browserify: | ||
// (if you need to auto-instantiate an object, for instance) | ||
EntrypointInputSourceFile: `${__dirname}/source/Fable-Browser-Shim.js`, | ||
// The name of the packaged object to be passed to browserify: | ||
// (browserify sets this to global scope and window.SOMEOBJECTNAMEHERE where SOMEOBJECTNAMEHERE is the string below) | ||
LibraryObjectName: `Fable`, | ||
// The folder to write the library files and maps out to: | ||
LibraryOutputFolder: `${__dirname}/dist/`, | ||
// The name of the unminified version of the packaged library, for easy debugging: | ||
LibraryUniminifiedFileName: `fable.js`, | ||
// The name of the minified version of the packaged library, for production release: | ||
LibraryMinifiedFileName: `fable.min.js` | ||
}); | ||
2) We are using a .browserslistrc file... this is what tells gulp-babel, through the | ||
magic of the @babel/preset-env library, how to transpile the library into a compatible | ||
enough format for our targets. | ||
For example as of writing this, there are two targets we want: | ||
* Modern browsers in the last five years, expressed as a .browserslistrc with the string "since 2018" | ||
* Very old janky browsers expressed as a .browserslistrc with the string "> 0.01%" | ||
... which is interpreted as anything more than 0.01% of browsers in existence or something like that | ||
3) Because we want multiple outputs, and, the tools do fine if we want one output but some of | ||
the toolchain doesn't like making different targets well, we're just going to have multiple | ||
configurations and .browserslistrc files. So if our spec above says we need a ".browserslistrc" | ||
file and a "gulpfile-config.json", we're going to make the following two sets of configuration: | ||
* .browserslistrc_default, .gulpfile-config_default.json | ||
* .browserslistrc_compatible, .gulpfile-config_compatible.json | ||
4) We will copy, synchronously, these files to where the rest of our toolchain expects | ||
them, before we begin the build. This will be done by looking at the GULP_CUSTOM_BUILD_TARGET | ||
environment variable. This allows us to create new targets to experiment by copying a couple files, | ||
jimmying the settings and setting an environment variable before running the pipeline. | ||
5) We will run the toolchain and it will happily think it's just doing a single build and kinda work. | ||
*/ | ||
// BEGINNING OF STEP 3 and STEP 4 ABOVE | ||
const libFS = require('fs'); | ||
const _GULP_CUSTOM_BUILD_TARGET = (typeof(process.env.GULP_CUSTOM_BUILD_TARGET) == 'undefined') ? 'default' : process.env.GULP_CUSTOM_BUILD_TARGET; | ||
console.log(`--> Gulp custom build target set to: [${_GULP_CUSTOM_BUILD_TARGET}]`); | ||
const _GULP_CONFIG = `./gulpfile-config_${_GULP_CUSTOM_BUILD_TARGET}.json`; | ||
const _GULP_CONFIG_TARGET = `./gulpfile-config.json`; | ||
console.log(` : Environment set gulp config [${_GULP_CONFIG}] will be copied to [${_GULP_CONFIG_TARGET}]`); | ||
if (!libFS.existsSync(`./${_GULP_CONFIG}`)) | ||
{ | ||
console.log(`!!!> Enviromnent set gulp config doesn't exist!`); | ||
process.exit(1); | ||
} | ||
else | ||
{ | ||
libFS.copyFileSync(_GULP_CONFIG, _GULP_CONFIG_TARGET); | ||
console.log(` > Environment Gulp Config copied`); | ||
} | ||
const _BROWSERSLISTRC = `./.browserslistrc_${_GULP_CUSTOM_BUILD_TARGET}`; | ||
const _BROWSERSLISTRC_TARGET = `./.browserslistrc`; | ||
console.log(` : Environment set browserslistrc [${_BROWSERSLISTRC}] will be copied to [${_BROWSERSLISTRC_TARGET}]`); | ||
if (!libFS.existsSync(`./${_GULP_CONFIG}`)) | ||
{ | ||
console.log(`!!!> Enviromnent set browserslistrc doesn't exist!`); | ||
process.exit(1); | ||
} | ||
else | ||
{ | ||
libFS.copyFileSync(_BROWSERSLISTRC, _BROWSERSLISTRC_TARGET); | ||
console.log(` > Environment Gulp Config copied`); | ||
} | ||
console.log(`---> The browserslistrc compatibility set is: ${libFS.readFileSync(_BROWSERSLISTRC_TARGET, 'utf8')}`); | ||
// END OF STEP 3 and STEP 4 ABOVE | ||
// ---> Now load the config and get on with building <--- \\ | ||
console.log(``); | ||
console.log(`---> Loading the gulp config...`); | ||
const _CONFIG = require('./gulpfile-config.json'); | ||
console.log(` > Building to [${_CONFIG.LibraryUniminifiedFileName}] and [${_CONFIG.LibraryMinifiedFileName}]`) | ||
// ---> Boilerplate Browser Uglification and Packaging <--- \\ | ||
console.log(``); | ||
console.log(`--> Gulp is taking over!`); | ||
@@ -40,20 +121,20 @@ const libBrowserify = require('browserify'); | ||
() => { | ||
// set up the custom browserify instance for this task | ||
var tmpBrowserify = libBrowserify( | ||
{ | ||
entries: _CONFIG.EntrypointInputSourceFile, | ||
standalone: _CONFIG.LibraryObjectName, | ||
debug: true | ||
}); | ||
// set up the custom browserify instance for this task | ||
var tmpBrowserify = libBrowserify( | ||
{ | ||
entries: _CONFIG.EntrypointInputSourceFile, | ||
standalone: _CONFIG.LibraryObjectName, | ||
debug: true | ||
}); | ||
return tmpBrowserify.bundle() | ||
.pipe(libVinylSourceStream(_CONFIG.LibraryMinifiedFileName)) | ||
.pipe(libVinylBuffer()) | ||
.pipe(libSourcemaps.init({loadMaps: true})) | ||
// Add transformation tasks to the pipeline here. | ||
.pipe(libBabel()) | ||
.pipe(libTerser()) | ||
.on('error', libGulpUtil.log) | ||
.pipe(libSourcemaps.write('./')) | ||
.pipe(libGulp.dest(_CONFIG.LibraryOutputFolder)); | ||
return tmpBrowserify.bundle() | ||
.pipe(libVinylSourceStream(_CONFIG.LibraryMinifiedFileName)) | ||
.pipe(libVinylBuffer()) | ||
.pipe(libSourcemaps.init({loadMaps: true})) | ||
// Add transformation tasks to the pipeline here. | ||
.pipe(libBabel()) | ||
.pipe(libTerser()) | ||
.on('error', libGulpUtil.log) | ||
.pipe(libSourcemaps.write('./')) | ||
.pipe(libGulp.dest(_CONFIG.LibraryOutputFolder)); | ||
}); | ||
@@ -63,23 +144,23 @@ | ||
libGulp.task('debug', | ||
() => { | ||
// set up the custom browserify instance for this task | ||
var tmpBrowserify = libBrowserify( | ||
{ | ||
entries: _CONFIG.EntrypointInputSourceFile, | ||
standalone: _CONFIG.LibraryObjectName, | ||
debug: true | ||
}); | ||
() => { | ||
// set up the custom browserify instance for this task | ||
var tmpBrowserify = libBrowserify( | ||
{ | ||
entries: _CONFIG.EntrypointInputSourceFile, | ||
standalone: _CONFIG.LibraryObjectName, | ||
debug: true | ||
}); | ||
return tmpBrowserify.bundle() | ||
.pipe(libVinylSourceStream(_CONFIG.LibraryUniminifiedFileName)) | ||
.pipe(libVinylBuffer()) | ||
.pipe(libBabel()) | ||
.on('error', libGulpUtil.log) | ||
.pipe(libGulp.dest(_CONFIG.LibraryOutputFolder)); | ||
}); | ||
return tmpBrowserify.bundle() | ||
.pipe(libVinylSourceStream(_CONFIG.LibraryUniminifiedFileName)) | ||
.pipe(libVinylBuffer()) | ||
.pipe(libBabel()) | ||
.on('error', libGulpUtil.log) | ||
.pipe(libGulp.dest(_CONFIG.LibraryOutputFolder)); | ||
}); | ||
libGulp.task | ||
( | ||
'build', | ||
libGulp.series('debug', 'minified') | ||
'build', | ||
libGulp.series('debug', 'minified') | ||
); |
{ | ||
"name": "precedent", | ||
"version": "1.0.9", | ||
"version": "1.0.10", | ||
"description": "Precedent Meta-Templating", | ||
@@ -15,3 +15,4 @@ "main": "source/Precedent.js", | ||
"docker-dev-run": "docker run -it -d --name precedent-dev -p 127.0.0.1:12340:8080 -v \"$PWD/.config:/home/coder/.config\" -v \"$PWD:/home/coder/precedent\" -u \"$(id -u):$(id -g)\" -e \"DOCKER_USER=$USER\" retold/precedent:local", | ||
"build": "./node_modules/.bin/gulp build" | ||
"build": "./node_modules/.bin/gulp build", | ||
"build-compatible": "GULP_CUSTOM_BUILD_TARGET=compatible ./node_modules/.bin/gulp build" | ||
}, | ||
@@ -49,2 +50,4 @@ "repository": { | ||
"devDependencies": { | ||
"@babel/core": "^7.21.5", | ||
"@babel/preset-env": "^7.21.5", | ||
"browserify": "^17.0.0", | ||
@@ -54,2 +57,3 @@ "chai": "4.3.7", | ||
"gulp-babel": "^8.0.0", | ||
"gulp-env": "^0.4.0", | ||
"gulp-sourcemaps": "^3.0.0", | ||
@@ -56,0 +60,0 @@ "gulp-terser": "^2.1.0", |
@@ -21,3 +21,3 @@ /** | ||
this.WordTree = new libWordTree(); | ||
this.StringParser = new libStringParser(); | ||
@@ -27,3 +27,3 @@ | ||
} | ||
/** | ||
@@ -41,3 +41,3 @@ * Add a Pattern to the Parse Tree | ||
} | ||
/** | ||
@@ -47,7 +47,8 @@ * Parse a string with the existing parse tree | ||
* @param {string} pString - The string to parse | ||
* @param {object} pData - Data to pass in as the second argument | ||
* @return {string} The result from the parser | ||
*/ | ||
parseString(pString) | ||
parseString(pString, pData) | ||
{ | ||
return this.StringParser.parseString(pString, this.ParseTree); | ||
return this.StringParser.parseString(pString, this.ParseTree, pData); | ||
} | ||
@@ -54,0 +55,0 @@ } |
@@ -19,3 +19,3 @@ /** | ||
} | ||
/** | ||
@@ -43,3 +43,3 @@ * Create a fresh parsing state object to work with. | ||
} | ||
/** | ||
@@ -64,3 +64,3 @@ * Assign a node of the parser tree to be the next potential match. | ||
} | ||
/** | ||
@@ -78,3 +78,3 @@ * Append a character to the output buffer in the parser state. | ||
} | ||
/** | ||
@@ -92,3 +92,3 @@ * Flush the output buffer to the output and clear it. | ||
/** | ||
@@ -100,5 +100,5 @@ * Check if the pattern has ended. If it has, properly flush the buffer and start looking for new patterns. | ||
*/ | ||
checkPatternEnd (pParserState) | ||
checkPatternEnd (pParserState, pData) | ||
{ | ||
if ((pParserState.OutputBuffer.length >= pParserState.Pattern.PatternEnd.length+pParserState.Pattern.PatternStart.length) && | ||
if ((pParserState.OutputBuffer.length >= pParserState.Pattern.PatternEnd.length+pParserState.Pattern.PatternStart.length) && | ||
(pParserState.OutputBuffer.substr(-pParserState.Pattern.PatternEnd.length) === pParserState.Pattern.PatternEnd)) | ||
@@ -108,3 +108,3 @@ { | ||
// Trim the start and end tags off the output buffer now | ||
pParserState.OutputBuffer = pParserState.Pattern.Parse(pParserState.OutputBuffer.substr(pParserState.Pattern.PatternStart.length, pParserState.OutputBuffer.length - (pParserState.Pattern.PatternStart.length+pParserState.Pattern.PatternEnd.length))); | ||
pParserState.OutputBuffer = pParserState.Pattern.Parse(pParserState.OutputBuffer.substr(pParserState.Pattern.PatternStart.length, pParserState.OutputBuffer.length - (pParserState.Pattern.PatternStart.length+pParserState.Pattern.PatternEnd.length)), pData); | ||
// Flush the output buffer. | ||
@@ -117,3 +117,3 @@ this.flushOutputBuffer(pParserState); | ||
} | ||
/** | ||
@@ -126,3 +126,3 @@ * Parse a character in the buffer. | ||
*/ | ||
parseCharacter (pCharacter, pParserState) | ||
parseCharacter (pCharacter, pParserState, pData) | ||
{ | ||
@@ -149,3 +149,3 @@ // (1) If we aren't in a pattern match, and we aren't potentially matching, and this may be the start of a new pattern.... | ||
// ... Check if this is the end of the pattern (if we are matching a valid pattern)... | ||
this.checkPatternEnd(pParserState); | ||
this.checkPatternEnd(pParserState, pData); | ||
} | ||
@@ -159,3 +159,3 @@ } | ||
} | ||
/** | ||
@@ -166,4 +166,5 @@ * Parse a string for matches, and process any template segments that occur. | ||
* @param {Object} pParseTree - The parse tree to begin parsing from (usually root) | ||
* @param {Object} pData - The data to pass to the function as a second paramter | ||
*/ | ||
parseString (pString, pParseTree) | ||
parseString (pString, pParseTree, pData) | ||
{ | ||
@@ -175,7 +176,7 @@ let tmpParserState = this.newParserState(pParseTree); | ||
// TODO: This is not fast. | ||
this.parseCharacter(pString[i], tmpParserState); | ||
this.parseCharacter(pString[i], tmpParserState, pData); | ||
} | ||
this.flushOutputBuffer(tmpParserState); | ||
return tmpParserState.Output; | ||
@@ -182,0 +183,0 @@ } |
@@ -27,2 +27,6 @@ /** | ||
pModule.addPattern('<%=', '%>', (pData)=>{return JSON.stringify(pModule.settings);}); | ||
// Do a data thingy | ||
pModule.addPattern('<*', '*>', (pHash, pData)=>{return `pData is [${pData}] with a hash of [${pHash}]`}); | ||
// Do a data thingy | ||
pModule.addPattern('<^', '^>', (pHash, pData)=>{return `hash of [${pHash}] from pData is ${pData[pHash]}`}); | ||
// This just escapes out pairs of $ | ||
@@ -69,3 +73,3 @@ pModule.addPattern('$'); | ||
var testPrecedent = loadPrecedentModule(); | ||
Expect(Object.keys(testPrecedent.ParseTree).length).to.equal(0, 'There should be an empty tree on initialization.'); | ||
@@ -76,3 +80,3 @@ configPrecedent(testPrecedent); | ||
//console.log(JSON.stringify(testPrecedent.tree,null,4)); | ||
var tmpResult = testPrecedent.parseString(''); | ||
@@ -128,2 +132,30 @@ Expect(tmpResult.length).to.equal(0, 'Parsing Empty Strings should Work...'); | ||
( | ||
'Leveraging pData a bit...', | ||
(fDone) => | ||
{ | ||
var tmpTestString = 'The <*SomeValue*> pData up in here and a $comment$ as well.'; | ||
var tmpExpectedResult = 'The pData is [Yikes] with a hash of [SomeValue] pData up in here and a comment as well.'; | ||
var testPrecedent = loadPrecedentModule(); | ||
configPrecedent(testPrecedent); | ||
var tmpResult = testPrecedent.parseString(tmpTestString, 'Yikes'); | ||
Expect(tmpResult).to.equal(tmpExpectedResult); | ||
fDone(); | ||
} | ||
); | ||
test | ||
( | ||
'Leveraging pData a using subobjects...', | ||
(fDone) => | ||
{ | ||
var tmpTestString = 'The <^SomeValue^> pData up in here and a $comment$ as well.'; | ||
var tmpExpectedResult = 'The hash of [SomeValue] from pData is AirbornLight pData up in here and a comment as well.'; | ||
var testPrecedent = loadPrecedentModule(); | ||
configPrecedent(testPrecedent); | ||
var tmpResult = testPrecedent.parseString(tmpTestString, {SomeValue:'AirbornLight'}); | ||
Expect(tmpResult).to.equal(tmpExpectedResult); | ||
fDone(); | ||
} | ||
); | ||
test | ||
( | ||
'Bad pattern start parameter...', | ||
@@ -241,3 +273,3 @@ (fDone) => | ||
'AAA ${ ${PATH} BBB', | ||
// Two start parameters isn't okay --- | ||
// Two start parameters isn't okay --- | ||
// ...it passes the pattern processor the following (without quotes): | ||
@@ -244,0 +276,0 @@ // " ${PATH" |
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
122024
31
1502
14
3
27