https://github.com/puse/spb25-device
Base class for random devices
https://github.com/puse/spb25-device
Last synced: over 1 year ago
JSON representation
Base class for random devices
- Host: GitHub
- URL: https://github.com/puse/spb25-device
- Owner: puse
- Created: 2016-12-19T14:33:28.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-12-19T15:09:04.000Z (over 9 years ago)
- Last Synced: 2025-02-01T08:26:37.346Z (over 1 year ago)
- Language: JavaScript
- Size: 2.93 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Device
Base class for random devices
### Example
~~~js
const Device = require('spb25-device');
const random = x => Math.floor(Math.random() * x);
class RandomNatural extends Device {
next (limit) {
return super.next(random(limit));
}
init (limit) {
return super.init(limit);
}
}
let die = new RandomNatural(10);
die.derive().then(console.log); // '6'
~~~
## Install
~~~sh
npm install spb25-device
~~~
## API
- `.derive()`
### License
MIT License