longest-streak
Advanced tools
Comparing version 2.0.2 to 2.0.3
36
index.js
@@ -1,38 +0,36 @@ | ||
'use strict'; | ||
'use strict' | ||
/* Expose. */ | ||
module.exports = longestStreak; | ||
module.exports = longestStreak | ||
/* Get the count of the longest repeating streak of | ||
* `character` in `value`. */ | ||
// Get the count of the longest repeating streak of `character` in `value`. | ||
function longestStreak(value, character) { | ||
var count = 0; | ||
var maximum = 0; | ||
var expected; | ||
var index; | ||
var count = 0 | ||
var maximum = 0 | ||
var expected | ||
var index | ||
if (typeof character !== 'string' || character.length !== 1) { | ||
throw new Error('Expected character'); | ||
throw new Error('Expected character') | ||
} | ||
value = String(value); | ||
index = value.indexOf(character); | ||
expected = index; | ||
value = String(value) | ||
index = value.indexOf(character) | ||
expected = index | ||
while (index !== -1) { | ||
count++; | ||
count++ | ||
if (index === expected) { | ||
if (count > maximum) { | ||
maximum = count; | ||
maximum = count | ||
} | ||
} else { | ||
count = 1; | ||
count = 1 | ||
} | ||
expected = index + 1; | ||
index = value.indexOf(character, expected); | ||
expected = index + 1 | ||
index = value.indexOf(character, expected) | ||
} | ||
return maximum; | ||
return maximum | ||
} |
{ | ||
"name": "longest-streak", | ||
"version": "2.0.2", | ||
"version": "2.0.3", | ||
"description": "Count the longest repeating streak of a character", | ||
@@ -16,5 +16,5 @@ "license": "MIT", | ||
"bugs": "https://github.com/wooorm/longest-streak/issues", | ||
"author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)", | ||
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)", | ||
"contributors": [ | ||
"Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)" | ||
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)" | ||
], | ||
@@ -26,19 +26,19 @@ "files": [ | ||
"devDependencies": { | ||
"browserify": "^14.0.0", | ||
"esmangle": "^1.0.0", | ||
"nyc": "^11.0.0", | ||
"remark-cli": "^4.0.0", | ||
"remark-preset-wooorm": "^3.0.0", | ||
"browserify": "^16.0.0", | ||
"nyc": "^14.0.0", | ||
"prettier": "^1.12.1", | ||
"remark-cli": "^6.0.0", | ||
"remark-preset-wooorm": "^4.0.0", | ||
"tape": "^4.6.2", | ||
"xo": "^0.18.0" | ||
"tinyify": "^2.5.0", | ||
"xo": "^0.24.0" | ||
}, | ||
"scripts": { | ||
"build-md": "remark . -qfo", | ||
"build-bundle": "browserify index.js --bare -s longestStreak > longest-streak.js", | ||
"build-mangle": "esmangle longest-streak.js > longest-streak.min.js", | ||
"build": "npm run build-md && npm run build-bundle && npm run build-mangle", | ||
"lint": "xo", | ||
"format": "remark . -qfo && prettier --write \"**/*.js\" && xo --fix", | ||
"build-bundle": "browserify . -s longestStreak -o longest-streak.js", | ||
"build-mangle": "browserify . -s longestStreak -p tinyify -o longest-streak.min.js", | ||
"build": "npm run build-bundle && npm run build-mangle", | ||
"test-api": "node test", | ||
"test-coverage": "nyc --reporter lcov tape test.js", | ||
"test": "npm run build && npm run lint && npm run test-coverage" | ||
"test": "npm run format && npm run build && npm run test-coverage" | ||
}, | ||
@@ -51,4 +51,12 @@ "nyc": { | ||
}, | ||
"prettier": { | ||
"tabWidth": 2, | ||
"useTabs": false, | ||
"singleQuote": true, | ||
"bracketSpacing": false, | ||
"semi": false, | ||
"trailingComma": "none" | ||
}, | ||
"xo": { | ||
"space": true, | ||
"prettier": true, | ||
"esnext": false, | ||
@@ -55,0 +63,0 @@ "ignores": [ |
@@ -1,3 +0,8 @@ | ||
# longest-streak [![Build Status][travis-badge]][travis] [![Coverage Status][codecov-badge]][codecov] | ||
# longest-streak | ||
[![Build][build-badge]][build] | ||
[![Coverage][coverage-badge]][coverage] | ||
[![Downloads][downloads-badge]][downloads] | ||
[![Size][size-badge]][size] | ||
Count the longest repeating streak of a character. | ||
@@ -16,5 +21,5 @@ | ||
```js | ||
var longestStreak = require('longest-streak'); | ||
var longestStreak = require('longest-streak') | ||
longestStreak('` foo `` bar `', '`') //=> 2 | ||
longestStreak('` foo `` bar `', '`') // => 2 | ||
``` | ||
@@ -48,14 +53,22 @@ | ||
[travis-badge]: https://img.shields.io/travis/wooorm/longest-streak.svg | ||
[build-badge]: https://img.shields.io/travis/wooorm/longest-streak.svg | ||
[travis]: https://travis-ci.org/wooorm/longest-streak | ||
[build]: https://travis-ci.org/wooorm/longest-streak | ||
[codecov-badge]: https://img.shields.io/codecov/c/github/wooorm/longest-streak.svg | ||
[coverage-badge]: https://img.shields.io/codecov/c/github/wooorm/longest-streak.svg | ||
[codecov]: https://codecov.io/github/wooorm/longest-streak | ||
[coverage]: https://codecov.io/github/wooorm/longest-streak | ||
[downloads-badge]: https://img.shields.io/npm/dm/longest-streak.svg | ||
[downloads]: https://www.npmjs.com/package/longest-streak | ||
[size-badge]: https://img.shields.io/bundlephobia/minzip/longest-streak.svg | ||
[size]: https://bundlephobia.com/result?p=longest-streak | ||
[npm]: https://docs.npmjs.com/cli/install | ||
[license]: LICENSE | ||
[license]: license | ||
[author]: http://wooorm.com | ||
[author]: https://wooorm.com |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5075
73
8
28