UNPKG

@dtex/mock-io

Version:

Mock provider for ECMA-419 IO testing

26 lines (20 loc) 359 B
class I2C { static Input = 0x00; static Output = 0x01; constructor(opts) { this.address = opts.address; this.onReadable = opts.onReadable; } read() { return this.value; } write(value) { if (value != this.value) { this.value = value; if (this.mode === this.Input) { this.onReadable(); } } } } export default I2C;