https://github.com/codetheweb/substr-occurrence
A small library that counts the number of occurrences of a substring
https://github.com/codetheweb/substr-occurrence
count small string
Last synced: 29 days ago
JSON representation
A small library that counts the number of occurrences of a substring
- Host: GitHub
- URL: https://github.com/codetheweb/substr-occurrence
- Owner: codetheweb
- License: mit
- Created: 2018-04-17T14:47:11.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-08-13T16:10:51.000Z (over 6 years ago)
- Last Synced: 2025-03-18T14:19:56.115Z (about 1 month ago)
- Topics: count, small, string
- Language: JavaScript
- Size: 7.81 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Substr Occurrence
[](https://forthebadge.com) [](https://travis-ci.org/codetheweb/substr-occurrence)A small, extremely lightweight library that counts the number of occurrences of a substring or single character in a larger string.
Created because [string-occurrence](https://github.com/SamVerschueren/string-occurrence) was too bloated and slow.## Installation
`npm install codetheweb/substr-occurrence`
## Usage
```javascript
var occurrence = require('substr-occurrence');console.log(occurrence('o', 'foo bar');
```Output should be `2`.
## Tests
`npm test`