Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

check-types

Package Overview
Dependencies
Maintainers
1
Versions
90
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

check-types - npm Package Compare versions

Comparing version 7.2.0 to 7.2.1

5

HISTORY.md
# History
## 7.2.1
* fix: perf tweaks for tight loops (8a9919d)
* chore: update ci config (136f185)
## 7.2.0

@@ -4,0 +9,0 @@

2

package.json
{
"name": "check-types",
"version": "7.2.0",
"version": "7.2.1",
"description": "A little library for asserting types and values.",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/philbooth/check-types.js",

@@ -7,4 +7,4 @@ /*globals define, module, Symbol */

var strings, messages, predicates, functions,
assert, not, maybe, collections, slice;
var strings, messages, predicates, functions, assert, not, maybe,
collections, slice, neginf, posinf, isArray, haveSymbols;

@@ -84,2 +84,6 @@ strings = {

slice = Array.prototype.slice;
neginf = Number.NEGATIVE_INFINITY;
posinf = Number.POSITIVE_INFINITY;
isArray = Array.isArray;
haveSymbols = typeof Symbol === 'function';

@@ -138,3 +142,3 @@ functions = mixin(functions, predicates);

function assigned (data) {
return ! isUndefined(data) && ! isNull(data);
return data !== undefined && data !== null;
}

@@ -157,3 +161,3 @@

function infinity (data) {
return data === Number.POSITIVE_INFINITY || data === Number.NEGATIVE_INFINITY;
return data === neginf || data === posinf;
}

@@ -167,6 +171,3 @@

function number (data) {
return typeof data === 'number' &&
isNaN(data) === false &&
data !== Number.POSITIVE_INFINITY &&
data !== Number.NEGATIVE_INFINITY;
return typeof data === 'number' && data > neginf && data < posinf;
}

@@ -180,3 +181,3 @@

function integer (data) {
return number(data) && data % 1 === 0;
return typeof data === 'number' && data % 1 === 0;
}

@@ -190,3 +191,3 @@

function even (data) {
return number(data) && data % 2 === 0;
return typeof data === 'number' && data % 2 === 0;
}

@@ -200,3 +201,3 @@

function odd (data) {
return integer(data) && !even(data);
return integer(data) && data % 2 !== 0;
}

@@ -229,6 +230,6 @@

if (x < y) {
return greater(data, x) && less(data, y);
return greater(data, x) && data < y;
}
return less(data, x) && greater(data, y);
return less(data, x) && data > y;
}

@@ -263,6 +264,6 @@

if (x < y) {
return greaterOrEqual(data, x) && lessOrEqual(data, y);
return greaterOrEqual(data, x) && data <= y;
}
return lessOrEqual(data, x) && greaterOrEqual(data, y);
return lessOrEqual(data, x) && data >= y;
}

@@ -430,3 +431,3 @@

function array (data) {
return Array.isArray(data);
return isArray(data);
}

@@ -449,3 +450,3 @@

function nonEmptyArray (data) {
return array(data) && data.length > 0;
return array(data) && greater(data.length, 0);
}

@@ -459,3 +460,3 @@

function arrayLike (data) {
return assigned(data) && number(data.length);
return assigned(data) && greaterOrEqual(data.length, 0);
}

@@ -469,3 +470,3 @@

function iterable (data) {
if (typeof Symbol === 'undefined') {
if (! haveSymbols) {
// Fall back to `arrayLike` predicate in pre-ES6 environments.

@@ -484,30 +485,28 @@ return arrayLike(data);

function includes (data, value) {
var iterator, iteration;
var iterator, iteration, keys, length, i;
if (not.assigned(data)) {
if (! assigned(data)) {
return false;
}
try {
if (typeof Symbol !== 'undefined' && data[Symbol.iterator] && isFunction(data.values)) {
iterator = data.values();
if (haveSymbols && data[Symbol.iterator] && isFunction(data.values)) {
iterator = data.values();
do {
iteration = iterator.next();
do {
iteration = iterator.next();
if (iteration.value === value) {
return true;
}
} while (! iteration.done);
if (iteration.value === value) {
return true;
}
} while (! iteration.done);
return false;
return false;
}
keys = Object.keys(data);
length = keys.length;
for (i = 0; i < length; ++i) {
if (data[keys[i]] === value) {
return true;
}
Object.keys(data).forEach(function (key) {
if (data[key] === value) {
throw 0;
}
});
} catch (ignore) {
return true;
}

@@ -534,7 +533,3 @@

function date (data) {
try {
return instance(data, Date) && integer(data.getTime());
} catch (error) {
return false;
}
return instanceStrict(data, Date) && integer(data.getTime());
}

@@ -541,0 +536,0 @@

@@ -1,1 +0,1 @@

!function(n){"use strict";function t(n,t){return n===t}function r(n){return void 0===n}function e(n){return null===n}function u(n){return!r(n)&&!e(n)}function f(n){return 0===n}function o(n){return n===Number.POSITIVE_INFINITY||n===Number.NEGATIVE_INFINITY}function i(n){return"number"==typeof n&&isNaN(n)===!1&&n!==Number.POSITIVE_INFINITY&&n!==Number.NEGATIVE_INFINITY}function c(n){return i(n)&&n%1===0}function a(n){return i(n)&&n%2===0}function l(n){return c(n)&&!a(n)}function s(n,t){return i(n)&&n>t}function y(n,t){return i(n)&&n<t}function b(n,t,r){return t<r?s(n,t)&&y(n,r):y(n,t)&&s(n,r)}function p(n,t){return i(n)&&n>=t}function h(n,t){return i(n)&&n<=t}function m(n,t,r){return t<r?p(n,t)&&h(n,r):h(n,t)&&p(n,r)}function d(n){return s(n,0)}function g(n){return y(n,0)}function v(n){return"string"==typeof n}function j(n){return""===n}function E(n){return v(n)&&""!==n}function O(n,t){return v(n)&&n.indexOf(t)!==-1}function I(n,t){return v(n)&&!!n.match(t)}function N(n){return n===!1||n===!0}function k(n){return"[object Object]"===Object.prototype.toString.call(n)}function w(n){return k(n)&&0===Object.keys(n).length}function S(n){return k(n)&&Object.keys(n).length>0}function T(n,t){try{return n instanceof t}catch(n){return!1}}function A(n,t){try{return T(n,t)||n.constructor.name===t.name||Object.prototype.toString.call(n)==="[object "+t.name+"]"}catch(n){return!1}}function P(n,t){var r;for(r in t)if(t.hasOwnProperty(r)){if(n.hasOwnProperty(r)===!1||typeof n[r]!=typeof t[r])return!1;if(k(n[r])&&P(n[r],t[r])===!1)return!1}return!0}function x(n){return Array.isArray(n)}function F(n){return x(n)&&0===n.length}function L(n){return x(n)&&n.length>0}function V(n){return u(n)&&i(n.length)}function Y(n){return"undefined"==typeof Symbol?V(n):u(n)&&z(n[Symbol.iterator])}function _(n,t){var r,e;if(dn.assigned(n))return!1;try{if("undefined"!=typeof Symbol&&n[Symbol.iterator]&&z(n.values)){r=n.values();do if(e=r.next(),e.value===t)return!0;while(!e.done);return!1}Object.keys(n).forEach(function(r){if(n[r]===t)throw 0})}catch(n){return!0}return!1}function q(n,t){return u(n)&&n.length===t}function G(n){try{return A(n,Date)&&c(n.getTime())}catch(n){return!1}}function z(n){return"function"==typeof n}function D(n,t){return mn.array(n),z(t)?n.map(function(n){return t(n)}):(mn.array(t),mn.hasLength(n,t.length),n.map(function(n,r){return t[r](n)}))}function R(n,t){return mn.object(n),z(t)?B(n,t):(mn.object(t),C(n,t))}function B(n,t){var r={};return Object.keys(n).forEach(function(e){r[e]=t(n[e])}),r}function C(n,t){var r={};return Object.keys(t).forEach(function(e){var u=t[e];z(u)?dn.assigned(n)?r[e]=!!u.m:r[e]=u(n[e]):k(u)&&(r[e]=C(n[e],u))}),r}function H(n){return x(n)?J(n,!1):(mn.object(n),K(n,!1))}function J(n,t){var r;for(r=0;r<n.length;r+=1)if(n[r]===t)return t;return!t}function K(n,t){var r,e;for(r in n)if(n.hasOwnProperty(r)){if(e=n[r],k(e)&&K(e,t)===t)return t;if(e===t)return t}return!t}function M(n){return x(n)?J(n,!0):(mn.object(n),K(n,!0))}function Q(n,t){return Object.keys(t).forEach(function(r){n[r]=t[r]}),n}function U(n,t){return function(){return W(n,arguments,t)}}function W(n,t,r){var e=n.l||n.length,u=t[e],f=t[e+1];return X(n.apply(null,t),E(u)?u:r,z(f)?f:TypeError),t[0]}function X(n,t,r){if(n)return n;throw new(r||Error)(t||"Assertion failed")}function Z(n){var t=function(){return $(n.apply(null,arguments))};return t.l=n.length,t}function $(n){return!n}function nn(n){var t=function(){return!!dn.assigned(arguments[0])||n.apply(null,arguments)};return t.l=n.length,t.m=!0,t}function tn(n){return u(n)===!1||n}function rn(n,t,r){var e=function(){var e,f;if(e=arguments[0],"maybe"===n&&dn.assigned(e))return!0;if(!t(e))return!1;e=en(t,e),f=jn.call(arguments,1);try{e.forEach(function(t){if(("maybe"!==n||u(t))&&!r.apply(null,[t].concat(f)))throw 0})}catch(n){return!1}return!0};return e.l=r.length,e}function en(n,t){switch(n){case V:return jn.call(t);case k:return Object.keys(t).map(function(n){return t[n]});default:return t}}function un(n,t){return fn([n,pn,t])}function fn(n){var t,r,e,u;return t=n.shift(),r=n.pop(),e=n.pop(),u=r||{},Object.keys(e).forEach(function(r){Object.defineProperty(u,r,{configurable:!1,enumerable:!0,writable:!1,value:t.apply(null,n.concat(e[r],bn[r]))})}),u}function on(n,t){return fn([n,t,null])}function cn(n){pn[n].of=fn([rn.bind(null,null),pn[n],pn,null])}function an(n,t){vn.forEach(function(r){n[r].of=on(t,pn[r].of)})}function ln(n){gn[n].of=fn([rn.bind(null,"maybe"),pn[n],pn,null]),mn.maybe[n].of=on(U,gn[n].of),mn.not[n].of=on(U,dn[n].of)}function sn(t){"function"==typeof define&&define.amd?define(function(){return t}):"undefined"!=typeof module&&null!==module&&module.exports?module.exports=t:n.check=t}var yn,bn,pn,hn,mn,dn,gn,vn,jn;yn={v:"value",n:"number",s:"string",b:"boolean",o:"object",t:"type",a:"array",al:"array-like",i:"iterable",d:"date",f:"function",l:"length"},bn={},pn={},[{n:"equal",f:t,s:"v"},{n:"undefined",f:r,s:"v"},{n:"null",f:e,s:"v"},{n:"assigned",f:u,s:"v"},{n:"includes",f:_,s:"v"},{n:"zero",f:f},{n:"infinity",f:o},{n:"number",f:i},{n:"integer",f:c},{n:"even",f:a},{n:"odd",f:l},{n:"greater",f:s},{n:"less",f:y},{n:"between",f:b},{n:"greaterOrEqual",f:p},{n:"lessOrEqual",f:h},{n:"inRange",f:m},{n:"positive",f:d},{n:"negative",f:g},{n:"string",f:v,s:"s"},{n:"emptyString",f:j,s:"s"},{n:"nonEmptyString",f:E,s:"s"},{n:"contains",f:O,s:"s"},{n:"match",f:I,s:"s"},{n:"boolean",f:N,s:"b"},{n:"object",f:k,s:"o"},{n:"emptyObject",f:w,s:"o"},{n:"nonEmptyObject",f:S,s:"o"},{n:"instanceStrict",f:T,s:"t"},{n:"instance",f:A,s:"t"},{n:"like",f:P,s:"t"},{n:"array",f:x,s:"a"},{n:"emptyArray",f:F,s:"a"},{n:"nonEmptyArray",f:L,s:"a"},{n:"arrayLike",f:V,s:"al"},{n:"iterable",f:Y,s:"i"},{n:"date",f:G,s:"d"},{n:"function",f:z,s:"f"},{n:"hasLength",f:q,s:"l"}].map(function(n){var t=n.n;bn[t]="Invalid "+yn[n.s||"n"],pn[t]=n.f}),hn={apply:D,map:R,all:H,any:M},vn=["array","arrayLike","iterable","object"],jn=Array.prototype.slice,hn=Q(hn,pn),mn=un(U,X),dn=un(Z,$),gn=un(nn,tn),mn.not=on(U,dn),mn.maybe=on(U,gn),vn.forEach(cn),an(mn,U),an(dn,Z),vn.forEach(ln),sn(Q(hn,{assert:mn,not:dn,maybe:gn}))}(this);
!function(n){"use strict";function t(n,t){return n===t}function r(n){return void 0===n}function e(n){return null===n}function u(n){return void 0!==n&&null!==n}function f(n){return 0===n}function o(n){return n===On||n===En}function i(n){return"number"==typeof n&&n>On&&n<En}function c(n){return"number"==typeof n&&n%1===0}function a(n){return"number"==typeof n&&n%2===0}function l(n){return c(n)&&n%2!==0}function s(n,t){return i(n)&&n>t}function y(n,t){return i(n)&&n<t}function b(n,t,r){return t<r?s(n,t)&&n<r:y(n,t)&&n>r}function p(n,t){return i(n)&&n>=t}function h(n,t){return i(n)&&n<=t}function m(n,t,r){return t<r?p(n,t)&&n<=r:h(n,t)&&n>=r}function d(n){return s(n,0)}function g(n){return y(n,0)}function v(n){return"string"==typeof n}function j(n){return""===n}function O(n){return v(n)&&""!==n}function E(n,t){return v(n)&&n.indexOf(t)!==-1}function k(n,t){return v(n)&&!!n.match(t)}function w(n){return n===!1||n===!0}function I(n){return"[object Object]"===Object.prototype.toString.call(n)}function S(n){return I(n)&&0===Object.keys(n).length}function A(n){return I(n)&&Object.keys(n).length>0}function N(n,t){try{return n instanceof t}catch(n){return!1}}function T(n,t){try{return N(n,t)||n.constructor.name===t.name||Object.prototype.toString.call(n)==="[object "+t.name+"]"}catch(n){return!1}}function P(n,t){var r;for(r in t)if(t.hasOwnProperty(r)){if(n.hasOwnProperty(r)===!1||typeof n[r]!=typeof t[r])return!1;if(I(n[r])&&P(n[r],t[r])===!1)return!1}return!0}function x(n){return kn(n)}function L(n){return x(n)&&0===n.length}function q(n){return x(n)&&s(n.length,0)}function F(n){return u(n)&&p(n.length,0)}function V(n){return wn?u(n)&&D(n[Symbol.iterator]):F(n)}function Y(n,t){var r,e,f,o,i;if(!u(n))return!1;if(wn&&n[Symbol.iterator]&&D(n.values)){r=n.values();do if(e=r.next(),e.value===t)return!0;while(!e.done);return!1}for(f=Object.keys(n),o=f.length,i=0;i<o;++i)if(n[f[i]]===t)return!0;return!1}function _(n,t){return u(n)&&n.length===t}function z(n){return N(n,Date)&&c(n.getTime())}function D(n){return"function"==typeof n}function G(n,t){return mn.array(n),D(t)?n.map(function(n){return t(n)}):(mn.array(t),mn.hasLength(n,t.length),n.map(function(n,r){return t[r](n)}))}function R(n,t){return mn.object(n),D(t)?B(n,t):(mn.object(t),C(n,t))}function B(n,t){var r={};return Object.keys(n).forEach(function(e){r[e]=t(n[e])}),r}function C(n,t){var r={};return Object.keys(t).forEach(function(e){var u=t[e];D(u)?dn.assigned(n)?r[e]=!!u.m:r[e]=u(n[e]):I(u)&&(r[e]=C(n[e],u))}),r}function H(n){return x(n)?J(n,!1):(mn.object(n),K(n,!1))}function J(n,t){var r;for(r=0;r<n.length;r+=1)if(n[r]===t)return t;return!t}function K(n,t){var r,e;for(r in n)if(n.hasOwnProperty(r)){if(e=n[r],I(e)&&K(e,t)===t)return t;if(e===t)return t}return!t}function M(n){return x(n)?J(n,!0):(mn.object(n),K(n,!0))}function Q(n,t){return Object.keys(t).forEach(function(r){n[r]=t[r]}),n}function U(n,t){return function(){return W(n,arguments,t)}}function W(n,t,r){var e=n.l||n.length,u=t[e],f=t[e+1];return X(n.apply(null,t),O(u)?u:r,D(f)?f:TypeError),t[0]}function X(n,t,r){if(n)return n;throw new(r||Error)(t||"Assertion failed")}function Z(n){var t=function(){return $(n.apply(null,arguments))};return t.l=n.length,t}function $(n){return!n}function nn(n){var t=function(){return!!dn.assigned(arguments[0])||n.apply(null,arguments)};return t.l=n.length,t.m=!0,t}function tn(n){return u(n)===!1||n}function rn(n,t,r){var e=function(){var e,f;if(e=arguments[0],"maybe"===n&&dn.assigned(e))return!0;if(!t(e))return!1;e=en(t,e),f=jn.call(arguments,1);try{e.forEach(function(t){if(("maybe"!==n||u(t))&&!r.apply(null,[t].concat(f)))throw 0})}catch(n){return!1}return!0};return e.l=r.length,e}function en(n,t){switch(n){case F:return jn.call(t);case I:return Object.keys(t).map(function(n){return t[n]});default:return t}}function un(n,t){return fn([n,pn,t])}function fn(n){var t,r,e,u;return t=n.shift(),r=n.pop(),e=n.pop(),u=r||{},Object.keys(e).forEach(function(r){Object.defineProperty(u,r,{configurable:!1,enumerable:!0,writable:!1,value:t.apply(null,n.concat(e[r],bn[r]))})}),u}function on(n,t){return fn([n,t,null])}function cn(n){pn[n].of=fn([rn.bind(null,null),pn[n],pn,null])}function an(n,t){vn.forEach(function(r){n[r].of=on(t,pn[r].of)})}function ln(n){gn[n].of=fn([rn.bind(null,"maybe"),pn[n],pn,null]),mn.maybe[n].of=on(U,gn[n].of),mn.not[n].of=on(U,dn[n].of)}function sn(t){"function"==typeof define&&define.amd?define(function(){return t}):"undefined"!=typeof module&&null!==module&&module.exports?module.exports=t:n.check=t}var yn,bn,pn,hn,mn,dn,gn,vn,jn,On,En,kn,wn;yn={v:"value",n:"number",s:"string",b:"boolean",o:"object",t:"type",a:"array",al:"array-like",i:"iterable",d:"date",f:"function",l:"length"},bn={},pn={},[{n:"equal",f:t,s:"v"},{n:"undefined",f:r,s:"v"},{n:"null",f:e,s:"v"},{n:"assigned",f:u,s:"v"},{n:"includes",f:Y,s:"v"},{n:"zero",f:f},{n:"infinity",f:o},{n:"number",f:i},{n:"integer",f:c},{n:"even",f:a},{n:"odd",f:l},{n:"greater",f:s},{n:"less",f:y},{n:"between",f:b},{n:"greaterOrEqual",f:p},{n:"lessOrEqual",f:h},{n:"inRange",f:m},{n:"positive",f:d},{n:"negative",f:g},{n:"string",f:v,s:"s"},{n:"emptyString",f:j,s:"s"},{n:"nonEmptyString",f:O,s:"s"},{n:"contains",f:E,s:"s"},{n:"match",f:k,s:"s"},{n:"boolean",f:w,s:"b"},{n:"object",f:I,s:"o"},{n:"emptyObject",f:S,s:"o"},{n:"nonEmptyObject",f:A,s:"o"},{n:"instanceStrict",f:N,s:"t"},{n:"instance",f:T,s:"t"},{n:"like",f:P,s:"t"},{n:"array",f:x,s:"a"},{n:"emptyArray",f:L,s:"a"},{n:"nonEmptyArray",f:q,s:"a"},{n:"arrayLike",f:F,s:"al"},{n:"iterable",f:V,s:"i"},{n:"date",f:z,s:"d"},{n:"function",f:D,s:"f"},{n:"hasLength",f:_,s:"l"}].map(function(n){var t=n.n;bn[t]="Invalid "+yn[n.s||"n"],pn[t]=n.f}),hn={apply:G,map:R,all:H,any:M},vn=["array","arrayLike","iterable","object"],jn=Array.prototype.slice,On=Number.NEGATIVE_INFINITY,En=Number.POSITIVE_INFINITY,kn=Array.isArray,wn="function"==typeof Symbol,hn=Q(hn,pn),mn=un(U,X),dn=un(Z,$),gn=un(nn,tn),mn.not=on(U,dn),mn.maybe=on(U,gn),vn.forEach(cn),an(mn,U),an(dn,Z),vn.forEach(ln),sn(Q(hn,{assert:mn,not:dn,maybe:gn}))}(this);
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc