Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including @pelevesque/are-substrings-under-minimum-occurrences with all npm packages installed. Try it out:

var areSubstringsUnderMinimumOccurrences = require("@pelevesque/are-substrings-under-minimum-occurrences")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

@pelevesque/are-substrings-under-minimum-occurrences v0.0.5

Checks if substrings are under minimum occurrences in a string.

Build Status Coverage Status JavaScript Style Guide

are-substrings-under-minimum-occurrences

Checks if substrings are under minimum occurrences in a string.

Related Packages

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

Node Repository

https://www.npmjs.com/package/@pelevesque/are-substrings-under-minimum-occurrences

Installation

npm install @pelevesque/are-substrings-under-minimum-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 areSubstringsUnderMinimumOccurrences = require('@pelevesque/are-substrings-under-minimum-occurrences')

One Check

// under occurrences returns true
// 'a' has 4 occurrences, less than 8
const str = 'aaaabbbb'
const checks = { a: 8 }
const result = areSubstringsUnderMinimumOccurrences(str, checks)
// result === true
// equal to occurrences returns false
const str = 'aaaabbbb'
const checks = { a: 4 }
const result = areSubstringsUnderMinimumOccurrences(str, checks)
// result === false
// over occurrences returns false
const str = 'a man, a hog, and another hog'
const checks = { hog: 1 }
const result = areSubstringsUnderMinimumOccurrences(str, checks)
// result === false

Multiple Checks

// when one is under occurrences, it returns true ('a' is under 8)
const str = 'aaaabbbb'
const checks = { a: 8, b: 4 }
const result = areSubstringsUnderMinimumOccurrences(str, checks)
// result === true
// when all are over or equal to occurrences, it returns false
const str = 'a man, a hog, and another hog'
const checks = { a: 1, hog: 1 }
const result = areSubstringsUnderMinimumOccurrences(str, checks)
// result === false
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free