Skip to content

Instantly share code, notes, and snippets.

@nirsky
Created December 17, 2019 14:36
Show Gist options
  • Save nirsky/eb1b39631a2243a1ea04e5b3a4696302 to your computer and use it in GitHub Desktop.
Save nirsky/eb1b39631a2243a1ea04e5b3a4696302 to your computer and use it in GitHub Desktop.
// node-handler.js
export const handle = () => {
require('fs').readFileSync(...);
...
};
// browser-handler.js
export const handle = () => { ... };
// index.js
const nodeHandler = require('./node-handler').handle;
const browserHandle = require('./browser-handler').handle;
const isNode = require('./config').isNode;
const handle = isNode ? nodeHandler : browserHandle;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment