npm.io
1.0.0 • Published 1 month ago

commonform-suspicious

Licence
BlueOak-1.0.0
Version
1.0.0
Deps
1
Size
5 kB
Vulns
0
Weekly
0
import suspicious from 'commonform-suspicious'

The examples in this README are the package's test suite.

import assert from 'node:assert'

Deep Nesting

let deeplyNested = { content: [ 'A' ] }

for (let depth = 0; depth < 11; depth++) {
  deeplyNested = { content: [ { form: deeplyNested } ] }
}

assert(suspicious(deeplyNested))

Long Defined Terms

const term = ( 'This defined term keeps going' + ' and going'.repeat(10) )

assert(suspicious({ content: [ { definition: term } ] }))

assert(suspicious({ content: [ { use: term } ] }))

Long Headings

const heading = ( 'This heading keeps going' + ' and going'.repeat(10) )

assert(suspicious({ content: [ { reference: heading } ] }))

assert(
  suspicious({
    content: [
      {
        heading: heading,
        form: { content: [ 'A' ] }
      }
    ]
  })
)

Long Content Arrays

const longContentArray = []
for (let index = 0; index < 300; index++) {
  if (index % 2) {
    longContentArray.push('X')
  } else {
    longContentArray.push({ use: 'Y' })
  }
}

assert(suspicious({ content: longContentArray }))

Long Words

const word = ( 'gobbledy' + 'obbledy'.repeat(10) + 'gook' )

assert(suspicious({ content: [ word ] }))
assert(!suspicious({ content: [ 'gobbledygook' ] }))
assert(!suspicious({ content: [ 'gobbledy gook' ] }))