precondition
Version:
For safe coding
3 lines • 926 B
JavaScript
/*! precondition - v0.0.1 - 2012-11-14
* Copyright 2012 Ozan Turgut; Licensed MIT */
(function(e){if(typeof module=="undefined"||!module.exports)return window.precondition=e;module.exports=e})(function(){var e={};e.check=function(e,n){if(e===!1)throw n&&typeof n!="string"?n(arguments.length>3?r(arguments[2],t.call(arguments,3)):arguments[2]):new Error(arguments.length>2?r(n,t.call(arguments,2)):n);return e},e.checkType=function(e,n){if(e===!1)throw new TypeError(arguments.length>2?r(n,t.call(arguments,2)):n);return e},e.checkDefined=function(e,n){if(e===void 0)throw new ReferenceError(arguments.length>2?r(n,t.call(arguments,2)):n);return e},e.checkRange=function(e,n){if(e===!1)throw new RangeError(arguments.length>2?r(n,t.call(arguments,2)):n);return e};var t=Array.prototype.splice,n=/%s/,r=function(e,t){var r=[],i=e.split(n),s=0,o=i.length;for(;s<o;s++)r.push(i[s]),r.push(t[s]);return r.join("")};return e}());