0.1.0 • Published 10 months ago

environment-safe-chai v0.1.0

Weekly downloads
-
License
-
Repository
-
Last release
10 months ago

environment-safe-chai

Ever since starting to run a single script I have to use an ugly compatibility block to import chai, something like:

import * as chaiModule from 'chai';
const chai = (
   typeof process === 'object' && 
   typeof process.versions === 'object' && 
   typeof process.versions.node !== 'undefined'
)?chaiModule:window.chai;

This works across native node modules, native browser modules and babel (for compatibility). It's also ugly (and potentially updatable in the future), so I'm masking it in this module.

import it with:

import { chai } from 'environment-safe-chai'; 
0.1.0

10 months ago

0.0.1

12 months ago