Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

longest-streak

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

longest-streak - npm Package Compare versions

Comparing version 3.0.0 to 3.0.1

11

index.d.ts
/**
* Get the count of the longest repeating streak of `character` in `value`.
*
* @param {string} value Content.
* @param {string} character Single character to look for
* @returns {number} Count of most frequent adjacent `character`s in `value`
* @param {string} value
* Content to search in.
* @param {string} character
* Single character to look for.
* @returns {number}
* Count of most frequent adjacent `character`s in `value`.
*/
export function longestStreak(value: string, character: string): number;
export function longestStreak(value: string, character: string): number
/**
* Get the count of the longest repeating streak of `character` in `value`.
*
* @param {string} value Content.
* @param {string} character Single character to look for
* @returns {number} Count of most frequent adjacent `character`s in `value`
* @param {string} value
* Content to search in.
* @param {string} character
* Single character to look for.
* @returns {number}
* Count of most frequent adjacent `character`s in `value`.
*/
export function longestStreak(value, character) {
var source = String(value)
var index = source.indexOf(character)
var expected = index
var count = 0
var max = 0
const source = String(value)
let index = source.indexOf(character)
let expected = index
let count = 0
let max = 0

@@ -15,0 +18,0 @@ if (typeof character !== 'string' || character.length !== 1) {

{
"name": "longest-streak",
"version": "3.0.0",
"version": "3.0.1",
"description": "Count the longest repeating streak of a character",

@@ -36,17 +36,17 @@ "license": "MIT",

"prettier": "^2.0.0",
"remark-cli": "^9.0.0",
"remark-preset-wooorm": "^8.0.0",
"remark-cli": "^10.0.0",
"remark-preset-wooorm": "^9.0.0",
"rimraf": "^3.0.0",
"tape": "^5.0.0",
"type-coverage": "^2.0.0",
"typescript": "^4.0.0",
"xo": "^0.38.0"
"xo": "^0.45.0"
},
"scripts": {
"prepublishOnly": "npm run build",
"prepublishOnly": "npm run build && npm run format",
"build": "rimraf \"test/**/*.d.ts\" \"*.d.ts\" && tsc && type-coverage",
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
"prebuild": "rimraf \"*.d.ts\"",
"build": "tsc",
"test-api": "node test",
"test-coverage": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov node test.js",
"test": "npm run format && npm run build && npm run test-coverage"
"test-api": "node --conditions development test.js",
"test-coverage": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov npm run test-api",
"test": "npm run build && npm run format && npm run test-coverage"
},

@@ -62,7 +62,3 @@ "prettier": {

"xo": {
"prettier": true,
"rules": {
"no-var": "off",
"prefer-arrow-callback": "off"
}
"prettier": true
},

@@ -73,3 +69,9 @@ "remarkConfig": {

]
},
"typeCoverage": {
"atLeast": 100,
"detail": true,
"strict": true,
"ignoreCatch": true
}
}

@@ -8,11 +8,22 @@ # longest-streak

Count the longest repeating streak of a character.
Get the count of the longest repeating streak of `character` in `value`.
## Contents
* [Install](#install)
* [Use](#use)
* [API](#api)
* [`longestStreak(value, character)`](#longeststreakvalue-character)
* [Types](#types)
* [Compatibility](#compatibility)
* [Security](#security)
* [Related](#related)
* [Contribute](#contribute)
* [License](#license)
## Install
This package is ESM only: Node 12+ is needed to use it and it must be `import`ed
instead of `require`d.
This package is [ESM only][esm].
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
[npm][]:
```sh

@@ -22,2 +33,16 @@ npm install longest-streak

In Deno with [Skypack][]:
```js
import {longestStreak} from 'https://cdn.skypack.dev/longest-streak@3?dts'
```
In browsers with [Skypack][]:
```html
<script type="module">
import {longestStreak} from 'https://cdn.skypack.dev/longest-streak@3?min'
</script>
```
## Use

@@ -42,13 +67,39 @@

* `value` (`string`) — Content, coerced to string.
* `character` (`string`) — Single character to look for.
* `value` (`string`) — content to search in
* `character` (`string`) — single character to look for
###### Returns
`number` — Count of most frequent adjacent `character`s in `value`
`number` — count of most frequent adjacent `character`s in `value`.
###### Throws
* `Error` — when `character` is not a single character string.
* `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
* [`wooorm/ccount`](https://github.com/wooorm/ccount)
— count characters
* [`wooorm/direction`](https://github.com/wooorm/direction)
— detect directionality: left-to-right, right-to-left, or neutral
## Contribute
Yes please!
See [How to Contribute to Open Source][contribute].
## License

@@ -78,4 +129,12 @@

[skypack]: https://www.skypack.dev
[license]: license
[author]: https://wooorm.com
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
[typescript]: https://www.typescriptlang.org
[contribute]: https://opensource.guide/how-to-contribute/
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc