UNPKG

immutability-util

Version:

Mutate a copy of data without changing the original source. Inspired by immutability-helper.

18 lines (16 loc) 430 B
/** * Created by hustcc. * * from: https://github.com/zertosh/invariant/blob/master/invariant.js */ module.exports = (condition, format, ...args) => { if (!condition && format) { let index = -1; const error = new Error( format.replace(/%s/g, () => args[index += 1]) ); error.name = 'Invariant Violation'; error.framesToPop = 1; // we don't care about invariant's own frame throw error; } };