https://github.com/theroyalwhee0/counters
Wrapping Numeric Counters
https://github.com/theroyalwhee0/counters
counters
Last synced: about 2 months ago
JSON representation
Wrapping Numeric Counters
- Host: GitHub
- URL: https://github.com/theroyalwhee0/counters
- Owner: theroyalwhee0
- License: apache-2.0
- Created: 2021-01-27T23:14:50.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-01-08T20:13:34.000Z (over 2 years ago)
- Last Synced: 2025-03-11T22:30:17.954Z (2 months ago)
- Topics: counters
- Language: TypeScript
- Homepage:
- Size: 682 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @theroyalwhee0/counters
## Wrapping Numeric Counters
Creates iterable sequences of 8/16/32/53 bits wrapping when the maximum value is exceeded. The sequences start at 1 (instead of 0) to prevent usage errors.## Installation
`npm install @theroyalwhee0/counters`*or*
`yarn add @theroyalwhee0/counters`
## Documentation
[API Documentation](https://theroyalwhee0.github.io/counters/)## Usage
```
const { uint8Counter } = require('./index');
const counter = uint8Counter();
let item = counter.next();
console.log(`${item.value} should be 1`);
item = counter.next();
console.log(`${item.value} should now be 2`);
for(let idx=0; idx < 255; idx++) {
item = counter.next();
console.log(`${idx} = ${item.value}`);
}
```## Testing.
Running ```npm run test``` will run the test suite. Running ```npm run test-watch``` will run the test suite in watch mode.## Links
- GitHub: https://github.com/theroyalwhee0/counters
- NPM: https://www.npmjs.com/package/@theroyalwhee0/counters## History
- v1.0.0 - 2022-06-02
- Bump depends for security.
- v0.0.3 - 2021-03-30
- Port to TypeScript.
- v0.0.2
- Change docs to not have date.
- v0.0.1 2021-01-27
- Initial release.## Legal & License
Copyright 2021-2022 Adam MillThis library is released under Apache 2 license. See [LICENSE](https://github.com/theroyalwhee0/dynasty/blob/master/LICENSE) for more details.