longest-streak
Count the longest repeating streak of a character
Last updated 4 years ago by wooorm .
MIT · Repository · Bugs · Original npm
$ cnpm install longest-streak 
SYNC missed versions from official npm registry.

longest-streak

Build Coverage Downloads Size

Get the count of the longest repeating streak of character in value.

Contents

Install

This package is ESM only. In Node.js (version 12.20+, 14.14+, or 16.0+), install with npm:

npm install longest-streak

In Deno with Skypack:

import {longestStreak} from 'https://cdn.skypack.dev/longest-streak@3?dts'

In browsers with Skypack:

<script type="module">
  import {longestStreak} from 'https://cdn.skypack.dev/longest-streak@3?min'
</script>

Use

import {longestStreak} from 'longest-streak'

longestStreak('` foo `` bar `', '`') // => 2

API

This package exports the following identifiers: longestStreak. There is no default export.

longestStreak(value, character)

Get the count of the longest repeating streak of character in value.

Parameters
  • value (string) — content to search in
  • character (string) — single character to look for
Returns

number — count of most frequent adjacent characters in value.

Throws
  • Error — when character is not a single character string

Types

This package is fully typed with TypeScript.

Compatibility

This package is at least compatible with all maintained versions of Node.js. As of now, that is Node.js 12.20+, 14.14+, and 16.0+. It also works in Deno and modern browsers.

Security

This package is safe.

Related

Contribute

Yes please! See How to Contribute to Open Source.

License

MIT © Titus Wormer

Current Tags

  • 3.1.0                                ...           latest (3 years ago)

6 Versions

  • 3.1.0                                ...           3 years ago
  • 3.0.1                                ...           4 years ago
  • 3.0.0                                ...           4 years ago
  • 2.0.2                                ...           8 years ago
  • 1.0.0                                ...           10 years ago
  • 2.0.4                                ...           6 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (10)
Dependents (0)
None

Copyright 2013 - present © cnpmjs.org