0.0.1 • Published 5 years ago

@pelevesque/find-substring-indexes v0.0.1

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

Build Status Coverage Status JavaScript Style Guide

find-substring-indexes

Finds all the indexes of a substring.

Node Repository

https://www.npmjs.com/package/@pelevesque/find-substring-indexes

Installation

npm install @pelevesque/find-substring-indexes

Tests

Standard Style & Unit Tests

npm test

Unit Tests & Coverage

npm run cover

Usage

find-substring-indexes returns an array of all the indexes of the substring.

const findSubstringIndexes = require('@pelevesque/find-substring-indexes')
const str = 'a little cat and a hat'
const substring = 'a'
const result = findSubstringIndexes(str, substring)
// result === [0, 10, 13, 17, 20]
const str = 'at a cat and a brat with a hat'
const substring = 'at'
const result = findSubstringIndexes(str, substring)
// result === [0, 6, 17, 28]