Miss any of our Open RFC calls?Watch the recordings here! »

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

0.0.5 • Public • Published

Build Status Coverage Status JavaScript Style Guide

are-substrings-over-maximum-density

Checks if substrings are over maximum densities in a string.

Related Packages

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

Node Repository

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

Installation

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

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 areSubstringsOverMaximumDensity = require('@pelevesque/are-substrings-over-maximum-density')

One Check

// over density returns true
// 'a' takes up 50% of the string, more than a 25% density
const str = 'aaaabbbb'
const checks = { a: 0.25 }
const result = areSubstringsOverMaximumDensity(str, checks)
// result === true
// equal to density returns false
const str = 'aaaabbbb'
const checks = { a: 0.5 }
const result = areSubstringsOverMaximumDensity(str, checks)
// result === false
// under density returns false
const str = 'a man, a hog, and a fly'
const checks = { hog: 0.5 }
const result = areSubstringsOverMaximumDensity(str, checks)
// result === false

Multiple Checks

// when one is over density, it returns true ('a' is over 25%)
const str = 'aaaabbbb'
const checks = { a: 0.25, b: 0.5, c: 0.3 }
const result = areSubstringsOverMaximumDensity(str, checks)
// result === true
// when all are under or equal to density, it returns false
const str = 'a man, a hog, and a fly'
const checks = { a: 0.5, hog: 0.5, c: 0.3 }
const result = areSubstringsOverMaximumDensity(str, checks)
// result === false

Install

npm i @pelevesque/are-substrings-over-maximum-density

DownloadsWeekly Downloads

1

Version

0.0.5

License

MIT

Unpacked Size

11.2 kB

Total Files

6

Last publish

Collaborators

  • avatar