commonform-regexp-annotator
Advanced tools
Comparing version 1.1.1 to 2.0.0
32
index.js
@@ -37,19 +37,19 @@ var predicate = require('commonform-predicate') | ||
return annotations | ||
.concat(rule(expressions, annotator, form, path)) | ||
.concat( | ||
form.content.reduce(function (annotations, element, index) { | ||
if (predicate.child(element)) { | ||
var childForm = element.form | ||
var childPath = path.concat(['content', index, 'form']) | ||
return annotations.concat( | ||
recurse( | ||
expressions, annotator, | ||
childForm, childPath, [] | ||
.concat(rule(expressions, annotator, form, path)) | ||
.concat( | ||
form.content.reduce(function (annotations, element, index) { | ||
if (predicate.child(element)) { | ||
var childForm = element.form | ||
var childPath = path.concat(['content', index, 'form']) | ||
return annotations.concat( | ||
recurse( | ||
expressions, annotator, | ||
childForm, childPath, [] | ||
) | ||
) | ||
) | ||
} else { | ||
return annotations | ||
} | ||
}, []) | ||
) | ||
} else { | ||
return annotations | ||
} | ||
}, []) | ||
) | ||
} |
{ | ||
"name": "commonform-regexp-annotator", | ||
"description": "create Common Form annotators from lists of regular expressions", | ||
"version": "1.1.1", | ||
"version": "2.0.0", | ||
"author": "Kyle E. Mitchell <kyle@kemitchell.com> (http://kemitchell.com)", | ||
"devDependencies": { | ||
"defence-cli": "1.x", | ||
"defence-cli": "^3.0.1", | ||
"replace-require-self": "1.x", | ||
"standard": "^8.0.0" | ||
"standard": "^12.0.1", | ||
"standard-markdown": "^5.0.1" | ||
}, | ||
@@ -21,11 +22,11 @@ "keywords": [ | ||
], | ||
"license": "Apache-2.0", | ||
"license": "BlueOak-1.0.0", | ||
"repository": "commonform/commonform-regexp-annotator", | ||
"scripts": { | ||
"test": "defence README.md | replace-require-self | node", | ||
"lint": "standard" | ||
"lint": "standard && standard-markdown" | ||
}, | ||
"dependencies": { | ||
"commonform-predicate": "^0.4.0" | ||
"commonform-predicate": "^3.0.1" | ||
} | ||
} |
@@ -0,1 +1,3 @@ | ||
# commonform-regexp-annotator | ||
The module exports a single function that takes an array of `RegExp` | ||
@@ -23,3 +25,3 @@ and a function for generating annotations and returns an annotator | ||
```javascript | ||
function message(form, path, expression, match) { | ||
function message (form, path, expression, match) { | ||
var word = match[1] | ||
@@ -29,4 +31,4 @@ return { | ||
match[1].indexOf('apple') > -1 | ||
? ('"' + word + '" is fruity') | ||
: ('"' + word + '" is archaic') | ||
? ('"' + word + '" is fruity') | ||
: ('"' + word + '" is archaic') | ||
), | ||
@@ -49,3 +51,3 @@ path: path, | ||
assert.deepEqual( | ||
assert.deepStrictEqual( | ||
annotator({ | ||
@@ -52,0 +54,0 @@ content: ['Drop them apples and the apple stem thereof!'] |
5677
4
75
4
+ Addedcommonform-predicate@3.0.1(transitive)
- Removedcommonform-predicate@0.4.4(transitive)
Updatedcommonform-predicate@^3.0.1