@pelevesque/are-substrings-over-maximum-occurrences

Checks if substrings are over maximum occurrences in a string.


Keywords
str, substring, maximum, occurrence
License
MIT
Install
npm install @pelevesque/are-substrings-over-maximum-occurrences@0.0.5

Documentation

Build Status Coverage Status JavaScript Style Guide

are-substrings-over-maximum-occurrences

Checks if substrings are over maximum occurrences in a string.

Related Packages

https://github.com/pelevesque/are-substrings-under-minimum-occurrences
https://github.com/pelevesque/are-substrings-over-maximum-density
https://github.com/pelevesque/are-substrings-under-minimum-density

Node Repository

https://www.npmjs.com/package/@pelevesque/are-substrings-over-maximum-occurrences

Installation

npm install @pelevesque/are-substrings-over-maximum-occurrences

Tests

Command Description
npm test or npm run test All Tests Below
npm run cover Standard Style
npm run standard Coverage
npm run unit Unit Tests

Usage

Requiring

const areSubstringsOverMaximumOccurrences = require('@pelevesque/are-substrings-over-maximum-occurrences')

One Check

// over occurrences returns true
// 'a' has 4 occurrences, more than the specified limit of 2
const str = 'aaaabbbb'
const checks = { a: 2 }
const result = areSubstringsOverMaximumOccurrences(str, checks)
// result === true
// equal to occurrences returns false
const str = 'aaaabbbb'
const checks = { a: 4 }
const result = areSubstringsOverMaximumOccurrences(str, checks)
// result === false
// under occurrences returns false
const str = 'a man, a hog, and another hog'
const checks = { hog: 1 }
const result = areSubstringsOverMaximumOccurrences(str, checks)
// result === false

Multiple Checks

// when one is over occurrences, it returns true ('a' is over 2)
const str = 'aaaabbbb'
const checks = { a: 2, b: 8, c: 2 }
const result = areSubstringsOverMaximumOccurrences(str, checks)
// result === true
// when all are under or equal to occurrences, it returns false
const str = 'a man, a hog, and another hog'
const checks = { a: 8, hog: 8, c: 8 }
const result = areSubstringsOverMaximumOccurrences(str, checks)
// result === false