attach to `this` rather than `window` to support web workers (closes #8)