Comparing version 1.0.0 to 1.0.1
@@ -1,9 +0,11 @@ | ||
--- | ||
mdast: | ||
setext: true | ||
--- | ||
<!--remark setext--> | ||
<!--lint disable no-multiple-toplevel-headings --> | ||
<!--lint disable no-multiple-toplevel-headings--> | ||
1.0.1 / 2016-07-23 | ||
================== | ||
* Rewrite module ([`c3cd494`](https://github.com/wooorm/ccount/commit/c3cd494)) | ||
1.0.0 / 2015-07-12 | ||
================== |
39
index.js
/** | ||
* @author Titus Wormer | ||
* @copyright 2015 Titus Wormer. All rights reserved. | ||
* @copyright 2015 Titus Wormer | ||
* @license MIT | ||
* @module ccount | ||
@@ -10,2 +11,5 @@ * @fileoverview Count characters. | ||
/* Expose. */ | ||
module.exports = ccount; | ||
/** | ||
@@ -26,26 +30,19 @@ * Count how many characters `character` occur in `value`. | ||
function ccount(value, character) { | ||
var index = -1; | ||
var count = 0; | ||
var length; | ||
var count = 0; | ||
var index; | ||
value = String(value); | ||
length = value.length; | ||
value = String(value); | ||
if (typeof character !== 'string' || character.length !== 1) { | ||
throw new Error('Expected character'); | ||
} | ||
if (typeof character !== 'string' || character.length !== 1) { | ||
throw new Error('Expected character'); | ||
} | ||
while (++index < length) { | ||
if (value.charAt(index) === character) { | ||
count++; | ||
} | ||
} | ||
index = value.indexOf(character); | ||
return count; | ||
while (index !== -1) { | ||
count++; | ||
index = value.indexOf(character, index + 1); | ||
} | ||
return count; | ||
} | ||
/* | ||
* Expose. | ||
*/ | ||
module.exports = ccount; |
{ | ||
"name": "ccount", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Count characters", | ||
@@ -12,38 +12,52 @@ "license": "MIT", | ||
"files": [ | ||
"index.js", | ||
"LICENSE" | ||
"index.js" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/wooorm/ccount.git" | ||
}, | ||
"author": "Titus Wormer <tituswormer@gmail.com>", | ||
"repository": "https://github.com/wooorm/ccount", | ||
"bugs": "https://github.com/wooorm/ccount/issues", | ||
"author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)", | ||
"contributors": [ | ||
"Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)" | ||
], | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"browserify": "^10.0.0", | ||
"eslint": "^0.24.0", | ||
"esmangle": "^1.0.0", | ||
"istanbul": "^0.3.0", | ||
"jscs": "^1.0.0", | ||
"jscs-jsdoc": "^1.0.0", | ||
"mdast": "^0.26.0", | ||
"mdast-github": "^0.3.1", | ||
"mdast-lint": "^0.4.1", | ||
"mdast-yaml-config": "^0.2.0", | ||
"mocha": "^2.0.0" | ||
"browserify": "^13.0.1", | ||
"esmangle": "^1.0.1", | ||
"nyc": "^7.0.0", | ||
"remark-cli": "^1.0.0", | ||
"remark-comment-config": "^4.0.0", | ||
"remark-github": "^5.0.0", | ||
"remark-lint": "^4.0.0", | ||
"remark-validate-links": "^4.0.0", | ||
"tape": "^4.0.0", | ||
"xo": "^0.16.0" | ||
}, | ||
"scripts": { | ||
"test-api": "mocha --check-leaks test.js", | ||
"test-coveralls": "istanbul cover _mocha --report lcovonly -- --check-leaks test.js", | ||
"test-coverage": "istanbul cover _mocha -- --check-leaks test.js", | ||
"test-travis": "npm run test-coveralls", | ||
"test": "npm run test-api", | ||
"lint-api": "eslint .", | ||
"lint-style": "jscs --reporter inline .", | ||
"lint": "npm run lint-api && npm run lint-style", | ||
"make": "npm run lint && npm run test-coverage", | ||
"build-md": "mdast . LICENSE --output --quiet", | ||
"build-md": "remark . --quiet --frail", | ||
"build-bundle": "browserify index.js --bare -s ccount > ccount.js", | ||
"postbuild-bundle": "esmangle ccount.js > ccount.min.js", | ||
"build": "npm run build-md && npm run build-bundle" | ||
"build-mangle": "esmangle ccount.js > ccount.min.js", | ||
"build": "npm run build-md && npm run build-bundle && npm run build-mangle", | ||
"lint": "xo", | ||
"test-api": "node test", | ||
"test-coverage": "nyc --reporter lcov tape test.js", | ||
"test": "npm run build && npm run lint && npm run test-coverage" | ||
}, | ||
"xo": { | ||
"space": true, | ||
"ignores": [ | ||
"ccount.js", | ||
"ccount.min.js" | ||
] | ||
}, | ||
"remarkConfig": { | ||
"output": true, | ||
"plugins": [ | ||
"comment-config", | ||
"github", | ||
"lint", | ||
"validate-links" | ||
], | ||
"settings": { | ||
"bullet": "*" | ||
} | ||
} | ||
} |
@@ -1,3 +0,5 @@ | ||
# ccount [![Build Status](https://img.shields.io/travis/wooorm/ccount.svg?style=flat)](https://travis-ci.org/wooorm/ccount) [![Coverage Status](https://img.shields.io/coveralls/wooorm/ccount.svg?style=flat)](https://coveralls.io/r/wooorm/ccount?branch=master) | ||
# ccount [![Build Status][travis-badge]][travis] [![Coverage Status][codecov-badge]][codecov] | ||
<!--lint disable heading-increment list-item-spacing--> | ||
Count characters. | ||
@@ -7,3 +9,3 @@ | ||
[npm](https://docs.npmjs.com/cli/install): | ||
[npm][npm-install]: | ||
@@ -14,7 +16,2 @@ ```bash | ||
**ccount** is also available for [bower](http://bower.io/#install-packages), | ||
[component](https://github.com/componentjs/component), [duo](http://duojs.org/#getting-started), | ||
and for AMD, CommonJS, and globals ([uncompressed](ccount.js) and | ||
[compressed](ccount.min.js)). | ||
## Usage | ||
@@ -31,7 +28,7 @@ | ||
### ccount(value, character) | ||
### `ccount(value, character)` | ||
Get the total count of `character` in `value`. | ||
Parameters: | ||
###### Parameters | ||
@@ -41,10 +38,24 @@ * `value` (`string`) — Content, coerced to string. | ||
Returns: `number` — Number of times `character` occurred in `value`. | ||
###### Returns | ||
Throws: | ||
`number` — Number of times `character` occurred in `value`. | ||
* `Error` — when `character` is not a single character string. | ||
## License | ||
[MIT](LICENSE) @ [Titus Wormer](http://wooorm.com) | ||
[MIT][license] © [Titus Wormer][author] | ||
<!-- Definitions --> | ||
[travis-badge]: https://img.shields.io/travis/wooorm/ccount.svg | ||
[travis]: https://travis-ci.org/wooorm/ccount | ||
[codecov-badge]: https://img.shields.io/codecov/c/github/wooorm/ccount.svg | ||
[codecov]: https://codecov.io/github/wooorm/ccount | ||
[npm-install]: https://docs.npmjs.com/cli/install | ||
[license]: LICENSE | ||
[author]: http://wooorm.com |
Sorry, the diff of this file is not supported yet
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
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
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
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
4874
10
58
38
1