https://github.com/jalal246/textics-stream
Text Statistics For Node Streams
https://github.com/jalal246/textics-stream
characters count-data count-lines counter get-info linesearch mytools node search-in-text statistics stream string string-calculator string-manipulation string-search text textics textics-stream transformer wordsearch
Last synced: 9 months ago
JSON representation
Text Statistics For Node Streams
- Host: GitHub
- URL: https://github.com/jalal246/textics-stream
- Owner: jalal246
- License: gpl-3.0
- Created: 2017-08-22T17:16:13.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2020-12-18T01:03:33.000Z (over 5 years ago)
- Last Synced: 2025-08-15T04:20:43.624Z (10 months ago)
- Topics: characters, count-data, count-lines, counter, get-info, linesearch, mytools, node, search-in-text, statistics, stream, string, string-calculator, string-manipulation, string-search, text, textics, textics-stream, transformer, wordsearch
- Language: JavaScript
- Homepage: https://jalal246.github.io/textics-stream/
- Size: 58.6 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# textics-stream
> `text/ics-stream` is a node version of
> [textics](https://github.com/Jimmy02020/textics). Counts lines,
> words, chars and spaces for a stream of strings :shower:
```bash
npm install textics-stream
```
## API
```js
import TStream from "textics-stream";
const txtStream = new TStream();
// Start counting
myStream.pipe(txtStream);
// Get lat chunk stat result
txtStream.on("latChunkStat", result => {
// result : {lines, words, chars, spaces}
});
// Get all stat counters
txtStream.getStat();
```
### Example
```js
import TStream from "textics-stream";
import fs from "fs";
// Create read stream for file you want to read form
const rStream = fs.createReadStream(myFile);
// Create TexticsStream instance
const txtStream = new TStream();
// Pass reading stream to textics
rStream.pipe(txtStream);
// For each chunk passed, give me the result
txtStream.on("latChunkStat", result => {
// do something
});
// When done, give me the final result
rStream.on("end", () => {
const { lines, words, chars, spaces } = txtStream.getStat();
});
```
### Related projects
- [textics](https://github.com/Jimmy02020/textics) - Using textics for browser.
- [packageSorter](https://github.com/jalal246/packageSorter) - Sorting packages
for monorepos production.
- [builderz](https://github.com/jalal246/builderz) - Building your project with zero config.
- [corename](https://github.com/jalal246/corename) - Extracts package name.
- [get-info](https://github.com/jalal246/get-info) - Utility functions for
projects production.
- [move-position](https://github.com/jalal246/move-position) - Moves element in given array form index-A to index-B
## Tests
```sh
npm test
```
## License
This project is licensed under the [GPL-3.0 License](https://github.com/Jimmy02020/textics-stream/blob/master/LICENSE)