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 4.1.0 to 4.2.0

2

bower.json
{
"name": "check-types",
"version": "4.1.0",
"version": "4.2.0",
"main": "src/check-types.min.js",

@@ -5,0 +5,0 @@ "ignore": [

{
"name": "check-types",
"version": "4.1.0",
"version": "4.2.0",
"description": "A tiny library for asserting types and values.",

@@ -5,0 +5,0 @@ "repo": "philbooth/check-types.js",

# History
## 4.2
* Implement `includes`.
## 4.1

@@ -12,2 +16,3 @@

* Support derived error objects in `error`.
* Fix HTMLElement instance predicate bug in Safari.

@@ -14,0 +19,0 @@ ## 3.3

{
"name": "check-types",
"version": "4.1.0",
"version": "4.2.0",
"description": "A little library for asserting types and values.",

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

@@ -54,3 +54,3 @@ # check-types.js

23 kb unminified with comments, 5.8 kb minified, 2 kb minified + gzipped.
23 kb unminified with comments, 6.2 kb minified, 2.1 kb minified + gzipped.

@@ -347,2 +347,7 @@ ## How do I install it?

* `check.includes(thing, value)`:
Returns `true`
if `thing` includes `value`,
`false` otherwise.
* `check.arrayLike(thing)`:

@@ -349,0 +354,0 @@ Returns `true`

@@ -23,2 +23,3 @@ /*globals define, module, Symbol */

hasLength: 'Invalid length',
includes: 'Invalid value',
emptyArray: 'Invalid array',

@@ -61,2 +62,3 @@ array: 'Invalid array',

hasLength: hasLength,
includes: includes,
emptyArray: emptyArray,

@@ -240,2 +242,46 @@ array: array,

/**
* Public function `includes`.
*
* Returns `true` if something contains `value`,
* `false` otherwise.
*
*/
function includes (data, value) {
var iterator, iteration;
if (not.assigned(data)) {
return false;
}
try {
if (typeof Symbol !== 'undefined' && data[Symbol.iterator] && isFunction(data.values)) {
iterator = data.values();
do {
iteration = iterator.next();
if (iteration.value === value) {
return true;
}
} while (! iteration.done);
return false;
}
Object.keys(data).forEach(function (key) {
if (data[key] === value) {
throw 0;
}
});
} catch (ignore) {
if (ignore.stack) {
console.log(ignore.stack);
}
return true;
}
return false;
}
/**
* Public function `emptyArray`.

@@ -827,6 +873,3 @@ *

) {
// HACK: Ideally we'd use a for...of loop and return here,
// but that syntax is not supported by ES5. We could
// use a transpiler and a build step but I'm happy
// enough with this until ES6 is the baseline.
// TODO: Replace with for...of when ES6 is required.
throw 0;

@@ -833,0 +876,0 @@ }

@@ -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){return d(n)&&0===n.length}function d(n){return Array.isArray(n)}function s(n){return o(n)&&T(n.length)}function b(n){return"undefined"==typeof Symbol?s(n):o(n)&&p(n[Symbol.iterator])}function y(n){return"[object Date]"===Object.prototype.toString.call(n)&&!isNaN(n.getTime())}function v(n){return n instanceof Error||"[object Error]"===Object.prototype.toString.call(n)}function p(n){return"function"==typeof n}function m(n,r){return h(n)&&!!n.match(r)}function g(n,r){return h(n)&&-1!==n.indexOf(r)}function I(n){return h(n)&&""!==n}function h(n){return"string"==typeof n}function j(n){return E(n)&&!O(n)}function O(n){return T(n)&&n%2===0}function E(n){return T(n)&&n%1===0}function k(n,r,t){return t>r?w(n,r)&&N(n,t):N(n,r)&&w(n,t)}function w(n,r){return T(n)&&n>=r}function N(n,r){return T(n)&&r>=n}function S(n,r,t){return t>r?A(n,r)&&q(n,t):q(n,r)&&A(n,t)}function A(n,r){return T(n)&&n>r}function q(n,r){return T(n)&&r>n}function L(n){return A(n,0)}function P(n){return q(n,0)}function T(n){return"number"==typeof n&&isNaN(n)===!1&&n!==Number.POSITIVE_INFINITY&&n!==Number.NEGATIVE_INFINITY}function _(n){return 0===n}function x(n){return n===!1||n===!0}function z(n,r){return dr.array(n),p(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 F(n,r){return dr.object(n),p(r)?M(n,r):(dr.object(r),R(n,r))}function M(n,r){var t={};return Object.keys(n).forEach(function(e){t[e]=r(n[e])}),t}function R(n,r){var t={};return Object.keys(r).forEach(function(e){var u=r[e];p(u)?t[e]=sr.assigned(n)?!!u._isMaybefied:u(n[e]):i(u)&&(t[e]=R(n[e],u))}),t}function V(n){return d(n)?Y(n,!1):(dr.object(n),D(n,!1))}function Y(n,r){var t;for(t=0;t<n.length;t+=1)if(n[t]===r)return r;return!r}function D(n,r){var t,e;for(t in n)if(n.hasOwnProperty(t)){if(e=n[t],i(e)&&D(e,r)===r)return r;if(e===r)return r}return!r}function G(n){return d(n)?Y(n,!0):(dr.object(n),D(n,!0))}function B(n,r){return Object.keys(r).forEach(function(t){n[t]=r[t]}),n}function C(n,r){return function(){H(n,arguments,r)}}function H(n,r,t){var e=r[r.length-1];J(n.apply(null,r),I(e)?e:t)}function J(n,r){if(n===!1)throw new Error(r||"Assertion failed")}function K(n,r){return function(){function t(n,r){return n[r]=function(){if(e&&!fr[r].apply(null,arguments))throw e},n}var e;try{H(n,arguments,r)}catch(u){e=u}return{or:Object.keys(fr).reduce(t,{})}}}function Q(n){return function(){return U(n.apply(null,arguments))}}function U(n){return!n}function W(n){var r=function(){return o(arguments[0])?n.apply(null,arguments):!0};return r._isMaybefied=!0,r}function X(n){return o(n)===!1?!0:n}function Z(n){function r(){return!0}return function(){function t(n,t){return n[t]=e?r:fr[t],n}var e=n.apply(null,arguments);return{or:Object.keys(fr).reduce(t,{})}}}function $(n,r,t){return function(){var e,u;if(e=arguments[0],!r(e))return!1;e=nr(r,e),u=pr.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 nr(n,r){switch(n){case s:return pr.call(r);case i:return Object.keys(r).map(function(n){return r[n]});default:return r}}function rr(n,r){return tr([n,fr,r])}function tr(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],cr[t]))})}),u}function er(n,r){return tr([n,r,null])}function ur(n){fr[n].of=tr([$.bind(null,null),fr[n],fr,null])}function ir(n,r){vr.forEach(function(t){n[t].of=er(r,fr[t].of)})}function or(n){br[n].of=tr([$.bind(null,"maybe"),fr[n],fr,null]),dr.maybe[n].of=er(C,br[n].of),dr.not[n].of=er(C,sr[n].of)}function ar(r){"function"==typeof define&&define.amd?define(function(){return r}):"undefined"!=typeof module&&null!==module&&module.exports?module.exports=r:n.check=r}var cr,fr,lr,dr,sr,br,yr,vr,pr;cr={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",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"},fr={equal:r,like:t,instance:e,emptyObject:u,object:i,assigned:o,undefined:a,"null":c,hasLength:f,emptyArray:l,array:d,arrayLike:s,iterable:b,date:y,error:v,"function":p,match:m,contains:g,nonEmptyString:I,string:h,odd:j,even:O,inRange:k,greaterOrEqual:w,lessOrEqual:N,between:S,greater:A,less:q,positive:L,negative:P,integer:E,zero:_,number:T,"boolean":x},lr={apply:z,map:F,all:V,any:G},vr=["array","arrayLike","iterable","object"],pr=Array.prototype.slice,lr=B(lr,fr),dr=rr(C,J),sr=rr(Q,U),br=rr(W,X),yr=rr(Z),dr.not=er(C,sr),dr.maybe=er(C,br),dr.either=er(K,fr),vr.forEach(ur),ir(dr,C),ir(sr,Q),vr.forEach(or),ar(B(lr,{assert:dr,not:sr,maybe:br,either:yr}))}(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(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);

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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