Created
June 28, 2018 07:26
-
-
Save etoxin/b4f7313a3b337589fa96e6b575053f0c to your computer and use it in GitHub Desktop.
Assert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @param {boolean} condition | |
* @param {string} msg | |
*/ | |
export function assert (condition, msg) { | |
if (!condition) throw new Error(`[assert error] ${msg}`) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (process.env.NODE_ENV !== 'production') { | |
assert(typeof type === 'string', `expects string as the type, but found ${typeof type}.`) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment