Comparing version 1.1.0 to 2.0.0
19
index.js
@@ -1,7 +0,10 @@ | ||
'use strict' | ||
module.exports = ccount | ||
function ccount(source, character) { | ||
var value = String(source) | ||
/** | ||
* Get the total count of `character` in `value`. | ||
* | ||
* @param {any} value Content, coerced to string | ||
* @param {string} character Single character to look for | ||
* @return {number} Number of times `character` occurred in `value`. | ||
*/ | ||
export function ccount(value, character) { | ||
var source = String(value) | ||
var count = 0 | ||
@@ -14,7 +17,7 @@ var index | ||
index = value.indexOf(character) | ||
index = source.indexOf(character) | ||
while (index !== -1) { | ||
count++ | ||
index = value.indexOf(character, index + character.length) | ||
index = source.indexOf(character, index + character.length) | ||
} | ||
@@ -21,0 +24,0 @@ |
{ | ||
"name": "ccount", | ||
"version": "1.1.0", | ||
"version": "2.0.0", | ||
"description": "Count characters", | ||
@@ -21,30 +21,30 @@ "license": "MIT", | ||
], | ||
"sideEffects": false, | ||
"type": "module", | ||
"main": "index.js", | ||
"types": "index.d.ts", | ||
"files": [ | ||
"index.d.ts", | ||
"index.js" | ||
], | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"browserify": "^17.0.0", | ||
"nyc": "^15.0.0", | ||
"@types/tape": "^4.0.0", | ||
"c8": "^7.0.0", | ||
"prettier": "^2.0.0", | ||
"remark-cli": "^9.0.0", | ||
"remark-preset-wooorm": "^8.0.0", | ||
"rimraf": "^3.0.0", | ||
"tape": "^5.0.0", | ||
"tinyify": "^3.0.0", | ||
"xo": "^0.34.0" | ||
"typescript": "^4.0.0", | ||
"xo": "^0.38.0" | ||
}, | ||
"scripts": { | ||
"prepublishOnly": "npm run build && npm run format", | ||
"prebuild": "rimraf \"*.d.ts\"", | ||
"build": "tsc", | ||
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix", | ||
"build-bundle": "browserify . -s ccount -o ccount.js", | ||
"build-mangle": "browserify . -s ccount -p tinyify -o ccount.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 format && npm run build && npm run test-coverage" | ||
"test-api": "node test.js", | ||
"test-coverage": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov node test.js", | ||
"test": "npm run build && npm run format && npm run test-coverage" | ||
}, | ||
"remarkConfig": { | ||
"plugins": [ | ||
"preset-wooorm" | ||
] | ||
}, | ||
"prettier": { | ||
@@ -60,16 +60,13 @@ "tabWidth": 2, | ||
"prettier": true, | ||
"esnext": false, | ||
"ignores": [ | ||
"ccount.js" | ||
], | ||
"rules": { | ||
"no-var": "off", | ||
"prefer-arrow-callback": "off", | ||
"unicorn/prefer-type-error": "off" | ||
} | ||
}, | ||
"nyc": { | ||
"check-coverage": true, | ||
"lines": 100, | ||
"functions": 100, | ||
"branches": 100 | ||
"remarkConfig": { | ||
"plugins": [ | ||
"preset-wooorm" | ||
] | ||
} | ||
} |
@@ -12,2 +12,5 @@ # ccount | ||
This package is ESM only: Node 12+ is needed to use it and it must be `import`ed | ||
instead of `require`d. | ||
[npm][]: | ||
@@ -22,3 +25,3 @@ | ||
```js | ||
var ccount = require('ccount') | ||
import {ccount} from 'ccount' | ||
@@ -31,2 +34,5 @@ ccount('foo(bar(baz)', '(') // => 2 | ||
This package exports the following identifiers: `ccount`. | ||
There is no default export. | ||
### `ccount(value, character)` | ||
@@ -51,5 +57,5 @@ | ||
[build-badge]: https://img.shields.io/travis/wooorm/ccount.svg | ||
[build-badge]: https://github.com/wooorm/ccount/workflows/main/badge.svg | ||
[build]: https://travis-ci.org/wooorm/ccount | ||
[build]: https://github.com/wooorm/ccount/actions | ||
@@ -56,0 +62,0 @@ [coverage-badge]: https://img.shields.io/codecov/c/github/wooorm/ccount.svg |
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
5221
5
29
75
Yes
9