check-types-mini
Advanced tools
Comparing version 3.4.2 to 3.4.3
@@ -79,3 +79,3 @@ # Change Log | ||
Funny, I discovered this issue when I tried to set up `check-types-mini` on [easy-replace](https://github.com/codsen/easy-replace). Like they say, eat what you cook - the easiest way to discover issues is to use your own software. Especially, in production. | ||
Funny, I discovered this issue when I tried to set up `check-types-mini` on [easy-replace](https://bitbucket.org/codsen/easy-replace). Like they say, eat what you cook - the easiest way to discover issues is to use your own software. Especially, in production. | ||
@@ -138,19 +138,20 @@ ## [2.1.0] - 2017-06-18 | ||
[1.1.0]: https://github.com/codsen/check-types-mini/compare/v1.0.1...v1.1.0 | ||
[1.2.0]: https://github.com/codsen/check-types-mini/compare/v1.1.0...v1.2.0 | ||
[1.3.0]: https://github.com/codsen/check-types-mini/compare/v1.2.2...v1.3.0 | ||
[1.4.0]: https://github.com/codsen/check-types-mini/compare/v1.3.0...v1.4.0 | ||
[1.5.0]: https://github.com/codsen/check-types-mini/compare/v1.4.0...v1.5.0 | ||
[1.6.0]: https://github.com/codsen/check-types-mini/compare/v1.5.0...v1.6.0 | ||
[2.0.0]: https://github.com/codsen/check-types-mini/compare/v1.6.0...v2.0.0 | ||
[2.1.0]: https://github.com/codsen/check-types-mini/compare/v2.0.0...v2.1.0 | ||
[2.2.0]: https://github.com/codsen/check-types-mini/compare/v2.1.0...v2.2.0 | ||
[2.3.0]: https://github.com/codsen/check-types-mini/compare/v2.2.0...v2.3.0 | ||
[2.4.0]: https://github.com/codsen/check-types-mini/compare/v2.3.0...v2.4.0 | ||
[2.5.0]: https://github.com/codsen/check-types-mini/compare/v2.4.0...v2.5.0 | ||
[2.6.0]: https://github.com/codsen/check-types-mini/compare/v2.5.0...v2.6.0 | ||
[2.7.0]: https://github.com/codsen/check-types-mini/compare/v2.6.0...v2.7.0 | ||
[3.0.0]: https://github.com/codsen/check-types-mini/compare/v2.7.0...v3.0.0 | ||
[3.1.0]: https://github.com/codsen/check-types-mini/compare/v3.0.4...v3.1.0 | ||
[3.2.0]: https://github.com/codsen/check-types-mini/compare/v3.1.2...v3.2.0 | ||
[3.3.0]: https://github.com/codsen/check-types-mini/compare/v3.2.0...v3.3.0 | ||
[1.1.0]: https://bitbucket.org/codsen/check-types-mini/branches/compare/v1.1.0%0Dv1.0.1#diff | ||
[1.2.0]: https://bitbucket.org/codsen/check-types-mini/branches/compare/v1.2.0%0Dv1.1.1#diff | ||
[1.3.0]: https://bitbucket.org/codsen/check-types-mini/branches/compare/v1.3.0%0Dv1.2.2#diff | ||
[1.4.0]: https://bitbucket.org/codsen/check-types-mini/branches/compare/v1.4.0%0Dv1.3.0#diff | ||
[1.5.0]: https://bitbucket.org/codsen/check-types-mini/branches/compare/v1.5.0%0Dv1.4.1#diff | ||
[1.6.0]: https://bitbucket.org/codsen/check-types-mini/branches/compare/v1.6.0%0Dv3.4.2#diff | ||
[2.0.0]: https://bitbucket.org/codsen/check-types-mini/branches/compare/v2.0.0%0Dv1.5.0#diff | ||
[2.1.0]: https://bitbucket.org/codsen/check-types-mini/branches/compare/v2.1.0%0Dv2.0.3#diff | ||
[2.2.0]: https://bitbucket.org/codsen/check-types-mini/branches/compare/v2.2.0%0Dv2.1.1#diff | ||
[2.3.0]: https://bitbucket.org/codsen/check-types-mini/branches/compare/v2.3.0%0Dv2.2.1#diff | ||
[2.4.0]: https://bitbucket.org/codsen/check-types-mini/branches/compare/v2.4.0%0Dv2.3.0#diff | ||
[2.5.0]: https://bitbucket.org/codsen/check-types-mini/branches/compare/v2.5.0%0Dv2.4.2#diff | ||
[2.6.0]: https://bitbucket.org/codsen/check-types-mini/branches/compare/v2.6.0%0Dv2.5.0#diff | ||
[2.7.0]: https://bitbucket.org/codsen/check-types-mini/branches/compare/v2.7.0%0Dv2.6.1#diff | ||
[3.0.0]: https://bitbucket.org/codsen/check-types-mini/branches/compare/v3.0.0%0Dv2.7.0#diff | ||
[3.1.0]: https://bitbucket.org/codsen/check-types-mini/branches/compare/v3.1.0%0Dv3.0.4#diff | ||
[3.2.0]: https://bitbucket.org/codsen/check-types-mini/branches/compare/v3.2.0%0Dv3.1.2#diff | ||
[3.3.0]: https://bitbucket.org/codsen/check-types-mini/branches/compare/v3.3.0%0Dv3.2.0#diff | ||
[3.4.0]: https://bitbucket.org/codsen/check-types-mini/branches/compare/v3.4.0%0Dv3.3.1#diff |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.checkTypesMini=t()}(this,function(){"use strict";var _="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var e,v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},p=(function(e,t){var o,i,r,a,c,s,u,f,n,y,p,l,h,g,m,d,b,w;e.exports=(o="function"==typeof Promise,i="object"===("undefined"==typeof self?"undefined":v(self))?self:_,r="undefined"!=typeof Symbol,a="undefined"!=typeof Map,c="undefined"!=typeof Set,s="undefined"!=typeof WeakMap,u="undefined"!=typeof WeakSet,f="undefined"!=typeof DataView,n=r&&void 0!==Symbol.iterator,y=r&&void 0!==Symbol.toStringTag,p=c&&"function"==typeof Set.prototype.entries,l=a&&"function"==typeof Map.prototype.entries,h=p&&Object.getPrototypeOf((new Set).entries()),g=l&&Object.getPrototypeOf((new Map).entries()),m=n&&"function"==typeof Array.prototype[Symbol.iterator],d=m&&Object.getPrototypeOf([][Symbol.iterator]()),b=n&&"function"==typeof String.prototype[Symbol.iterator],w=b&&Object.getPrototypeOf(""[Symbol.iterator]()),function(e){var t=void 0===e?"undefined":v(e);if("object"!==t)return t;if(null===e)return"null";if(e===i)return"global";if(Array.isArray(e)&&(!1===y||!(Symbol.toStringTag in e)))return"Array";if("object"===("undefined"==typeof window?"undefined":v(window))&&null!==window){if("object"===v(window.location)&&e===window.location)return"Location";if("object"===v(window.document)&&e===window.document)return"Document";if("object"===v(window.navigator)){if("object"===v(window.navigator.mimeTypes)&&e===window.navigator.mimeTypes)return"MimeTypeArray";if("object"===v(window.navigator.plugins)&&e===window.navigator.plugins)return"PluginArray"}if(("function"==typeof window.HTMLElement||"object"===v(window.HTMLElement))&&e instanceof window.HTMLElement){if("BLOCKQUOTE"===e.tagName)return"HTMLQuoteElement";if("TD"===e.tagName)return"HTMLTableDataCellElement";if("TH"===e.tagName)return"HTMLTableHeaderCellElement"}}var r=y&&e[Symbol.toStringTag];if("string"==typeof r)return r;var n=Object.getPrototypeOf(e);return n===RegExp.prototype?"RegExp":n===Date.prototype?"Date":o&&n===Promise.prototype?"Promise":c&&n===Set.prototype?"Set":a&&n===Map.prototype?"Map":u&&n===WeakSet.prototype?"WeakSet":s&&n===WeakMap.prototype?"WeakMap":f&&n===DataView.prototype?"DataView":a&&n===g?"Map Iterator":c&&n===h?"Set Iterator":m&&n===d?"Array Iterator":b&&n===w?"String Iterator":null===n?"Object":Object.prototype.toString.call(e).slice(8,-1)})}(e={exports:{}},e.exports),e.exports);function l(e,t,r){if(t!=t)return function(e,t,r,n){for(var o=e.length,i=r+(n?1:-1);n?i--:++i<o;)if(t(e[i],i,e))return i;return-1}(e,i,r);for(var n=r-1,o=e.length;++n<o;)if(e[n]===t)return n;return-1}function h(e,t,r,n){for(var o=r-1,i=e.length;++o<i;)if(n(e[o],t))return o;return-1}function i(e){return e!=e}var g=Array.prototype.splice;function r(e,t,r,n){var o,i=n?h:l,a=-1,c=t.length,s=e;for(e===t&&(t=function(e,t){var r=-1,n=e.length;t||(t=Array(n));for(;++r<n;)t[r]=e[r];return t}(t)),r&&(s=function(e,t){for(var r=-1,n=e?e.length:0,o=Array(n);++r<n;)o[r]=t(e[r],r,e);return o}(e,(o=r,function(e){return o(e)})));++a<c;)for(var u=0,f=t[a],y=r?r(f):f;-1<(u=i(s,y,u,n));)s!==e&&g.call(s,u,1),g.call(e,u,1);return e}var m=function(e,t){return e&&e.length&&t&&t.length?r(e,t):e},a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n="__lodash_hash_undefined__",c=9007199254740991,o="[object Function]",s="[object GeneratorFunction]",u=/^\[object .+?Constructor\]$/,t="object"==a(_)&&_&&_.Object===Object&&_,f="object"==("undefined"==typeof self?"undefined":a(self))&&self&&self.Object===Object&&self,y=t||f||Function("return this")();function d(e,t){return!!(e?e.length:0)&&-1<function(e,t,r){if(t!=t)return function(e,t,r,n){var o=e.length,i=r+(n?1:-1);for(;n?i--:++i<o;)if(t(e[i],i,e))return i;return-1}(e,O,r);var n=r-1,o=e.length;for(;++n<o;)if(e[n]===t)return n;return-1}(e,t,0)}function b(e,t,r){for(var n=-1,o=e?e.length:0;++n<o;)if(r(t,e[n]))return!0;return!1}function w(e,t){for(var r=-1,n=e?e.length:0,o=Array(n);++r<n;)o[r]=t(e[r],r,e);return o}function O(e){return e!=e}function j(t){return function(e){return t(e)}}function S(e,t){return e.has(t)}var T,k,A,E=Array.prototype,M=Function.prototype,N=Object.prototype,I=y["__core-js_shared__"],D=(T=/[^.]+$/.exec(I&&I.keys&&I.keys.IE_PROTO||""))?"Symbol(src)_1."+T:"",H=M.toString,K=N.hasOwnProperty,V=N.toString,W=RegExp("^"+H.call(K).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),P=E.splice,L=Math.max,R=Math.min,x=z(y,"Map"),C=z(Object,"create");function J(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function $(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function B(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function F(e){var t=-1,r=e?e.length:0;for(this.__data__=new B;++t<r;)this.add(e[t])}function q(e,t){for(var r,n,o=e.length;o--;)if((r=e[o][0])===(n=t)||r!=r&&n!=n)return o;return-1}function Q(e){return!(!Y(e)||(t=e,D&&D in t))&&(X(e)||function(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}(e)?W:u).test(function(e){if(null!=e){try{return H.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e));var t}function G(e){return(o=t=e)&&"object"==(void 0===o?"undefined":a(o))&&(null!=(r=t)&&("number"==typeof(n=r.length)&&-1<n&&n%1==0&&n<=c)&&!X(r))?e:[];var t,r,n,o}function U(e,t){var r,n,o=e.__data__;return("string"==(n=void 0===(r=t)?"undefined":a(r))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==r:null===r)?o["string"==typeof t?"string":"hash"]:o.map}function z(e,t){var r,n,o=(n=t,null==(r=e)?void 0:r[n]);return Q(o)?o:void 0}function X(e){var t=Y(e)?V.call(e):"";return t==o||t==s}function Y(e){var t=void 0===e?"undefined":a(e);return!!e&&("object"==t||"function"==t)}J.prototype.clear=function(){this.__data__=C?C(null):{}},J.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},J.prototype.get=function(e){var t=this.__data__;if(C){var r=t[e];return r===n?void 0:r}return K.call(t,e)?t[e]:void 0},J.prototype.has=function(e){var t=this.__data__;return C?void 0!==t[e]:K.call(t,e)},J.prototype.set=function(e,t){return this.__data__[e]=C&&void 0===t?n:t,this},$.prototype.clear=function(){this.__data__=[]},$.prototype.delete=function(e){var t=this.__data__,r=q(t,e);return!(r<0||(r==t.length-1?t.pop():P.call(t,r,1),0))},$.prototype.get=function(e){var t=this.__data__,r=q(t,e);return r<0?void 0:t[r][1]},$.prototype.has=function(e){return-1<q(this.__data__,e)},$.prototype.set=function(e,t){var r=this.__data__,n=q(r,e);return n<0?r.push([e,t]):r[n][1]=t,this},B.prototype.clear=function(){this.__data__={hash:new J,map:new(x||$),string:new J}},B.prototype.delete=function(e){return U(this,e).delete(e)},B.prototype.get=function(e){return U(this,e).get(e)},B.prototype.has=function(e){return U(this,e).has(e)},B.prototype.set=function(e,t){return U(this,e).set(e,t),this},F.prototype.add=F.prototype.push=function(e){return this.__data__.set(e,n),this},F.prototype.has=function(e){return this.__data__.has(e)};var Z=(k=function(e){var t=w(e,G);return t.length&&t[0]===e[0]?function(e,t,r){for(var n=r?b:d,o=e[0].length,i=e.length,a=i,c=Array(i),s=1/0,u=[];a--;){var f=e[a];a&&t&&(f=w(f,j(t))),s=R(f.length,s),c[a]=!r&&(t||120<=o&&120<=f.length)?new F(a&&f):void 0}f=e[0];var y=-1,p=c[0];e:for(;++y<o&&u.length<s;){var l=f[y],h=t?t(l):l;if(l=r||0!==l?l:0,!(p?S(p,h):n(u,h,r))){for(a=i;--a;){var g=c[a];if(!(g?S(g,h):n(e[a],h,r)))continue e}p&&p.push(h),u.push(l)}}return u}(t):[]},A=L(void 0===A?k.length-1:A,0),function(){for(var e=arguments,t=-1,r=L(e.length-A,0),n=Array(r);++t<r;)n[t]=e[A+t];t=-1;for(var o=Array(A+1);++t<A;)o[t]=e[t];return o[A]=n,function(e,t,r){switch(r.length){case 0:return e.call(t);case 1:return e.call(t,r[0]);case 2:return e.call(t,r[0],r[1]);case 3:return e.call(t,r[0],r[1],r[2])}return e.apply(t,r)}(k,this,o)});function ee(e){return"string"==typeof e?0<e.length?[e]:[]:e}return function(n,e,t){function o(e){return null!=e}function r(e){return"boolean"===p(e)}function i(e){return"string"===p(e)}function a(e){return"Object"===p(e)}var c=["any","anything","every","everything","all","whatever","whatevs"],s=Array.isArray;if(0===arguments.length)throw new Error("check-types-mini: [THROW_ID_01] Missing all arguments!");if(1===arguments.length)throw new Error("check-types-mini: [THROW_ID_02] Missing second argument!");var u=a(e)?e:{},f={ignoreKeys:[],acceptArrays:!1,acceptArraysIgnore:[],enforceStrictKeyset:!0,schema:{},msg:"check-types-mini",optsVarName:"opts"},y=void 0;if(!i((y=o(t)&&a(t)?Object.assign({},f,t):Object.assign({},f)).msg))throw new Error("check-types-mini: [THROW_ID_03] opts.msg must be string! Currently it's: "+p(y.msg)+", equal to "+JSON.stringify(y.msg,null,4));if(y.msg=y.msg.trim(),":"===y.msg[y.msg.length-1]&&(y.msg=y.msg.slice(0,y.msg.length-1)),!i(y.optsVarName))throw new Error("check-types-mini: [THROW_ID_04] opts.optsVarName must be string! Currently it's: "+p(y.optsVarName)+", equal to "+JSON.stringify(y.optsVarName,null,4));if(y.ignoreKeys=ee(y.ignoreKeys),y.acceptArraysIgnore=ee(y.acceptArraysIgnore),!s(y.ignoreKeys))throw new TypeError("check-types-mini: [THROW_ID_05] opts.ignoreKeys should be an array, currently it's: "+p(y.ignoreKeys));if(!r(y.acceptArrays))throw new TypeError("check-types-mini: [THROW_ID_06] opts.acceptArrays should be a Boolean, currently it's: "+p(y.acceptArrays));if(!s(y.acceptArraysIgnore))throw new TypeError("check-types-mini: [THROW_ID_07] opts.acceptArraysIgnore should be an array, currently it's: "+p(y.acceptArraysIgnore));if(!r(y.enforceStrictKeyset))throw new TypeError("check-types-mini: [THROW_ID_08] opts.enforceStrictKeyset should be a Boolean, currently it's: "+p(y.enforceStrictKeyset));if(Object.keys(y.schema).forEach(function(e){s(y.schema[e])||(y.schema[e]=[y.schema[e]]),y.schema[e]=y.schema[e].map(String).map(function(e){return e.toLowerCase()}).map(function(e){return e.trim()})}),y.enforceStrictKeyset)if(o(y.schema)&&0<Object.keys(y.schema).length){if(0!==m(Object.keys(n),Object.keys(u).concat(Object.keys(y.schema))).length)throw new TypeError(y.msg+": "+y.optsVarName+".enforceStrictKeyset is on and the following keys are not covered by schema and/or reference objects: "+JSON.stringify(m(Object.keys(n),Object.keys(u).concat(Object.keys(y.schema))),null,4))}else{if(!(o(u)&&0<Object.keys(u).length))throw new TypeError(y.msg+": Both "+y.optsVarName+".schema and reference objects are missing! We don't have anything to match the keys as you requested via opts.enforceStrictKeyset!");if(0!==m(Object.keys(n),Object.keys(u)).length)throw new TypeError(y.msg+": The input object has keys that are not covered by reference object: "+JSON.stringify(m(Object.keys(n),Object.keys(u)),null,4));if(0!==m(Object.keys(u),Object.keys(n)).length)throw new TypeError(y.msg+": The reference object has keys that are not present in the input object: "+JSON.stringify(m(Object.keys(u),Object.keys(n)),null,4))}Object.keys(n).forEach(function(t){if(o(y.schema)&&Object.prototype.hasOwnProperty.call(y.schema,t)){if(y.schema[t]=ee(y.schema[t]).map(String).map(function(e){return e.toLowerCase()}),!(Z(y.schema[t],c).length||(!0===n[t]||!1===n[t]||y.schema[t].includes(p(n[t]).toLowerCase()))&&(!0!==n[t]&&!1!==n[t]||y.schema[t].includes(String(n[t]))||y.schema[t].includes("boolean")))){if(!s(n[t])||!y.acceptArrays)throw new TypeError(y.msg+": "+y.optsVarName+"."+t+" was customised to "+JSON.stringify(n[t],null,4)+" which is not among the allowed types in schema ("+y.schema[t]+") but "+p(n[t]));for(var e=0,r=n[t].length;e<r;e++)if(!y.schema[t].includes(p(n[t][e]).toLowerCase()))throw new TypeError(y.msg+": "+y.optsVarName+"."+t+" is of type "+p(n[t][e]).toLowerCase()+", but only the following are allowed in "+y.optsVarName+".schema: "+y.schema[t])}}else if(o(u)&&Object.prototype.hasOwnProperty.call(u,t)&&p(n[t])!==p(u[t])&&!y.ignoreKeys.includes(t)){if(!y.acceptArrays||!s(n[t])||y.acceptArraysIgnore.includes(t))throw new TypeError(y.msg+": "+y.optsVarName+"."+t+" was customised to "+JSON.stringify(n[t],null,4)+" which is not "+p(u[t])+" but "+p(n[t]));if(!n[t].every(function(e){return p(e)===p(u[t])}))throw new TypeError(y.msg+": "+y.optsVarName+"."+t+" was customised to be array, but not all of its elements are "+p(u[t])+"-type")}})}}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.checkTypesMini=t()}(this,function(){"use strict";var _="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var e,v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},p=(function(e,t){var o,i,r,a,c,s,u,f,n,y,p,l,h,g,d,m,b,w;e.exports=(o="function"==typeof Promise,i="object"===("undefined"==typeof self?"undefined":v(self))?self:_,r="undefined"!=typeof Symbol,a="undefined"!=typeof Map,c="undefined"!=typeof Set,s="undefined"!=typeof WeakMap,u="undefined"!=typeof WeakSet,f="undefined"!=typeof DataView,n=r&&void 0!==Symbol.iterator,y=r&&void 0!==Symbol.toStringTag,p=c&&"function"==typeof Set.prototype.entries,l=a&&"function"==typeof Map.prototype.entries,h=p&&Object.getPrototypeOf((new Set).entries()),g=l&&Object.getPrototypeOf((new Map).entries()),d=n&&"function"==typeof Array.prototype[Symbol.iterator],m=d&&Object.getPrototypeOf([][Symbol.iterator]()),b=n&&"function"==typeof String.prototype[Symbol.iterator],w=b&&Object.getPrototypeOf(""[Symbol.iterator]()),function(e){var t=void 0===e?"undefined":v(e);if("object"!==t)return t;if(null===e)return"null";if(e===i)return"global";if(Array.isArray(e)&&(!1===y||!(Symbol.toStringTag in e)))return"Array";if("object"===("undefined"==typeof window?"undefined":v(window))&&null!==window){if("object"===v(window.location)&&e===window.location)return"Location";if("object"===v(window.document)&&e===window.document)return"Document";if("object"===v(window.navigator)){if("object"===v(window.navigator.mimeTypes)&&e===window.navigator.mimeTypes)return"MimeTypeArray";if("object"===v(window.navigator.plugins)&&e===window.navigator.plugins)return"PluginArray"}if(("function"==typeof window.HTMLElement||"object"===v(window.HTMLElement))&&e instanceof window.HTMLElement){if("BLOCKQUOTE"===e.tagName)return"HTMLQuoteElement";if("TD"===e.tagName)return"HTMLTableDataCellElement";if("TH"===e.tagName)return"HTMLTableHeaderCellElement"}}var r=y&&e[Symbol.toStringTag];if("string"==typeof r)return r;var n=Object.getPrototypeOf(e);return n===RegExp.prototype?"RegExp":n===Date.prototype?"Date":o&&n===Promise.prototype?"Promise":c&&n===Set.prototype?"Set":a&&n===Map.prototype?"Map":u&&n===WeakSet.prototype?"WeakSet":s&&n===WeakMap.prototype?"WeakMap":f&&n===DataView.prototype?"DataView":a&&n===g?"Map Iterator":c&&n===h?"Set Iterator":d&&n===m?"Array Iterator":b&&n===w?"String Iterator":null===n?"Object":Object.prototype.toString.call(e).slice(8,-1)})}(e={exports:{}},e.exports),e.exports);function l(e,t,r){if(t!=t)return function(e,t,r,n){for(var o=e.length,i=r+(n?1:-1);n?i--:++i<o;)if(t(e[i],i,e))return i;return-1}(e,i,r);for(var n=r-1,o=e.length;++n<o;)if(e[n]===t)return n;return-1}function h(e,t,r,n){for(var o=r-1,i=e.length;++o<i;)if(n(e[o],t))return o;return-1}function i(e){return e!=e}var g=Array.prototype.splice;function r(e,t,r,n){var o,i=n?h:l,a=-1,c=t.length,s=e;for(e===t&&(t=function(e,t){var r=-1,n=e.length;t||(t=Array(n));for(;++r<n;)t[r]=e[r];return t}(t)),r&&(s=function(e,t){for(var r=-1,n=e?e.length:0,o=Array(n);++r<n;)o[r]=t(e[r],r,e);return o}(e,(o=r,function(e){return o(e)})));++a<c;)for(var u=0,f=t[a],y=r?r(f):f;-1<(u=i(s,y,u,n));)s!==e&&g.call(s,u,1),g.call(e,u,1);return e}var d=function(e,t){return e&&e.length&&t&&t.length?r(e,t):e},a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n="__lodash_hash_undefined__",c=9007199254740991,o="[object Function]",s="[object GeneratorFunction]",u=/^\[object .+?Constructor\]$/,t="object"==a(_)&&_&&_.Object===Object&&_,f="object"==("undefined"==typeof self?"undefined":a(self))&&self&&self.Object===Object&&self,y=t||f||Function("return this")();function m(e,t){return!!(e?e.length:0)&&-1<function(e,t,r){if(t!=t)return function(e,t,r,n){var o=e.length,i=r+(n?1:-1);for(;n?i--:++i<o;)if(t(e[i],i,e))return i;return-1}(e,O,r);var n=r-1,o=e.length;for(;++n<o;)if(e[n]===t)return n;return-1}(e,t,0)}function b(e,t,r){for(var n=-1,o=e?e.length:0;++n<o;)if(r(t,e[n]))return!0;return!1}function w(e,t){for(var r=-1,n=e?e.length:0,o=Array(n);++r<n;)o[r]=t(e[r],r,e);return o}function O(e){return e!=e}function j(t){return function(e){return t(e)}}function S(e,t){return e.has(t)}var T,k,A,E=Array.prototype,M=Function.prototype,N=Object.prototype,I=y["__core-js_shared__"],D=(T=/[^.]+$/.exec(I&&I.keys&&I.keys.IE_PROTO||""))?"Symbol(src)_1."+T:"",H=M.toString,K=N.hasOwnProperty,V=N.toString,W=RegExp("^"+H.call(K).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),$=E.splice,P=Math.max,L=Math.min,R=z(y,"Map"),x=z(Object,"create");function C(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function J(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function B(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function F(e){var t=-1,r=e?e.length:0;for(this.__data__=new B;++t<r;)this.add(e[t])}function q(e,t){for(var r,n,o=e.length;o--;)if((r=e[o][0])===(n=t)||r!=r&&n!=n)return o;return-1}function Q(e){return!(!Y(e)||(t=e,D&&D in t))&&(X(e)||function(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}(e)?W:u).test(function(e){if(null!=e){try{return H.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e));var t}function G(e){return(o=t=e)&&"object"==(void 0===o?"undefined":a(o))&&(null!=(r=t)&&("number"==typeof(n=r.length)&&-1<n&&n%1==0&&n<=c)&&!X(r))?e:[];var t,r,n,o}function U(e,t){var r,n,o=e.__data__;return("string"==(n=void 0===(r=t)?"undefined":a(r))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==r:null===r)?o["string"==typeof t?"string":"hash"]:o.map}function z(e,t){var r,n,o=(n=t,null==(r=e)?undefined$3:r[n]);return Q(o)?o:undefined$3}function X(e){var t=Y(e)?V.call(e):"";return t==o||t==s}function Y(e){var t=void 0===e?"undefined":a(e);return!!e&&("object"==t||"function"==t)}C.prototype.clear=function(){this.__data__=x?x(null):{}},C.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},C.prototype.get=function(e){var t=this.__data__;if(x){var r=t[e];return r===n?undefined$3:r}return K.call(t,e)?t[e]:undefined$3},C.prototype.has=function(e){var t=this.__data__;return x?t[e]!==undefined$3:K.call(t,e)},C.prototype.set=function(e,t){return this.__data__[e]=x&&t===undefined$3?n:t,this},J.prototype.clear=function(){this.__data__=[]},J.prototype.delete=function(e){var t=this.__data__,r=q(t,e);return!(r<0||(r==t.length-1?t.pop():$.call(t,r,1),0))},J.prototype.get=function(e){var t=this.__data__,r=q(t,e);return r<0?undefined$3:t[r][1]},J.prototype.has=function(e){return-1<q(this.__data__,e)},J.prototype.set=function(e,t){var r=this.__data__,n=q(r,e);return n<0?r.push([e,t]):r[n][1]=t,this},B.prototype.clear=function(){this.__data__={hash:new C,map:new(R||J),string:new C}},B.prototype.delete=function(e){return U(this,e).delete(e)},B.prototype.get=function(e){return U(this,e).get(e)},B.prototype.has=function(e){return U(this,e).has(e)},B.prototype.set=function(e,t){return U(this,e).set(e,t),this},F.prototype.add=F.prototype.push=function(e){return this.__data__.set(e,n),this},F.prototype.has=function(e){return this.__data__.has(e)};var Z=(k=function(e){var t=w(e,G);return t.length&&t[0]===e[0]?function(e,t,r){for(var n=r?b:m,o=e[0].length,i=e.length,a=i,c=Array(i),s=1/0,u=[];a--;){var f=e[a];a&&t&&(f=w(f,j(t))),s=L(f.length,s),c[a]=!r&&(t||120<=o&&120<=f.length)?new F(a&&f):undefined$3}f=e[0];var y=-1,p=c[0];e:for(;++y<o&&u.length<s;){var l=f[y],h=t?t(l):l;if(l=r||0!==l?l:0,!(p?S(p,h):n(u,h,r))){for(a=i;--a;){var g=c[a];if(!(g?S(g,h):n(e[a],h,r)))continue e}p&&p.push(h),u.push(l)}}return u}(t):[]},A=P(A===undefined$3?k.length-1:A,0),function(){for(var e=arguments,t=-1,r=P(e.length-A,0),n=Array(r);++t<r;)n[t]=e[A+t];t=-1;for(var o=Array(A+1);++t<A;)o[t]=e[t];return o[A]=n,function(e,t,r){switch(r.length){case 0:return e.call(t);case 1:return e.call(t,r[0]);case 2:return e.call(t,r[0],r[1]);case 3:return e.call(t,r[0],r[1],r[2])}return e.apply(t,r)}(k,this,o)});function ee(e){return"string"==typeof e?0<e.length?[e]:[]:e}return function(n,e,t){function o(e){return null!=e}function r(e){return"boolean"===p(e)}function i(e){return"string"===p(e)}function a(e){return"Object"===p(e)}var c=["any","anything","every","everything","all","whatever","whatevs"],s=Array.isArray;if(0===arguments.length)throw new Error("check-types-mini: [THROW_ID_01] Missing all arguments!");if(1===arguments.length)throw new Error("check-types-mini: [THROW_ID_02] Missing second argument!");var u=a(e)?e:{},f={ignoreKeys:[],acceptArrays:!1,acceptArraysIgnore:[],enforceStrictKeyset:!0,schema:{},msg:"check-types-mini",optsVarName:"opts"},y=void 0;if(!i((y=o(t)&&a(t)?Object.assign({},f,t):Object.assign({},f)).msg))throw new Error("check-types-mini: [THROW_ID_03] opts.msg must be string! Currently it's: "+p(y.msg)+", equal to "+JSON.stringify(y.msg,null,4));if(y.msg=y.msg.trim(),":"===y.msg[y.msg.length-1]&&(y.msg=y.msg.slice(0,y.msg.length-1)),!i(y.optsVarName))throw new Error("check-types-mini: [THROW_ID_04] opts.optsVarName must be string! Currently it's: "+p(y.optsVarName)+", equal to "+JSON.stringify(y.optsVarName,null,4));if(y.ignoreKeys=ee(y.ignoreKeys),y.acceptArraysIgnore=ee(y.acceptArraysIgnore),!s(y.ignoreKeys))throw new TypeError("check-types-mini: [THROW_ID_05] opts.ignoreKeys should be an array, currently it's: "+p(y.ignoreKeys));if(!r(y.acceptArrays))throw new TypeError("check-types-mini: [THROW_ID_06] opts.acceptArrays should be a Boolean, currently it's: "+p(y.acceptArrays));if(!s(y.acceptArraysIgnore))throw new TypeError("check-types-mini: [THROW_ID_07] opts.acceptArraysIgnore should be an array, currently it's: "+p(y.acceptArraysIgnore));if(!r(y.enforceStrictKeyset))throw new TypeError("check-types-mini: [THROW_ID_08] opts.enforceStrictKeyset should be a Boolean, currently it's: "+p(y.enforceStrictKeyset));if(Object.keys(y.schema).forEach(function(e){s(y.schema[e])||(y.schema[e]=[y.schema[e]]),y.schema[e]=y.schema[e].map(String).map(function(e){return e.toLowerCase()}).map(function(e){return e.trim()})}),y.enforceStrictKeyset)if(o(y.schema)&&0<Object.keys(y.schema).length){if(0!==d(Object.keys(n),Object.keys(u).concat(Object.keys(y.schema))).length)throw new TypeError(y.msg+": "+y.optsVarName+".enforceStrictKeyset is on and the following keys are not covered by schema and/or reference objects: "+JSON.stringify(d(Object.keys(n),Object.keys(u).concat(Object.keys(y.schema))),null,4))}else{if(!(o(u)&&0<Object.keys(u).length))throw new TypeError(y.msg+": Both "+y.optsVarName+".schema and reference objects are missing! We don't have anything to match the keys as you requested via opts.enforceStrictKeyset!");if(0!==d(Object.keys(n),Object.keys(u)).length)throw new TypeError(y.msg+": The input object has keys that are not covered by reference object: "+JSON.stringify(d(Object.keys(n),Object.keys(u)),null,4));if(0!==d(Object.keys(u),Object.keys(n)).length)throw new TypeError(y.msg+": The reference object has keys that are not present in the input object: "+JSON.stringify(d(Object.keys(u),Object.keys(n)),null,4))}Object.keys(n).forEach(function(t){if(o(y.schema)&&Object.prototype.hasOwnProperty.call(y.schema,t)){if(y.schema[t]=ee(y.schema[t]).map(String).map(function(e){return e.toLowerCase()}),!(Z(y.schema[t],c).length||(!0===n[t]||!1===n[t]||y.schema[t].includes(p(n[t]).toLowerCase()))&&(!0!==n[t]&&!1!==n[t]||y.schema[t].includes(String(n[t]))||y.schema[t].includes("boolean")))){if(!s(n[t])||!y.acceptArrays)throw new TypeError(y.msg+": "+y.optsVarName+"."+t+" was customised to "+JSON.stringify(n[t],null,4)+" which is not among the allowed types in schema ("+y.schema[t]+") but "+p(n[t]));for(var e=0,r=n[t].length;e<r;e++)if(!y.schema[t].includes(p(n[t][e]).toLowerCase()))throw new TypeError(y.msg+": "+y.optsVarName+"."+t+" is of type "+p(n[t][e]).toLowerCase()+", but only the following are allowed in "+y.optsVarName+".schema: "+y.schema[t])}}else if(o(u)&&Object.prototype.hasOwnProperty.call(u,t)&&p(n[t])!==p(u[t])&&!y.ignoreKeys.includes(t)){if(!y.acceptArrays||!s(n[t])||y.acceptArraysIgnore.includes(t))throw new TypeError(y.msg+": "+y.optsVarName+"."+t+" was customised to "+JSON.stringify(n[t],null,4)+" which is not "+p(u[t])+" but "+p(n[t]));if(!n[t].every(function(e){return p(e)===p(u[t])}))throw new TypeError(y.msg+": "+y.optsVarName+"."+t+" was customised to be array, but not all of its elements are "+p(u[t])+"-type")}})}}); |
{ | ||
"name": "check-types-mini", | ||
"version": "3.4.2", | ||
"version": "3.4.3", | ||
"description": "Check the types of your options object's values after user has customised them", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -6,2 +6,3 @@ # check-types-mini | ||
[![Minimum Node version required][node-img]][node-url] | ||
[![Repository is on BitBucket][bitbucket-img]][bitbucket-url] | ||
[![Coverage][cov-img]][cov-url] | ||
@@ -16,3 +17,2 @@ [![View dependencies as 2D chart][deps2d-img]][deps2d-url] | ||
- [Table of Contents](#markdown-header-table-of-contents) | ||
- [Install](#markdown-header-install) | ||
@@ -47,3 +47,3 @@ - [Idea](#markdown-header-idea) | ||
**[⬆ back to top](#)** | ||
**[⬆ back to top](#markdown-header-check-types-mini)** | ||
@@ -68,3 +68,3 @@ ## Idea | ||
**[⬆ back to top](#)** | ||
**[⬆ back to top](#markdown-header-check-types-mini)** | ||
@@ -87,3 +87,3 @@ ## API | ||
**[⬆ back to top](#)** | ||
**[⬆ back to top](#markdown-header-check-types-mini)** | ||
@@ -104,3 +104,3 @@ ### Options object | ||
**[⬆ back to top](#)** | ||
**[⬆ back to top](#markdown-header-check-types-mini)** | ||
@@ -188,11 +188,11 @@ ### For example | ||
**[⬆ back to top](#)** | ||
**[⬆ back to top](#markdown-header-check-types-mini)** | ||
### `opts.enforceStrictKeyset` | ||
When I was coding a new major version of [ast-delete-object](https://github.com/codsen/ast-delete-object) I had to update all the unit tests too. Previously, the settings were set using only one argument, Boolean-type. I had to change it to be a plain object. I noticed that when I missed updating some tests, their Booleans were `Object.assign`ed into a default settings object and no alarm was being raised! That's not good. | ||
When I was coding a new major version of [ast-delete-object](https://bitbucket.org/codsen/ast-delete-object) I had to update all the unit tests too. Previously, the settings were set using only one argument, Boolean-type. I had to change it to be a plain object. I noticed that when I missed updating some tests, their Booleans were `Object.assign`ed into a default settings object and no alarm was being raised! That's not good. | ||
Then I came up with the idea to **enforce the keys of the object** to match the reference and/or schema keys in `options`. It's on by default because I can't imagine how you would end up with settings object that does not match your default settings object, key-wise, but if you don't like that, feel free to turn it off. It's `opts.enforceStrictKeyset` Boolean flag. | ||
**[⬆ back to top](#)** | ||
**[⬆ back to top](#markdown-header-check-types-mini)** | ||
@@ -266,3 +266,3 @@ ### `opts.schema` | ||
**[⬆ back to top](#)** | ||
**[⬆ back to top](#markdown-header-check-types-mini)** | ||
@@ -277,3 +277,3 @@ ## Contributing | ||
**[⬆ back to top](#)** | ||
**[⬆ back to top](#markdown-header-check-types-mini)** | ||
@@ -288,2 +288,4 @@ ## Licence | ||
[node-url]: https://www.npmjs.com/package/check-types-mini | ||
[bitbucket-img]: https://img.shields.io/badge/repo-on%20BitBucket-brightgreen.svg?style=flat-square | ||
[bitbucket-url]: https://bitbucket.org/codsen/check-types-mini | ||
[cov-img]: https://coveralls.io/repos/bitbucket/codsen/check-types-mini/badge.svg?style=flat-square&branch=master | ||
@@ -290,0 +292,0 @@ [cov-url]: https://coveralls.io/bitbucket/codsen/check-types-mini?branch=master |
56223
293