Comparing version 0.0.4 to 0.0.5
@@ -69,3 +69,2 @@ { | ||
"+", | ||
"-", | ||
"/", | ||
@@ -72,0 +71,0 @@ "*", |
34
index.js
@@ -48,18 +48,34 @@ /* jshint -W084, -W093 */ | ||
function Retext(parser) { | ||
var self = this; | ||
var self = this, | ||
cache = require.cache, | ||
attribute; | ||
if (!parser) { | ||
parser = 'parse-english'; | ||
/* istanbul ignore if: Not all `require` providers support dynamic | ||
* loading, needed for the next step, thus we skip the next | ||
* branch early. */ | ||
if (require.client || require.component) { | ||
parser = require('parse-english'); | ||
} else { | ||
parser = 'parse-english'; | ||
} | ||
} | ||
if (typeof parser === 'string') { | ||
var cache = require.cache, attribute; | ||
/* istanbul ignore if: Node always has a `cache`. Other `require` | ||
* vendors however don't support this feature. */ | ||
if (!cache) { | ||
throw new TypeError( | ||
'Illegal invocation: \'Retext\' in this environment ' + | ||
'can\'t require from scratch' | ||
); | ||
} else { | ||
for (attribute in cache) { | ||
if (attribute.indexOf('/' + parser + '/') !== -1) { | ||
delete cache[attribute]; | ||
} | ||
} | ||
for (attribute in cache) { | ||
if (attribute.indexOf('/' + parser + '/') !== -1) { | ||
delete cache[attribute]; | ||
} | ||
parser = require(parser); | ||
} | ||
parser = require(parser); | ||
} | ||
@@ -66,0 +82,0 @@ |
{ | ||
"name": "retext", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "Extensible system for analysing and manipulating natural language", | ||
@@ -17,3 +17,3 @@ "keywords": [ | ||
"dependencies": { | ||
"parse-english": "~0.0.9" | ||
"parse-english": "~0.0.12" | ||
}, | ||
@@ -20,0 +20,0 @@ "devDependencies": { |
@@ -37,13 +37,16 @@ | ||
it('should create a new context/parser/textom when required, thus ' + | ||
'not requiring from memory', function () { | ||
var rootNode1 = new Retext().parse(), | ||
rootNode2 = new Retext().parse(); | ||
/* istanbul ignore else: Node always has a `cache` property */ | ||
if (require.cache) { | ||
it('should create a new context/parser/textom when required, thus ' + | ||
'not requiring from memory', function () { | ||
var rootNode1 = new Retext().parse(), | ||
rootNode2 = new Retext().parse(); | ||
assert(rootNode1 instanceof rootNode1.constructor); | ||
assert(!(rootNode1 instanceof rootNode2.constructor)); | ||
assert(rootNode2 instanceof rootNode2.constructor); | ||
assert(!(rootNode2 instanceof rootNode1.constructor)); | ||
} | ||
); | ||
assert(rootNode1 instanceof rootNode1.constructor); | ||
assert(!(rootNode1 instanceof rootNode2.constructor)); | ||
assert(rootNode2 instanceof rootNode2.constructor); | ||
assert(!(rootNode2 instanceof rootNode1.constructor)); | ||
} | ||
); | ||
} | ||
@@ -50,0 +53,0 @@ it('should set the `plugins` attribute to an empty array', function () { |
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
21115
9
484
Updatedparse-english@~0.0.12