0.0.5 • Published 4 years ago

@pelevesque/are-substrings-over-maximum-occurrences v0.0.5

Weekly downloads
5
License
MIT
Repository
github
Last release
4 years ago

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

CommandDescription
npm test or npm run testAll Tests Below
npm run coverStandard Style
npm run standardCoverage
npm run unitUnit 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