JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1124585
  • Score
    100M100P100Q187967F
  • License MIT

Check where the code is running in the browser or node.js

Package Exports

  • browser-or-node

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (browser-or-node) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Browser or Node.js

Build Status npm version License: MIT

Check whether the code is running in the browser or node.js runtime.

Install

$ npm install --save browser-or-node

Usage

ES6 style import

import { isBrowser, isNode } from 'browser-or-node';

if (isBrowser) {
  // do browser only stuff
}

if (isNode) {
  // do node.js only stuff
}

ES5 style import

var jsEnv = require('browser-or-node');

if (jsEnv.isBrowser) {
  // do browser only stuff
}

if (jsEnv.isNode) {
  // do node.js only stuff
}

License

MIT © Dineshkumar Pandiyan