Skip to content

Instantly share code, notes, and snippets.

@etoxin
Created June 28, 2018 07:26
Show Gist options
  • Save etoxin/b4f7313a3b337589fa96e6b575053f0c to your computer and use it in GitHub Desktop.
Save etoxin/b4f7313a3b337589fa96e6b575053f0c to your computer and use it in GitHub Desktop.
Assert
/**
* @param {boolean} condition
* @param {string} msg
*/
export function assert (condition, msg) {
if (!condition) throw new Error(`[assert error] ${msg}`)
}
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