check-types
Advanced tools
Comparing version 4.2.0 to 4.3.0
{ | ||
"name": "check-types", | ||
"version": "4.2.0", | ||
"version": "4.3.0", | ||
"main": "src/check-types.min.js", | ||
@@ -5,0 +5,0 @@ "ignore": [ |
{ | ||
"name": "check-types", | ||
"version": "4.2.0", | ||
"version": "4.3.0", | ||
"description": "A tiny library for asserting types and values.", | ||
@@ -5,0 +5,0 @@ "repo": "philbooth/check-types.js", |
# History | ||
## 4.3 | ||
* Implement `isMap`. Thanks to [Ryan Temple][ryantemple]. | ||
## 4.2 | ||
@@ -126,2 +130,3 @@ | ||
[myitcv]: https://github.com/myitcv | ||
[ryantemple]: https://github.com/ryantemple | ||
{ | ||
"name": "check-types", | ||
"version": "4.2.0", | ||
"version": "4.3.0", | ||
"description": "A little library for asserting types and values.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/philbooth/check-types.js", |
@@ -65,2 +65,3 @@ /*globals define, module, Symbol */ | ||
arrayLike: arrayLike, | ||
isMap: isMap, | ||
iterable: iterable, | ||
@@ -275,5 +276,2 @@ date: date, | ||
} catch (ignore) { | ||
if (ignore.stack) { | ||
console.log(ignore.stack); | ||
} | ||
return true; | ||
@@ -319,4 +317,14 @@ } | ||
/** | ||
* Public function `iterable`. | ||
* Public function 'Map' | ||
* | ||
* Returns 'true' if something is a Map, | ||
* 'false' otherwise | ||
*/ | ||
function isMap (data) { | ||
return Object.prototype.toString.call(data) === '[object Map]'; | ||
} | ||
/** | ||
* Public function. | ||
* | ||
* Returns `true` something is an iterable, | ||
@@ -323,0 +331,0 @@ * `false` otherwise. |
@@ -1,1 +0,1 @@ | ||
!function(n){"use strict";function r(n,r){return n===r}function t(n,r){var e;for(e in r)if(r.hasOwnProperty(e)){if(n.hasOwnProperty(e)===!1||typeof n[e]!=typeof r[e])return!1;if(i(n[e])&&t(n[e],r[e])===!1)return!1}return!0}function e(n,r){try{return n instanceof r}catch(t){return!1}}function u(n){return i(n)&&0===Object.keys(n).length}function i(n){return"[object Object]"===Object.prototype.toString.call(n)}function o(n){return!a(n)&&!c(n)}function a(n){return void 0===n}function c(n){return null===n}function f(n,r){return o(n)&&n.length===r}function l(n,r){var t,e;if(yr.assigned(n))return!1;try{if("undefined"!=typeof Symbol&&n[Symbol.iterator]&&m(n.values)){t=n.values();do if(e=t.next(),e.value===r)return!0;while(!e.done);return!1}Object.keys(n).forEach(function(t){if(n[t]===r)throw 0})}catch(u){return u.stack&&console.log(u.stack),!0}return!1}function s(n){return d(n)&&0===n.length}function d(n){return Array.isArray(n)}function y(n){return o(n)&&x(n.length)}function b(n){return"undefined"==typeof Symbol?y(n):o(n)&&m(n[Symbol.iterator])}function v(n){return"[object Date]"===Object.prototype.toString.call(n)&&!isNaN(n.getTime())}function p(n){return n instanceof Error||"[object Error]"===Object.prototype.toString.call(n)}function m(n){return"function"==typeof n}function g(n,r){return j(n)&&!!n.match(r)}function h(n,r){return j(n)&&-1!==n.indexOf(r)}function I(n){return j(n)&&""!==n}function j(n){return"string"==typeof n}function O(n){return k(n)&&!E(n)}function E(n){return x(n)&&n%2===0}function k(n){return x(n)&&n%1===0}function w(n,r,t){return t>r?N(n,r)&&S(n,t):S(n,r)&&N(n,t)}function N(n,r){return x(n)&&n>=r}function S(n,r){return x(n)&&r>=n}function A(n,r,t){return t>r?q(n,r)&&L(n,t):L(n,r)&&q(n,t)}function q(n,r){return x(n)&&n>r}function L(n,r){return x(n)&&r>n}function P(n){return q(n,0)}function T(n){return L(n,0)}function x(n){return"number"==typeof n&&isNaN(n)===!1&&n!==Number.POSITIVE_INFINITY&&n!==Number.NEGATIVE_INFINITY}function _(n){return 0===n}function z(n){return n===!1||n===!0}function F(n,r){return dr.array(n),m(r)?n.map(function(n){return r(n)}):(dr.array(r),dr.hasLength(n,r.length),n.map(function(n,t){return r[t](n)}))}function M(n,r){return dr.object(n),m(r)?R(n,r):(dr.object(r),V(n,r))}function R(n,r){var t={};return Object.keys(n).forEach(function(e){t[e]=r(n[e])}),t}function V(n,r){var t={};return Object.keys(r).forEach(function(e){var u=r[e];m(u)?t[e]=yr.assigned(n)?!!u._isMaybefied:u(n[e]):i(u)&&(t[e]=V(n[e],u))}),t}function Y(n){return d(n)?D(n,!1):(dr.object(n),G(n,!1))}function D(n,r){var t;for(t=0;t<n.length;t+=1)if(n[t]===r)return r;return!r}function G(n,r){var t,e;for(t in n)if(n.hasOwnProperty(t)){if(e=n[t],i(e)&&G(e,r)===r)return r;if(e===r)return r}return!r}function B(n){return d(n)?D(n,!0):(dr.object(n),G(n,!0))}function C(n,r){return Object.keys(r).forEach(function(t){n[t]=r[t]}),n}function H(n,r){return function(){J(n,arguments,r)}}function J(n,r,t){var e=r[r.length-1];K(n.apply(null,r),I(e)?e:t)}function K(n,r){if(n===!1)throw new Error(r||"Assertion failed")}function Q(n,r){return function(){function t(n,r){return n[r]=function(){if(e&&!lr[r].apply(null,arguments))throw e},n}var e;try{J(n,arguments,r)}catch(u){e=u}return{or:Object.keys(lr).reduce(t,{})}}}function U(n){return function(){return W(n.apply(null,arguments))}}function W(n){return!n}function X(n){var r=function(){return o(arguments[0])?n.apply(null,arguments):!0};return r._isMaybefied=!0,r}function Z(n){return o(n)===!1?!0:n}function $(n){function r(){return!0}return function(){function t(n,t){return n[t]=e?r:lr[t],n}var e=n.apply(null,arguments);return{or:Object.keys(lr).reduce(t,{})}}}function nr(n,r,t){return function(){var e,u;if(e=arguments[0],!r(e))return!1;e=rr(r,e),u=mr.call(arguments,1);try{e.forEach(function(r){if(("maybe"!==n||o(r))&&!t.apply(null,[r].concat(u)))throw 0})}catch(i){return!1}return!0}}function rr(n,r){switch(n){case y:return mr.call(r);case i:return Object.keys(r).map(function(n){return r[n]});default:return r}}function tr(n,r){return er([n,lr,r])}function er(n){var r,t,e,u;return r=n.shift(),t=n.pop(),e=n.pop(),u=t||{},Object.keys(e).forEach(function(t){Object.defineProperty(u,t,{configurable:!1,enumerable:!0,writable:!1,value:r.apply(null,n.concat(e[t],fr[t]))})}),u}function ur(n,r){return er([n,r,null])}function ir(n){lr[n].of=er([nr.bind(null,null),lr[n],lr,null])}function or(n,r){pr.forEach(function(t){n[t].of=ur(r,lr[t].of)})}function ar(n){br[n].of=er([nr.bind(null,"maybe"),lr[n],lr,null]),dr.maybe[n].of=ur(H,br[n].of),dr.not[n].of=ur(H,yr[n].of)}function cr(r){"function"==typeof define&&define.amd?define(function(){return r}):"undefined"!=typeof module&&null!==module&&module.exports?module.exports=r:n.check=r}var fr,lr,sr,dr,yr,br,vr,pr,mr;fr={equal:"Invalid value",like:"Invalid type",instance:"Invalid type",emptyObject:"Invalid object",object:"Invalid object",assigned:"Invalid value",undefined:"Invalid value","null":"Invalid value",hasLength:"Invalid length",includes:"Invalid value",emptyArray:"Invalid array",array:"Invalid array",arrayLike:"Invalid array-like object",iterable:"Invalid iterable",date:"Invalid date",error:"Invalid error","function":"Invalid function",match:"Invalid string",contains:"Invalid string",nonEmptyString:"Invalid string",string:"Invalid string",odd:"Invalid number",even:"Invalid number",inRange:"Invalid number",greaterOrEqual:"Invalid number",lessOrEqual:"Invalid number",between:"Invalid number",greater:"Invalid number",less:"Invalid number",positive:"Invalid number",negative:"Invalid number",integer:"Invalid number",zero:"Invalid number",number:"Invalid number","boolean":"Invalid boolean"},lr={equal:r,like:t,instance:e,emptyObject:u,object:i,assigned:o,undefined:a,"null":c,hasLength:f,includes:l,emptyArray:s,array:d,arrayLike:y,iterable:b,date:v,error:p,"function":m,match:g,contains:h,nonEmptyString:I,string:j,odd:O,even:E,inRange:w,greaterOrEqual:N,lessOrEqual:S,between:A,greater:q,less:L,positive:P,negative:T,integer:k,zero:_,number:x,"boolean":z},sr={apply:F,map:M,all:Y,any:B},pr=["array","arrayLike","iterable","object"],mr=Array.prototype.slice,sr=C(sr,lr),dr=tr(H,K),yr=tr(U,W),br=tr(X,Z),vr=tr($),dr.not=ur(H,yr),dr.maybe=ur(H,br),dr.either=ur(Q,lr),pr.forEach(ir),or(dr,H),or(yr,U),pr.forEach(ar),cr(C(sr,{assert:dr,not:yr,maybe:br,either:vr}))}(this); | ||
!function(n){"use strict";function r(n,r){return n===r}function t(n,r){var e;for(e in r)if(r.hasOwnProperty(e)){if(n.hasOwnProperty(e)===!1||typeof n[e]!=typeof r[e])return!1;if(i(n[e])&&t(n[e],r[e])===!1)return!1}return!0}function e(n,r){try{return n instanceof r}catch(t){return!1}}function u(n){return i(n)&&0===Object.keys(n).length}function i(n){return"[object Object]"===Object.prototype.toString.call(n)}function o(n){return!a(n)&&!c(n)}function a(n){return void 0===n}function c(n){return null===n}function f(n,r){return o(n)&&n.length===r}function l(n,r){var t,e;if(br.assigned(n))return!1;try{if("undefined"!=typeof Symbol&&n[Symbol.iterator]&&g(n.values)){t=n.values();do if(e=t.next(),e.value===r)return!0;while(!e.done);return!1}Object.keys(n).forEach(function(t){if(n[t]===r)throw 0})}catch(u){return!0}return!1}function d(n){return s(n)&&0===n.length}function s(n){return Array.isArray(n)}function y(n){return o(n)&&M(n.length)}function b(n){return"[object Map]"===Object.prototype.toString.call(n)}function v(n){return"undefined"==typeof Symbol?y(n):o(n)&&g(n[Symbol.iterator])}function p(n){return"[object Date]"===Object.prototype.toString.call(n)&&!isNaN(n.getTime())}function m(n){return n instanceof Error||"[object Error]"===Object.prototype.toString.call(n)}function g(n){return"function"==typeof n}function h(n,r){return O(n)&&!!n.match(r)}function I(n,r){return O(n)&&-1!==n.indexOf(r)}function j(n){return O(n)&&""!==n}function O(n){return"string"==typeof n}function E(n){return w(n)&&!k(n)}function k(n){return M(n)&&n%2===0}function w(n){return M(n)&&n%1===0}function N(n,r,t){return t>r?S(n,r)&&A(n,t):A(n,r)&&S(n,t)}function S(n,r){return M(n)&&n>=r}function A(n,r){return M(n)&&r>=n}function q(n,r,t){return t>r?L(n,r)&&P(n,t):P(n,r)&&L(n,t)}function L(n,r){return M(n)&&n>r}function P(n,r){return M(n)&&r>n}function T(n){return L(n,0)}function x(n){return P(n,0)}function M(n){return"number"==typeof n&&isNaN(n)===!1&&n!==Number.POSITIVE_INFINITY&&n!==Number.NEGATIVE_INFINITY}function _(n){return 0===n}function z(n){return n===!1||n===!0}function F(n,r){return yr.array(n),g(r)?n.map(function(n){return r(n)}):(yr.array(r),yr.hasLength(n,r.length),n.map(function(n,t){return r[t](n)}))}function R(n,r){return yr.object(n),g(r)?V(n,r):(yr.object(r),Y(n,r))}function V(n,r){var t={};return Object.keys(n).forEach(function(e){t[e]=r(n[e])}),t}function Y(n,r){var t={};return Object.keys(r).forEach(function(e){var u=r[e];g(u)?t[e]=br.assigned(n)?!!u._isMaybefied:u(n[e]):i(u)&&(t[e]=Y(n[e],u))}),t}function D(n){return s(n)?G(n,!1):(yr.object(n),B(n,!1))}function G(n,r){var t;for(t=0;t<n.length;t+=1)if(n[t]===r)return r;return!r}function B(n,r){var t,e;for(t in n)if(n.hasOwnProperty(t)){if(e=n[t],i(e)&&B(e,r)===r)return r;if(e===r)return r}return!r}function C(n){return s(n)?G(n,!0):(yr.object(n),B(n,!0))}function H(n,r){return Object.keys(r).forEach(function(t){n[t]=r[t]}),n}function J(n,r){return function(){K(n,arguments,r)}}function K(n,r,t){var e=r[r.length-1];Q(n.apply(null,r),j(e)?e:t)}function Q(n,r){if(n===!1)throw new Error(r||"Assertion failed")}function U(n,r){return function(){function t(n,r){return n[r]=function(){if(e&&!dr[r].apply(null,arguments))throw e},n}var e;try{K(n,arguments,r)}catch(u){e=u}return{or:Object.keys(dr).reduce(t,{})}}}function W(n){return function(){return X(n.apply(null,arguments))}}function X(n){return!n}function Z(n){var r=function(){return o(arguments[0])?n.apply(null,arguments):!0};return r._isMaybefied=!0,r}function $(n){return o(n)===!1?!0:n}function nr(n){function r(){return!0}return function(){function t(n,t){return n[t]=e?r:dr[t],n}var e=n.apply(null,arguments);return{or:Object.keys(dr).reduce(t,{})}}}function rr(n,r,t){return function(){var e,u;if(e=arguments[0],!r(e))return!1;e=tr(r,e),u=gr.call(arguments,1);try{e.forEach(function(r){if(("maybe"!==n||o(r))&&!t.apply(null,[r].concat(u)))throw 0})}catch(i){return!1}return!0}}function tr(n,r){switch(n){case y:return gr.call(r);case i:return Object.keys(r).map(function(n){return r[n]});default:return r}}function er(n,r){return ur([n,dr,r])}function ur(n){var r,t,e,u;return r=n.shift(),t=n.pop(),e=n.pop(),u=t||{},Object.keys(e).forEach(function(t){Object.defineProperty(u,t,{configurable:!1,enumerable:!0,writable:!1,value:r.apply(null,n.concat(e[t],lr[t]))})}),u}function ir(n,r){return ur([n,r,null])}function or(n){dr[n].of=ur([rr.bind(null,null),dr[n],dr,null])}function ar(n,r){mr.forEach(function(t){n[t].of=ir(r,dr[t].of)})}function cr(n){vr[n].of=ur([rr.bind(null,"maybe"),dr[n],dr,null]),yr.maybe[n].of=ir(J,vr[n].of),yr.not[n].of=ir(J,br[n].of)}function fr(r){"function"==typeof define&&define.amd?define(function(){return r}):"undefined"!=typeof module&&null!==module&&module.exports?module.exports=r:n.check=r}var lr,dr,sr,yr,br,vr,pr,mr,gr;lr={equal:"Invalid value",like:"Invalid type",instance:"Invalid type",emptyObject:"Invalid object",object:"Invalid object",assigned:"Invalid value",undefined:"Invalid value","null":"Invalid value",hasLength:"Invalid length",includes:"Invalid value",emptyArray:"Invalid array",array:"Invalid array",arrayLike:"Invalid array-like object",iterable:"Invalid iterable",date:"Invalid date",error:"Invalid error","function":"Invalid function",match:"Invalid string",contains:"Invalid string",nonEmptyString:"Invalid string",string:"Invalid string",odd:"Invalid number",even:"Invalid number",inRange:"Invalid number",greaterOrEqual:"Invalid number",lessOrEqual:"Invalid number",between:"Invalid number",greater:"Invalid number",less:"Invalid number",positive:"Invalid number",negative:"Invalid number",integer:"Invalid number",zero:"Invalid number",number:"Invalid number","boolean":"Invalid boolean"},dr={equal:r,like:t,instance:e,emptyObject:u,object:i,assigned:o,undefined:a,"null":c,hasLength:f,includes:l,emptyArray:d,array:s,arrayLike:y,isMap:b,iterable:v,date:p,error:m,"function":g,match:h,contains:I,nonEmptyString:j,string:O,odd:E,even:k,inRange:N,greaterOrEqual:S,lessOrEqual:A,between:q,greater:L,less:P,positive:T,negative:x,integer:w,zero:_,number:M,"boolean":z},sr={apply:F,map:R,all:D,any:C},mr=["array","arrayLike","iterable","object"],gr=Array.prototype.slice,sr=H(sr,dr),yr=er(J,Q),br=er(W,X),vr=er(Z,$),pr=er(nr),yr.not=ir(J,br),yr.maybe=ir(J,vr),yr.either=ir(U,dr),mr.forEach(or),ar(yr,J),ar(br,W),mr.forEach(cr),fr(H(sr,{assert:yr,not:br,maybe:vr,either:pr}))}(this); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
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
130198
2456