check-types
Advanced tools
Comparing version 11.1.0 to 11.1.1
# History | ||
## 11.1.1 | ||
### Other changes | ||
* build: update minified script (99f024b) | ||
* docs: tweak comment (6a69673) | ||
## 11.1.0 | ||
@@ -4,0 +11,0 @@ |
{ | ||
"name": "check-types", | ||
"version": "11.1.0", | ||
"version": "11.1.1", | ||
"description": "A little library for asserting types and values.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://gitlab.com/philbooth/check-types.js", |
@@ -64,3 +64,3 @@ # check-types.js | ||
24 kb unminified with comments, 7 kb minified, 2.5 kb minified + gzipped. | ||
24 kb unminified with comments, 7.1 kb minified, 2.5 kb minified + gzipped. | ||
@@ -67,0 +67,0 @@ ## How do I install it? |
@@ -49,3 +49,3 @@ /*globals define, module, Symbol, Map, Set */ | ||
{ n: 'instanceStrict', f: instanceStrict, s: 'be instanceof {t}' }, | ||
{ n: 'thenable', f: thenable, s: 'be a promise' }, | ||
{ n: 'thenable', f: thenable, s: 'be promise-like' }, | ||
{ n: 'instance', f: instance, s: 'be {t}' }, | ||
@@ -406,3 +406,3 @@ { n: 'like', f: like, s: 'be like {e}' }, | ||
* | ||
* Returns true if `data` is a promise, false otherwise. | ||
* Returns true if `data` has a `then` method. | ||
*/ | ||
@@ -409,0 +409,0 @@ function thenable (data) { |
@@ -1,1 +0,1 @@ | ||
!function(n){"use strict";var i,r,e,f,c,t,u,o,a,l,s,b,p,y,m,h,g,d;function v(n){return null!=n}function j(n){return"number"==typeof n&&p<n&&n<y}function E(n){return"number"==typeof n&&n%1==0}function O(n,e){return j(n)&&e<n}function w(n,e){return j(n)&&n<e}function S(n,e){return j(n)&&e<=n}function k(n,e){return j(n)&&n<=e}function I(n){return"string"==typeof n}function N(n){return I(n)&&""!==n}function A(n){return"[object Object]"===a.call(n)}function q(n,e){for(var t in n)if(o.call(n,t)&&e(t,n[t]))return!0;return!1}function x(n,e){try{return n instanceof e}catch(n){return!1}}function T(n,e){var t;for(t in e)if(o.call(e,t)){if(!1===o.call(n,t)||typeof n[t]!=typeof e[t])return!1;if(A(n[t])&&!1===T(n[t],e[t]))return!1}return!0}function F(n){return v(n)&&0<=n.length}function L(n){return m?v(n)&&M(n[Symbol.iterator]):F(n)}function P(n,t){var e,r;if(!v(n))return!1;if(g&&x(n,Set))return n.has(t);if(I(n))return-1!==n.indexOf(t);if(m&&n[Symbol.iterator]&&M(n.values)){e=n.values();do{if((r=e.next()).value===t)return!0}while(!r.done);return!1}return q(n,function(n,e){return e===t})}function D(n,e){return!!v(n)&&(h&&x(n,Map)?n.has(e):!(L(n)&&!j(+e))&&!!n[e])}function M(n){return"function"==typeof n}function R(n,e){for(var t in n)o.call(n,t)&&e(t,n[t])}function V(n,e){var t;for(t=0;t<n.length;t+=1)if(n[t]===e)return e;return!e}function Y(n,e){var t,r;for(t in n)if(o.call(n,t)){if(A(r=n[t])&&Y(r,e)===e)return e;if(r===e)return e}return!e}function _(t,n){return R(n,function(n,e){t[n]=e}),t}function z(u,o){return function(){var e=arguments,n=u.l||u.length,t=e[n],r=e[n+1];return G(u.apply(null,e),N(t)?t:o.replace("{a}",B(e[0])).replace("{e}",B(e[1])).replace("{e2}",B(e[2])).replace("{t}",function(){var n=e[1];return n&&n.name?n.name:n}),M(r)?r:TypeError),e[0]}}function B(n){return function(){return I(n)?'"'+n.replace(/\\/g,"\\\\").replace(/"/g,'\\"')+'"':n&&n.constructor&&!x(n,RegExp)&&"number"!=typeof n?n.constructor.name:n}}function G(n,e,t){if(n)return n;throw new(t||Error)(e||"assert failed")}function K(n){var e=function(){return C(n.apply(null,arguments))};return e.l=n.length,e}function C(n){return!n}function H(t,r,u){var n=function(){var n,e;if(n=arguments[0],"maybe"===t&&c.assigned(n))return!0;if(!r(n))return!1;n=function(n,e){switch(n){case F:return s.call(e);case A:return l(e).map(function(n){return e[n]});default:return e}}(r,n),e=s.call(arguments,1);try{n.forEach(function(n){if(("maybe"!==t||v(n))&&!u.apply(null,[n].concat(e)))throw 0})}catch(n){return!1}return!0};return n.l=u.length,n}function J(n,e){return Q([n,r,e,""])}function Q(r){var u,o,f;return u=r.shift(),o=r.pop(),f=r.pop(),R(r.pop(),function(n,e){var t=i[n];t&&o&&(t=t.replace("to",o+"to")),Object.defineProperty(f,n,{configurable:!1,enumerable:!0,writable:!1,value:u.apply(null,r.concat(e,t))})}),f}function U(n,e,t){return Q([n,e,{},t])}function W(e,t){u.forEach(function(n){e[n].of=U(t,r[n].of)})}i={},r={},[{n:"equal",f:function(n,e){return n===e},s:"equal {e}"},{n:"undefined",f:function(n){return void 0===n},s:"be undefined"},{n:"null",f:function(n){return null===n},s:"be null"},{n:"assigned",f:v,s:"be assigned"},{n:"primitive",f:function(n){var e;switch(n){case null:case void 0:case!1:case!0:return!0}return"string"==(e=typeof n)||"number"===e||m&&"symbol"===e},s:"be primitive type"},{n:"contains",f:P,s:"contain {e}"},{n:"in",f:function(n,e){return P(e,n)},s:"be in {e}"},{n:"containsKey",f:D,s:"contain key {e}"},{n:"keyIn",f:function(n,e){return D(e,n)},s:"be key in {e}"},{n:"zero",f:function(n){return 0===n},s:"be 0"},{n:"one",f:function(n){return 1===n},s:"be 1"},{n:"infinity",f:function(n){return n===p||n===y},s:"be infinity"},{n:"number",f:j,s:"be Number"},{n:"integer",f:E,s:"be integer"},{n:"float",f:function(n){return j(n)&&n%1!=0},s:"be non-integer number"},{n:"even",f:function(n){return"number"==typeof n&&n%2==0},s:"be even number"},{n:"odd",f:function(n){return E(n)&&n%2!=0},s:"be odd number"},{n:"greater",f:O,s:"be greater than {e}"},{n:"less",f:w,s:"be less than {e}"},{n:"between",f:function(n,e,t){if(e<t)return O(n,e)&&n<t;return w(n,e)&&t<n},s:"be between {e} and {e2}"},{n:"greaterOrEqual",f:S,s:"be greater than or equal to {e}"},{n:"lessOrEqual",f:k,s:"be less than or equal to {e}"},{n:"inRange",f:function(n,e,t){if(e<t)return S(n,e)&&n<=t;return k(n,e)&&t<=n},s:"be in the range {e} to {e2}"},{n:"positive",f:function(n){return O(n,0)},s:"be positive number"},{n:"negative",f:function(n){return w(n,0)},s:"be negative number"},{n:"string",f:I,s:"be String"},{n:"emptyString",f:function(n){return""===n},s:"be empty string"},{n:"nonEmptyString",f:N,s:"be non-empty string"},{n:"match",f:function(n,e){return I(n)&&!!n.match(e)},s:"match {e}"},{n:"boolean",f:function(n){return!1===n||!0===n},s:"be Boolean"},{n:"object",f:A,s:"be Object"},{n:"emptyObject",f:function(n){return A(n)&&!q(n,function(){return!0})},s:"be empty object"},{n:"nonEmptyObject",f:function(n){return A(n)&&q(n,function(){return!0})},s:"be non-empty object"},{n:"instanceStrict",f:x,s:"be instanceof {t}"},{n:"thenable",f:function(n){return v(n)&&M(n.then)},s:"be a promise"},{n:"instance",f:function(n,e){try{return x(n,e)||n.constructor.name===e.name||a.call(n)==="[object "+e.name+"]"}catch(n){return!1}},s:"be {t}"},{n:"like",f:T,s:"be like {e}"},{n:"array",f:function(n){return b(n)},s:"be Array"},{n:"emptyArray",f:function(n){return b(n)&&0===n.length},s:"be empty array"},{n:"nonEmptyArray",f:function(n){return b(n)&&0<n.length},s:"be non-empty array"},{n:"arrayLike",f:F,s:"be array-like"},{n:"iterable",f:L,s:"be iterable"},{n:"date",f:function(n){return x(n,Date)&&E(n.getTime())},s:"be valid Date"},{n:"function",f:M,s:"be Function"},{n:"hasLength",f:function(n,e){return v(n)&&n.length===e},s:"have length {e}"},{n:"throws",f:function(n){if(!M(n))return!1;try{n()}catch(n){return!0}return!1},s:"throw"}].map(function(n){var e=n.n;i[e]="assert failed: expected {a} to "+n.s,r[e]=n.f}),e={map:function e(r,t){var u;u=b(r)?[]:{};if(M(t))R(r,function(n,e){u[n]=t(e)});else{b(t)||f.object(t);var o=l(r||{});R(t,function(t,n){o.some(function(n,e){return n===t&&(o.splice(e,1),!0)}),M(n)?c.assigned(r)?u[t]=!!n.m:u[t]=n(r[t]):u[t]=e(r[t],n)})}return u},all:function(n){if(b(n))return V(n,!1);return f.object(n),Y(n,!1)},any:function(n){if(b(n))return V(n,!0);return f.object(n),Y(n,!0)}},u=["array","arrayLike","iterable","object"],o=Object.prototype.hasOwnProperty,a=Object.prototype.toString,l=Object.keys,s=Array.prototype.slice,b=Array.isArray,p=Number.NEGATIVE_INFINITY,y=Number.POSITIVE_INFINITY,m="function"==typeof Symbol,h="function"==typeof Map,g="function"==typeof Set,e=_(e,r),f=J(z,G),c=J(K,C),t=J(function(n){var e=function(){return!!c.assigned(arguments[0])||n.apply(null,arguments)};return e.l=n.length,e.m=!0,e},function(n){return!1===v(n)||n}),f.not=U(z,c,"not "),f.maybe=U(z,t,"maybe "),u.forEach(function(n){r[n].of=Q([H.bind(null,null),r[n],r,{},""])}),W(f,z),W(c,K),u.forEach(function(n){t[n].of=Q([H.bind(null,"maybe"),r[n],r,{},""]),f.maybe[n].of=U(z,t[n].of),f.not[n].of=U(z,c[n].of)}),d=_(e,{assert:f,not:c,maybe:t}),"function"==typeof define&&define.amd?define(function(){return d}):"undefined"!=typeof module&&null!==module&&module.exports?module.exports=d:n.check=d}(this); | ||
!function(n){"use strict";var i,r,e,f,c,t,u,o,a,l,s,b,p,y,m,h,g,d;function v(n){return null!=n}function j(n){return"number"==typeof n&&p<n&&n<y}function E(n){return"number"==typeof n&&n%1==0}function O(n,e){return j(n)&&e<n}function w(n,e){return j(n)&&n<e}function k(n,e){return j(n)&&e<=n}function S(n,e){return j(n)&&n<=e}function I(n){return"string"==typeof n}function N(n){return I(n)&&""!==n}function A(n){return"[object Object]"===a.call(n)}function q(n,e){for(var t in n)if(o.call(n,t)&&e(t,n[t]))return!0;return!1}function x(n,e){try{return n instanceof e}catch(n){return!1}}function T(n,e){var t;for(t in e)if(o.call(e,t)){if(!1===o.call(n,t)||typeof n[t]!=typeof e[t])return!1;if(A(n[t])&&!1===T(n[t],e[t]))return!1}return!0}function F(n){return v(n)&&0<=n.length}function L(n){return m?v(n)&&M(n[Symbol.iterator]):F(n)}function P(n,t){var e,r;if(!v(n))return!1;if(g&&x(n,Set))return n.has(t);if(I(n))return-1!==n.indexOf(t);if(m&&n[Symbol.iterator]&&M(n.values)){e=n.values();do{if((r=e.next()).value===t)return!0}while(!r.done);return!1}return q(n,function(n,e){return e===t})}function D(n,e){return!!v(n)&&(h&&x(n,Map)?n.has(e):!(L(n)&&!j(+e))&&!!n[e])}function M(n){return"function"==typeof n}function R(n,e){for(var t in n)o.call(n,t)&&e(t,n[t])}function V(n,e){var t;for(t=0;t<n.length;t+=1)if(n[t]===e)return e;return!e}function Y(n,e){var t,r;for(t in n)if(o.call(n,t)){if(A(r=n[t])&&Y(r,e)===e)return e;if(r===e)return e}return!e}function _(t,n){return R(n,function(n,e){t[n]=e}),t}function z(u,o){return function(){var e=arguments,n=u.l||u.length,t=e[n],r=e[n+1];return G(u.apply(null,e),N(t)?t:o.replace("{a}",B(e[0])).replace("{e}",B(e[1])).replace("{e2}",B(e[2])).replace("{t}",function(){var n=e[1];return n&&n.name?n.name:n}),M(r)?r:TypeError),e[0]}}function B(n){return function(){return I(n)?'"'+n.replace(/\\/g,"\\\\").replace(/"/g,'\\"')+'"':n&&n.constructor&&!x(n,RegExp)&&"number"!=typeof n?n.constructor.name:n}}function G(n,e,t){if(n)return n;throw new(t||Error)(e||"assert failed")}function K(n){var e=function(){return C(n.apply(null,arguments))};return e.l=n.length,e}function C(n){return!n}function H(t,r,u){var n=function(){var n,e;if(n=arguments[0],"maybe"===t&&c.assigned(n))return!0;if(!r(n))return!1;n=function(n,e){switch(n){case F:return s.call(e);case A:return l(e).map(function(n){return e[n]});default:return e}}(r,n),e=s.call(arguments,1);try{n.forEach(function(n){if(("maybe"!==t||v(n))&&!u.apply(null,[n].concat(e)))throw 0})}catch(n){return!1}return!0};return n.l=u.length,n}function J(n,e){return Q([n,r,e,""])}function Q(r){var u,o,f;return u=r.shift(),o=r.pop(),f=r.pop(),R(r.pop(),function(n,e){var t=i[n];t&&o&&(t=t.replace("to",o+"to")),Object.defineProperty(f,n,{configurable:!1,enumerable:!0,writable:!1,value:u.apply(null,r.concat(e,t))})}),f}function U(n,e,t){return Q([n,e,{},t])}function W(e,t){u.forEach(function(n){e[n].of=U(t,r[n].of)})}i={},r={},[{n:"equal",f:function(n,e){return n===e},s:"equal {e}"},{n:"undefined",f:function(n){return void 0===n},s:"be undefined"},{n:"null",f:function(n){return null===n},s:"be null"},{n:"assigned",f:v,s:"be assigned"},{n:"primitive",f:function(n){var e;switch(n){case null:case void 0:case!1:case!0:return!0}return"string"==(e=typeof n)||"number"===e||m&&"symbol"===e},s:"be primitive type"},{n:"contains",f:P,s:"contain {e}"},{n:"in",f:function(n,e){return P(e,n)},s:"be in {e}"},{n:"containsKey",f:D,s:"contain key {e}"},{n:"keyIn",f:function(n,e){return D(e,n)},s:"be key in {e}"},{n:"zero",f:function(n){return 0===n},s:"be 0"},{n:"one",f:function(n){return 1===n},s:"be 1"},{n:"infinity",f:function(n){return n===p||n===y},s:"be infinity"},{n:"number",f:j,s:"be Number"},{n:"integer",f:E,s:"be integer"},{n:"float",f:function(n){return j(n)&&n%1!=0},s:"be non-integer number"},{n:"even",f:function(n){return"number"==typeof n&&n%2==0},s:"be even number"},{n:"odd",f:function(n){return E(n)&&n%2!=0},s:"be odd number"},{n:"greater",f:O,s:"be greater than {e}"},{n:"less",f:w,s:"be less than {e}"},{n:"between",f:function(n,e,t){if(e<t)return O(n,e)&&n<t;return w(n,e)&&t<n},s:"be between {e} and {e2}"},{n:"greaterOrEqual",f:k,s:"be greater than or equal to {e}"},{n:"lessOrEqual",f:S,s:"be less than or equal to {e}"},{n:"inRange",f:function(n,e,t){if(e<t)return k(n,e)&&n<=t;return S(n,e)&&t<=n},s:"be in the range {e} to {e2}"},{n:"positive",f:function(n){return O(n,0)},s:"be positive number"},{n:"negative",f:function(n){return w(n,0)},s:"be negative number"},{n:"string",f:I,s:"be String"},{n:"emptyString",f:function(n){return""===n},s:"be empty string"},{n:"nonEmptyString",f:N,s:"be non-empty string"},{n:"match",f:function(n,e){return I(n)&&!!n.match(e)},s:"match {e}"},{n:"boolean",f:function(n){return!1===n||!0===n},s:"be Boolean"},{n:"object",f:A,s:"be Object"},{n:"emptyObject",f:function(n){return A(n)&&!q(n,function(){return!0})},s:"be empty object"},{n:"nonEmptyObject",f:function(n){return A(n)&&q(n,function(){return!0})},s:"be non-empty object"},{n:"instanceStrict",f:x,s:"be instanceof {t}"},{n:"thenable",f:function(n){return v(n)&&M(n.then)},s:"be promise-like"},{n:"instance",f:function(n,e){try{return x(n,e)||n.constructor.name===e.name||a.call(n)==="[object "+e.name+"]"}catch(n){return!1}},s:"be {t}"},{n:"like",f:T,s:"be like {e}"},{n:"array",f:function(n){return b(n)},s:"be Array"},{n:"emptyArray",f:function(n){return b(n)&&0===n.length},s:"be empty array"},{n:"nonEmptyArray",f:function(n){return b(n)&&0<n.length},s:"be non-empty array"},{n:"arrayLike",f:F,s:"be array-like"},{n:"iterable",f:L,s:"be iterable"},{n:"date",f:function(n){return x(n,Date)&&E(n.getTime())},s:"be valid Date"},{n:"function",f:M,s:"be Function"},{n:"hasLength",f:function(n,e){return v(n)&&n.length===e},s:"have length {e}"},{n:"throws",f:function(n){if(!M(n))return!1;try{n()}catch(n){return!0}return!1},s:"throw"}].map(function(n){var e=n.n;i[e]="assert failed: expected {a} to "+n.s,r[e]=n.f}),e={map:function e(r,t){var u;u=b(r)?[]:{};if(M(t))R(r,function(n,e){u[n]=t(e)});else{b(t)||f.object(t);var o=l(r||{});R(t,function(t,n){o.some(function(n,e){return n===t&&(o.splice(e,1),!0)}),M(n)?c.assigned(r)?u[t]=!!n.m:u[t]=n(r[t]):u[t]=e(r[t],n)})}return u},all:function(n){if(b(n))return V(n,!1);return f.object(n),Y(n,!1)},any:function(n){if(b(n))return V(n,!0);return f.object(n),Y(n,!0)}},u=["array","arrayLike","iterable","object"],o=Object.prototype.hasOwnProperty,a=Object.prototype.toString,l=Object.keys,s=Array.prototype.slice,b=Array.isArray,p=Number.NEGATIVE_INFINITY,y=Number.POSITIVE_INFINITY,m="function"==typeof Symbol,h="function"==typeof Map,g="function"==typeof Set,e=_(e,r),f=J(z,G),c=J(K,C),t=J(function(n){var e=function(){return!!c.assigned(arguments[0])||n.apply(null,arguments)};return e.l=n.length,e.m=!0,e},function(n){return!1===v(n)||n}),f.not=U(z,c,"not "),f.maybe=U(z,t,"maybe "),u.forEach(function(n){r[n].of=Q([H.bind(null,null),r[n],r,{},""])}),W(f,z),W(c,K),u.forEach(function(n){t[n].of=Q([H.bind(null,"maybe"),r[n],r,{},""]),f.maybe[n].of=U(z,t[n].of),f.not[n].of=U(z,c[n].of)}),d=_(e,{assert:f,not:c,maybe:t}),"function"==typeof define&&define.amd?define(function(){return d}):"undefined"!=typeof module&&null!==module&&module.exports?module.exports=d:n.check=d}(this); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
63933