Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mefengl/string-no-repeat
https://github.com/mefengl/string-no-repeat
Last synced: 8 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/mefengl/string-no-repeat
- Owner: mefengl
- License: mit
- Created: 2023-08-01T14:01:24.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-08-01T14:59:07.000Z (over 1 year ago)
- Last Synced: 2024-10-16T21:11:43.840Z (22 days ago)
- Language: JavaScript
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# string-no-repeat
## Description
A package that removes excess duplicate parts from a text string based on the count provided.## Installation
```sh
npm install string-no-repeat
```## Usage
The main function exported by this package is `removeDuplicateParts(text, duplicatesToKeep)`.
Here's a basic example:
```javascript
const { removeDuplicateParts } = require('string-no-repeat');const str = "Woo! Woo! Woo! Woo! Woo!";
const result = removeDuplicateParts(str, 2);console.log(result);
// Outputs: "Woo! Woo!"
```In this example, the function reduces the count of "Woo!" in the string to only two instances.
## Tests
To run the test suite for `string-no-repeat`, use the command:
```sh
npm test
```A test file is provided (`test.js`). Here is an example test:
```javascript
const { removeDuplicateParts } = require('./dist/index.js');const text = 'Woo! Woo! Woo! Woo! Woo! Again! Woo! Woo! Woo! Woo!';
const result = removeDuplicateParts(text, 2);
console.log(result); // Outputs: "Woo! Woo! Again! Woo! Woo!"
```