Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jzombie/ts-lorem-ipsum-word-frequencies
https://github.com/jzombie/ts-lorem-ipsum-word-frequencies
Last synced: 2 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/jzombie/ts-lorem-ipsum-word-frequencies
- Owner: jzombie
- Created: 2021-12-01T02:41:34.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2021-12-01T14:22:13.000Z (almost 3 years ago)
- Last Synced: 2024-01-01T05:12:05.651Z (11 months ago)
- Language: TypeScript
- Size: 55.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Prototype Streaming Interface Word Counter
## Building / Running
```bash
$ npm install
$ npm run build
$ npm start
```## Request / Response
**Example request:** [POST] http://localhost:3000/word-count?n=3 (where n is the number of top-most frequent words; be sure to upload a UTF-8 encoded text file)
**Example response:**
```JSON
{
"frequencies": [
{
"word": "sed",
"count": 12
},
{
"word": "id",
"count": 10
},
{
"word": "sit",
"count": 8
}
]
}
```## Testing
Testing with code coverage.
```bash
$ npm install
$ npm test
```## Considerations and Additional Improvements
I wanted to use as little RAM as possible when processing larger files, so opted for parsing off of streaming input.
Unit tests could have had additional mock data and / or modification of mock data to perform additional test scenarios.
Didn't dive into potential error handing with using incorrect encoding types, non-integer / invalid range "n" values, etc.