@kmamal/sdl
Version:
SDL bindings for Node.js
23 lines (16 loc) • 544 B
JavaScript
const Globals = require('../globals')
const Bindings = require('../bindings')
const { EventsViaPoll } = require('../events/events-via-poll')
const validEvents = [ 'update' ]
const clipboard = new class extends EventsViaPoll {
constructor () { super(validEvents) }
get text () {
Globals.events.poll()
return Bindings.clipboard_getText()
}
setText (text) {
if (typeof text !== 'string') { throw Object.assign(new Error("text must be a string"), { text }) }
Bindings.clipboard_setText(text)
}
}()
module.exports = { clipboard }