browser-monads
Version:
Interface for the `window` and `document` variables of a webpage.
9 lines (6 loc) • 307 B
JavaScript
const { Nothing, isNothing } = require('nothing-mock');
const win = (typeof window !== 'undefined') ? window : Nothing;
const doc = (typeof document !== 'undefined') ? document : Nothing;
module.exports.window = win;
module.exports.document = doc;
module.exports.exists = variable => !isNothing(variable)