JS: Strip invariant calls in production

Fixes #742
This commit is contained in:
Erik Arvidsson
2015-12-17 11:43:48 -05:00
parent 201a8a46d6
commit de0632be77
2 changed files with 17 additions and 6 deletions

View File

@@ -1,8 +1,20 @@
// @flow
import {readValue, Struct, makeType, Ref, registerPackage} from 'noms';
import {
invariant,
Kind,
makeCompoundType,
makePrimitiveType,
makeType,
NomsMap,
NomsSet,
readValue,
Ref,
registerPackage,
SetLeafSequence,
Struct
} from 'noms';
import type {ChunkStore, Package} from 'noms';
import {invariant, Kind, NomsMap, NomsSet, SetLeafSequence, makeCompoundType, makePrimitiveType} from 'noms';
type RoundTypeEnum = 0 | 1 | 2;
const Seed = 0;

View File

@@ -1,9 +1,8 @@
// @flow
export function invariant(exp: boolean, message: string = 'Invariant violated') {
if (!exp) {
throw new Error(message);
}
export function invariant(exp: any, message: string = 'Invariant violated') {
if (process.env.NODE_ENV === 'production') return;
if (!exp) throw new Error(message);
}
export function notNull<T>(v: ?T): T {