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.1.5 to 7.2.0

6

HISTORY.md
# History
## 7.2.0
* feature: return the target value from assertions (73da792)
* chore: add release script dependency (cacc348)
* fix: make assert throw for any falsy value (4f15c73)
## 7.1

@@ -4,0 +10,0 @@

5

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

@@ -35,3 +35,4 @@ "homepage": "https://github.com/philbooth/check-types.js",

"chai": "3.5.x",
"uglify-js": "2.7.x"
"uglify-js": "2.7.x",
"please-release-me": "1.0.x"
},

@@ -38,0 +39,0 @@ "scripts": {

@@ -148,4 +148,4 @@ # check-types.js

changes predicates
to throw when their result
would otherwise be `false`.
to throw when their result is `false`,
otherwise it returns `thing`.
It can be applied

@@ -490,3 +490,4 @@ to the `not` and `maybe` modifiers

Throws a `TypeError`
if `value` is `false`.
if `value` is *falsy*,
otherwise it returns `value`.
`message` and `ErrorType`

@@ -500,3 +501,4 @@ are optional arguments

Throws a `TypeError`
if the predicate returns false.
if the predicate returns false,
otherwise it returns the subject value.
The last two arguments

@@ -568,3 +570,3 @@ are an optional message and error type

check.assert.not.like({ foo: 'bar' }, { baz: 'qux' });
// Doesn't throw
// Doesn't throw, returns `{ foo: 'bar' }`
```

@@ -574,3 +576,3 @@

check.assert.maybe.like(undefined, { foo: 'bar' });
// Doesn't throw
// Doesn't throw, returns `undefined`
```

@@ -768,4 +770,5 @@

[Mocha],
[Chai] and
[UglifyJS].
[Chai],
[UglifyJS] and
[please-release-me].
Assuming that you already have Node.js and NPM set up,

@@ -798,3 +801,4 @@ you just need to run `npm install` to

[uglifyjs]: https://github.com/mishoo/UglifyJS
[please-release-me]: https://github.com/philbooth/please-release-me
[license]: https://github.com/philbooth/check-types.js/blob/master/COPYING

8

src/check-types.js

@@ -694,3 +694,3 @@ /*globals define, module, Symbol */

return function () {
assertPredicate(predicate, arguments, defaultMessage);
return assertPredicate(predicate, arguments, defaultMessage);
};

@@ -708,8 +708,10 @@ }

);
return args[0];
}
function assertImpl (value, message, ErrorType) {
if (value === false) {
throw new (ErrorType || Error)(message || 'Assertion failed');
if (value) {
return value;
}
throw new (ErrorType || Error)(message || 'Assertion failed');
}

@@ -716,0 +718,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(){W(n,arguments,t)}}function W(n,t,r){var e=n.l||n.length,u=t[e],f=t[e+1];X(n.apply(null,t),E(u)?u:r,z(f)?f:TypeError)}function X(n,t,r){if(n===!1)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!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);
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