Compare commits
No commits in common. "5b723e8e5141f0feddfc75c07187c3807f3cceac" and "7e769027b1252fcdb98b17b18f72023185d9c85b" have entirely different histories.
5b723e8e51
...
7e769027b1
|
@ -57,9 +57,6 @@ const options = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Invalid input */
|
|
||||||
metamorpov.translate({}, options.firstPerson);
|
|
||||||
|
|
||||||
/* vrb, vrn */
|
/* vrb, vrn */
|
||||||
assert.equal(metamorpov.translate("vrb/be/", options.firstPerson), "was"); // I was
|
assert.equal(metamorpov.translate("vrb/be/", options.firstPerson), "was"); // I was
|
||||||
assert.equal(metamorpov.translate("vrb/be/", options.secondPerson), "were"); // You were
|
assert.equal(metamorpov.translate("vrb/be/", options.secondPerson), "were"); // You were
|
||||||
|
@ -211,3 +208,5 @@ assert.equal(metamorpov.translate("a/an pear", options.firstPerson), "a pear");
|
||||||
assert.equal(metamorpov.translate("a/an apple", options.firstPerson), "an apple"); // Starts with a vowel sound
|
assert.equal(metamorpov.translate("a/an apple", options.firstPerson), "an apple"); // Starts with a vowel sound
|
||||||
assert.equal(metamorpov.translate("a/an hour", options.firstPerson), "an hour"); // Starts with a vowel sound despite consonant letter
|
assert.equal(metamorpov.translate("a/an hour", options.firstPerson), "an hour"); // Starts with a vowel sound despite consonant letter
|
||||||
assert.equal(metamorpov.translate("a/an 1800s-era", options.firstPerson), "an 1800s-era"); // "Eighteen-hundreds" starts with a vowel sound
|
assert.equal(metamorpov.translate("a/an 1800s-era", options.firstPerson), "an 1800s-era"); // "Eighteen-hundreds" starts with a vowel sound
|
||||||
|
|
||||||
|
console.log("Test succeeded");
|
||||||
|
|
|
@ -11,7 +11,6 @@ exports.translate = function(input, options) {
|
||||||
options: options,
|
options: options,
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
if (typeof(input) == "object" && input instanceof Node) {
|
if (typeof(input) == "object" && input instanceof Node) {
|
||||||
request.loop = loopNode;
|
request.loop = loopNode;
|
||||||
}
|
}
|
||||||
|
@ -19,12 +18,7 @@ exports.translate = function(input, options) {
|
||||||
request.loop = loopString;
|
request.loop = loopString;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
console.error("Input of type " + typeof(input) + " is unsupported");
|
console.error("Invalid input type");
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch {
|
|
||||||
console.error("Translation of Node objects is unsupported outside of a browser context");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,28 +71,15 @@ function loopNode(request, params, method) {
|
||||||
child = node.firstChild;
|
child = node.firstChild;
|
||||||
while (child) {
|
while (child) {
|
||||||
next = child.nextSibling;
|
next = child.nextSibling;
|
||||||
loopNode({
|
loopNode(node, params, method);
|
||||||
input: child,
|
|
||||||
options: request.options
|
|
||||||
}, params, method);
|
|
||||||
child = next;
|
child = next;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 3: /* TEXT_NODE */
|
case 3: /* TEXT_NODE */
|
||||||
loopNodeValue({
|
loopString(node.nodeValue, params, method);
|
||||||
input: node,
|
|
||||||
options: request.options
|
|
||||||
}, params, method);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Iterator for strings belonging to HTML Node elements */
|
|
||||||
function loopNodeValue(request, params, method) {
|
|
||||||
if (request.input.nodeValue.match(params.regexp) == null) { return; }
|
|
||||||
request.input.nodeValue = method(request.input.nodeValue, params);
|
|
||||||
loopNodeValue(request, params, method);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Iterator for string elements */
|
/* Iterator for string elements */
|
||||||
function loopString(request, params, method) {
|
function loopString(request, params, method) {
|
||||||
if (request.input.match(params.regexp) == null) { return; }
|
if (request.input.match(params.regexp) == null) { return; }
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
},
|
},
|
||||||
"author": "Jean Viscogliosi-Pate",
|
"author": "Jean Viscogliosi-Pate",
|
||||||
"license": "GPL-3.0-or-later",
|
"license": "GPL-3.0-or-later",
|
||||||
"dependencies": {
|
"devDependencies": {
|
||||||
"english-verbs-gerunds": "^3.4.0",
|
"english-verbs-gerunds": "^3.4.0",
|
||||||
"english-verbs-helper": "^3.4.0",
|
"english-verbs-helper": "^3.4.0",
|
||||||
"english-verbs-irregular": "^3.4.0",
|
"english-verbs-irregular": "^3.4.0",
|
||||||
|
|
Loading…
Reference in New Issue