Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

commonform-regexp-annotator

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

commonform-regexp-annotator - npm Package Compare versions

Comparing version 1.0.3 to 1.1.0

14

index.js

@@ -11,6 +11,12 @@ var predicate = require('commonform-predicate')

.forEach(function(expression) {
var match = expression.exec(element)
if (match !== null) {
annotations.push(
annotator(form, elementPath, expression, match)) } }) }
var match
if (expression.global) {
while ((match = expression.exec(element)) !== null) {
annotations.push(
annotator(form, elementPath, expression, match)) } }
else {
match = expression.exec(element)
if (match !== null) {
annotations.push(
annotator(form, elementPath, expression, match)) } } }) }
return annotations },

@@ -17,0 +23,0 @@ [ ]) }

{
"name": "commonform-regexp-annotator",
"description": "create Common Form annotators from lists of regular expressions",
"version": "1.0.3",
"version": "1.1.0",
"author": "Kyle E. Mitchell <kyle@kemitchell.com> (http://kemitchell.com)",

@@ -6,0 +6,0 @@ "devDependencies": {

@@ -7,3 +7,3 @@ The module exports a single function that takes an array of `RegExp` and a function for generating annotations and returns an annotator function to apply to Common Forms.

var expressions = [
new RegExp('\\b(apple)\\b', 'i'),
new RegExp('\\b(apple(s?))\\b', 'gi'),
/\b(thereof)\b/ ]

@@ -19,3 +19,3 @@ ```

message: (
match[1] === 'apple' ?
( match[1].indexOf('apple') > -1 ) ?
( '"' + word + '" is fruity' ) :

@@ -38,7 +38,11 @@ ( '"' + word + '" is archaic' ) ),

assert.deepEqual(
annotator({ content: [ 'Drop that apple and the stem thereof!' ] }),
[ { message: '"apple" is fruity',
annotator({ content: [ 'Drop them apples and the apple stem thereof!' ] }),
[ { message: '"apples" is fruity',
path: [ 'content', 0 ],
source: 'example-annotator',
url: null },
{ message: '"apple" is fruity',
path: [ 'content', 0 ],
source: 'example-annotator',
url: null },
{ message: '"thereof" is archaic',

@@ -45,0 +49,0 @@ path: [ 'content', 0 ],

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc