New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

commonform-phrase-annotator

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

commonform-phrase-annotator

create Common Form annotators from lists of words and phrases

latest
Source
npmnpm
Version
2.0.0
Version published
Weekly downloads
8
-55.56%
Maintainers
1
Weekly downloads
 
Created
Source

commonform-phrase-annotator

The module exports a single function that takes an array of strings and a function for generating annotations, returning an annotator function to apply to Common Forms.

var phrases = ['thereof', 'whereof']

The annotation function receives the form in which a string was found, its path within the overall form, and the string that matches. It must return a Common Form Annotations.

function implementation (form, path, string) {
  return {
    message: '"' + string + '" is archaic',
    path: path,
    source: 'example-annotator',
    url: null
  }
}

var phraseAnnotator = require('commonform-phrase-annotator')

var annotator = phraseAnnotator(phrases, implementation)

The library does the job of finding matches and calculating paths.

var assert = require('assert')

assert.deepStrictEqual(
  annotator({ content: ['all rights thereof and whereof'] }),
  [
    {
      message: '"thereof" is archaic',
      path: ['content', 0],
      source: 'example-annotator',
      url: null
    },
    {
      message: '"whereof" is archaic',
      path: ['content', 0],
      source: 'example-annotator',
      url: null
    }
  ]
)

Keywords

contracts

FAQs

Package last updated on 02 Jun 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts