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

check-more-types

Package Overview
Dependencies
Maintainers
3
Versions
81
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

check-more-types - npm Package Compare versions

Comparing version 2.3.0 to 2.4.0

39

check-more-types.js

@@ -17,2 +17,18 @@ (function checkMoreTypes() {

// utility method
function curry2(fn) {
return function curried(a) {
if (arguments.length > 2) {
throw new Error('Curry2 function ' + fn.name +
' called with too many arguments ' + arguments.length);
}
if (arguments.length === 2) {
return fn(arguments[0], arguments[1]);
}
return function second(b) {
return fn(a, b);
};
};
}
// most of the old methods from check-types.js

@@ -69,2 +85,11 @@ function isFn(x) { return typeof x === 'function'; }

/**
Checks if the type of second argument matches the name in the first
@method type
*/
function type(expectedType, x) {
return typeof x === expectedType;
}
var startsWithHttp = startsWith.bind(null, 'http://');

@@ -142,2 +167,12 @@ var startsWithHttps = startsWith.bind(null, 'https://');

/**
Checks if it is exact semver
@method semver
*/
function semver(s) {
return check.unemptyString(s) &&
/^\d+\.\d+\.\d+$/.test(s);
}
/**
Returns true if the argument is primitive JavaScript type

@@ -743,3 +778,5 @@

startsWith: startsWith,
webUrl: webUrl
webUrl: webUrl,
semver: semver,
type: curry2(type)
};

@@ -746,0 +783,0 @@

2

check-more-types.min.js

@@ -5,2 +5,2 @@ /*! check-more-types - v0.0.0

!function(){"use strict";function a(a){return"function"==typeof a}function b(a){return"string"==typeof a}function c(a){return b(a)&&a}function d(a){return"object"==typeof a&&!Array.isArray(a)&&!i(a)&&!l(a)}function e(a){return d(a)&&0===Object.keys(a).length}function f(a){return"number"==typeof a&&!isNaN(a)&&a!==1/0&&a!==-(1/0)}function g(a){return f(a)&&a%1===0}function h(a){return f(a)&&a%1!==0}function i(a){return null===a}function j(a){return f(a)&&a>0}function k(a){return f(a)&&0>a}function l(a){return a instanceof Date}function m(a,b){return a instanceof b}function n(a,c){return(Array.isArray(a)||b(a))&&a.length===c}function o(a,c){return b(a)&&b(c)&&0===c.indexOf(a)}function p(a){return b(a)&&($(a)||_(a))}function q(a){var b,c;for(b in a)if(a.hasOwnProperty(b)){if(c=a[b],d(c)&&q(c)===!1)return!1;if(c===!1)return!1}return!0}function r(b,c){var e,f,g={};for(e in c)c.hasOwnProperty(e)&&(f=c[e],a(f)?g[e]=f(b[e]):d(f)&&(g[e]=r(b[e],f)));return g}function s(a){return"undefined"!=typeof a}function t(a){return aa.date(a)&&aa.number(Number(a))}function u(a){var b=typeof a;return"number"===b||"boolean"===b||"string"===b}function v(a){return"number"==typeof a&&0===a}function w(a,b){return a===b}function x(a,b){return s(a)&&E(a,"length")&&b>=0&&b<a.length}function y(a,b){return typeof a==typeof b&&a&&b&&a.length===b.length}function z(a){if(!aa.array(a))return!1;if(!a.length)return!0;var b=a[0];return a.every(function(a){return a===b})}function A(a,b){return aa.verify.array(a,"expected an array"),-1!==a.indexOf(b)}function B(a){return aa.unemptyString(a)&&/^git@/.test(a)}function C(a){return 0===a||1===a}function D(a){return"boolean"==typeof a}function E(a,b){if(2!==arguments.length)throw new Error("Expected two arguments to check.has, got only "+arguments.length);return Boolean(a&&b&&"string"==typeof b&&"undefined"!=typeof a[b])}function F(a){return aa.string(a)&&a.toLowerCase()===a}function G(a){return aa.array(a)&&a.length>0}function H(a,b){return aa.array(b)&&b.every(a)}function I(a,b){return aa.verify.array(b,"expected array to find bad items"),b.filter(X(a))}function J(a,b){var c=aa.array(a)&&a.every(aa.string);return c&&aa.bool(b)&&b?a.every(aa.lowerCase):c}function K(a,b){return aa.array(a)&&a.every(function(a){return aa.arrayOfStrings(a,b)})}function L(a,b){return aa.verify.fn(aa.every,"missing check.every method"),aa.verify.fn(aa.map,"missing check.map method"),aa.verify.object(a,"missing object to check"),aa.verify.object(b,"missing predicates object"),Object.keys(b).forEach(function(a){if(!aa.fn(b[a]))throw new Error("not a predicate function for "+a+" but "+b[a])}),aa.every(aa.map(a,b))}function M(a,b){return L(b,a)}function N(a,b){aa.verify.fn(a,"expected function that raises");try{a()}catch(c){return"undefined"==typeof b?!0:"function"==typeof b?b(c):!1}return!1}function O(a){return""===a}function P(a){var b="string"==typeof a||Array.isArray(a);return b?!a.length:a instanceof Object?!Object.keys(a).length:!1}function Q(a){var b="string"==typeof a||Array.isArray(a);return b?a.length:a instanceof Object?Object.keys(a).length:!0}function R(a){return aa.number(a)&&a>=0&&1>=a}function S(a){return aa.string(a)&&ba.test(a)}function T(a){return aa.string(a)&&40===a.length&&ca.test(a)}function U(a){return aa.string(a)&&7===a.length&&da.test(a)}function V(){var a=Array.prototype.slice.call(arguments,0);if(!a.length)throw new Error("empty list of arguments to or");return function(){var b=Array.prototype.slice.call(arguments,0);return a.some(function(a){try{return aa.fn(a)?a.apply(null,b):Boolean(a)}catch(c){return!1}})}}function W(){var a=Array.prototype.slice.call(arguments,0);if(!a.length)throw new Error("empty list of arguments to or");return function(){var b=Array.prototype.slice.call(arguments,0);return a.every(function(a){return aa.fn(a)?a.apply(null,b):Boolean(a)})}}function X(a){return function(){return!a.apply(null,arguments)}}function Y(a){return aa.object(a)&&ga(a)}function Z(a,b){if(2===arguments.length)return a===b;if(1===arguments.length)return function(b){return a===b};throw new Error("Expected at least 1 or 2 arguments to check.equal")}if("function"!=typeof Function.prototype.bind)throw new Error("Missing Function.prototype.bind, please load es5-shim first");var $=o.bind(null,"http://"),_=o.bind(null,"https://"),aa={maybe:{},verify:{},not:{},every:q,map:r},ba=/^#(?:[0-9a-fA-F]{3}){1,2}$/,ca=/^[0-9a-f]{40}$/,da=/^[0-9a-f]{7}$/;if(!aa.defend){var ea=function(a,b,c){aa.verify.fn(a,"expected a function"),aa.verify.array(b,"expected list of predicates"),aa.verify.defined(c,"missing args");var d=0,e=0,f=b.length;for(d=0;f>d;d+=1){var g=b[d];if(aa.fn(g)){if(!g.call(null,c[e])){var h="Argument "+(e+1)+": "+c[e]+" does not pass predicate";throw aa.unemptyString(b[d+1])&&(h+=": "+b[d+1]),new Error(h)}e+=1}}return a.apply(null,c)};aa.defend=function(a){var b=Array.prototype.slice.call(arguments,1);return function(){return ea(a,b,arguments)}}}aa.mixin||(aa.mixin=function(e,f){function g(b,e,f){if(!d(b))throw new Error("missing object "+b);if(!c(e))throw new Error("missing name");if(!a(f))throw new Error("missing function");b[e]||(b[e]=f)}function h(a){return function(){return!aa.defined(arguments[0])||aa.nulled(arguments[0])?!0:a.apply(null,arguments)}}function i(a,b){return function(){var c;if(a.apply(null,arguments)===!1)throw c=arguments[arguments.length-1],new Error(aa.unemptyString(c)?c:b)}}if(b(e)&&a(f)){var j=e;e=f,f=j}if(!a(e))throw new Error("expected predicate function");if(c(f)||(f=e.name),!c(f))throw new Error("predicate function missing name\n"+e.toString());g(aa,f,e),g(aa.maybe,f,h(e)),g(aa.not,f,X(e)),g(aa.verify,f,i(e,f+" failed"))}),aa.then||(aa.then=function(a,b){return function(){var c="function"==typeof a?a.apply(null,arguments):a;return c?b.apply(null,arguments):void 0}});var fa={then:a};fa["catch"]=a,fa["finally"]=a;var ga=M.bind(null,fa),ha={nulled:i,fn:a,string:b,unemptyString:c,object:d,number:f,array:Array.isArray,positiveNumber:j,negativeNumber:k,defined:s,same:w,allSame:z,bit:C,bool:D,has:E,lowerCase:F,unemptyArray:G,arrayOfStrings:J,arrayOfArraysOfStrings:K,all:L,schema:M,raises:N,empty:P,emptyString:O,unempty:Q,unit:R,hexRgb:S,sameLength:y,commitId:T,shortCommitId:U,index:x,git:B,arrayOf:H,badItems:I,oneOf:A,promise:Y,validDate:t,equal:Z,or:V,and:W,primitive:u,zero:v,date:l,instance:m,emptyObject:e,length:n,floatNumber:h,intNumber:g,startsWith:o,webUrl:p};Object.keys(ha).forEach(function(a){aa.mixin(ha[a],a)}),"object"==typeof module&&(module.exports=aa),"object"==typeof window&&(window.check=aa),"object"==typeof global&&(global.check=aa)}();
!function(){"use strict";function a(a){return function(b){if(arguments.length>2)throw new Error("Curry2 function "+a.name+" called with too many arguments "+arguments.length);return 2===arguments.length?a(arguments[0],arguments[1]):function(c){return a(b,c)}}}function b(a){return"function"==typeof a}function c(a){return"string"==typeof a}function d(a){return c(a)&&a}function e(a){return"object"==typeof a&&!Array.isArray(a)&&!j(a)&&!m(a)}function f(a){return e(a)&&0===Object.keys(a).length}function g(a){return"number"==typeof a&&!isNaN(a)&&a!==1/0&&a!==-(1/0)}function h(a){return g(a)&&a%1===0}function i(a){return g(a)&&a%1!==0}function j(a){return null===a}function k(a){return g(a)&&a>0}function l(a){return g(a)&&0>a}function m(a){return a instanceof Date}function n(a,b){return a instanceof b}function o(a,b){return(Array.isArray(a)||c(a))&&a.length===b}function p(a,b){return c(a)&&c(b)&&0===b.indexOf(a)}function q(a,b){return typeof b===a}function r(a){return c(a)&&(ba(a)||ca(a))}function s(a){var b,c;for(b in a)if(a.hasOwnProperty(b)){if(c=a[b],e(c)&&s(c)===!1)return!1;if(c===!1)return!1}return!0}function t(a,c){var d,f,g={};for(d in c)c.hasOwnProperty(d)&&(f=c[d],b(f)?g[d]=f(a[d]):e(f)&&(g[d]=t(a[d],f)));return g}function u(a){return"undefined"!=typeof a}function v(a){return da.date(a)&&da.number(Number(a))}function w(a){return da.unemptyString(a)&&/^\d+\.\d+\.\d+$/.test(a)}function x(a){var b=typeof a;return"number"===b||"boolean"===b||"string"===b}function y(a){return"number"==typeof a&&0===a}function z(a,b){return a===b}function A(a,b){return u(a)&&H(a,"length")&&b>=0&&b<a.length}function B(a,b){return typeof a==typeof b&&a&&b&&a.length===b.length}function C(a){if(!da.array(a))return!1;if(!a.length)return!0;var b=a[0];return a.every(function(a){return a===b})}function D(a,b){return da.verify.array(a,"expected an array"),-1!==a.indexOf(b)}function E(a){return da.unemptyString(a)&&/^git@/.test(a)}function F(a){return 0===a||1===a}function G(a){return"boolean"==typeof a}function H(a,b){if(2!==arguments.length)throw new Error("Expected two arguments to check.has, got only "+arguments.length);return Boolean(a&&b&&"string"==typeof b&&"undefined"!=typeof a[b])}function I(a){return da.string(a)&&a.toLowerCase()===a}function J(a){return da.array(a)&&a.length>0}function K(a,b){return da.array(b)&&b.every(a)}function L(a,b){return da.verify.array(b,"expected array to find bad items"),b.filter($(a))}function M(a,b){var c=da.array(a)&&a.every(da.string);return c&&da.bool(b)&&b?a.every(da.lowerCase):c}function N(a,b){return da.array(a)&&a.every(function(a){return da.arrayOfStrings(a,b)})}function O(a,b){return da.verify.fn(da.every,"missing check.every method"),da.verify.fn(da.map,"missing check.map method"),da.verify.object(a,"missing object to check"),da.verify.object(b,"missing predicates object"),Object.keys(b).forEach(function(a){if(!da.fn(b[a]))throw new Error("not a predicate function for "+a+" but "+b[a])}),da.every(da.map(a,b))}function P(a,b){return O(b,a)}function Q(a,b){da.verify.fn(a,"expected function that raises");try{a()}catch(c){return"undefined"==typeof b?!0:"function"==typeof b?b(c):!1}return!1}function R(a){return""===a}function S(a){var b="string"==typeof a||Array.isArray(a);return b?!a.length:a instanceof Object?!Object.keys(a).length:!1}function T(a){var b="string"==typeof a||Array.isArray(a);return b?a.length:a instanceof Object?Object.keys(a).length:!0}function U(a){return da.number(a)&&a>=0&&1>=a}function V(a){return da.string(a)&&ea.test(a)}function W(a){return da.string(a)&&40===a.length&&fa.test(a)}function X(a){return da.string(a)&&7===a.length&&ga.test(a)}function Y(){var a=Array.prototype.slice.call(arguments,0);if(!a.length)throw new Error("empty list of arguments to or");return function(){var b=Array.prototype.slice.call(arguments,0);return a.some(function(a){try{return da.fn(a)?a.apply(null,b):Boolean(a)}catch(c){return!1}})}}function Z(){var a=Array.prototype.slice.call(arguments,0);if(!a.length)throw new Error("empty list of arguments to or");return function(){var b=Array.prototype.slice.call(arguments,0);return a.every(function(a){return da.fn(a)?a.apply(null,b):Boolean(a)})}}function $(a){return function(){return!a.apply(null,arguments)}}function _(a){return da.object(a)&&ja(a)}function aa(a,b){if(2===arguments.length)return a===b;if(1===arguments.length)return function(b){return a===b};throw new Error("Expected at least 1 or 2 arguments to check.equal")}if("function"!=typeof Function.prototype.bind)throw new Error("Missing Function.prototype.bind, please load es5-shim first");var ba=p.bind(null,"http://"),ca=p.bind(null,"https://"),da={maybe:{},verify:{},not:{},every:s,map:t},ea=/^#(?:[0-9a-fA-F]{3}){1,2}$/,fa=/^[0-9a-f]{40}$/,ga=/^[0-9a-f]{7}$/;if(!da.defend){var ha=function(a,b,c){da.verify.fn(a,"expected a function"),da.verify.array(b,"expected list of predicates"),da.verify.defined(c,"missing args");var d=0,e=0,f=b.length;for(d=0;f>d;d+=1){var g=b[d];if(da.fn(g)){if(!g.call(null,c[e])){var h="Argument "+(e+1)+": "+c[e]+" does not pass predicate";throw da.unemptyString(b[d+1])&&(h+=": "+b[d+1]),new Error(h)}e+=1}}return a.apply(null,c)};da.defend=function(a){var b=Array.prototype.slice.call(arguments,1);return function(){return ha(a,b,arguments)}}}da.mixin||(da.mixin=function(a,f){function g(a,c,f){if(!e(a))throw new Error("missing object "+a);if(!d(c))throw new Error("missing name");if(!b(f))throw new Error("missing function");a[c]||(a[c]=f)}function h(a){return function(){return!da.defined(arguments[0])||da.nulled(arguments[0])?!0:a.apply(null,arguments)}}function i(a,b){return function(){var c;if(a.apply(null,arguments)===!1)throw c=arguments[arguments.length-1],new Error(da.unemptyString(c)?c:b)}}if(c(a)&&b(f)){var j=a;a=f,f=j}if(!b(a))throw new Error("expected predicate function");if(d(f)||(f=a.name),!d(f))throw new Error("predicate function missing name\n"+a.toString());g(da,f,a),g(da.maybe,f,h(a)),g(da.not,f,$(a)),g(da.verify,f,i(a,f+" failed"))}),da.then||(da.then=function(a,b){return function(){var c="function"==typeof a?a.apply(null,arguments):a;return c?b.apply(null,arguments):void 0}});var ia={then:b};ia["catch"]=b,ia["finally"]=b;var ja=P.bind(null,ia),ka={nulled:j,fn:b,string:c,unemptyString:d,object:e,number:g,array:Array.isArray,positiveNumber:k,negativeNumber:l,defined:u,same:z,allSame:C,bit:F,bool:G,has:H,lowerCase:I,unemptyArray:J,arrayOfStrings:M,arrayOfArraysOfStrings:N,all:O,schema:P,raises:Q,empty:S,emptyString:R,unempty:T,unit:U,hexRgb:V,sameLength:B,commitId:W,shortCommitId:X,index:A,git:E,arrayOf:K,badItems:L,oneOf:D,promise:_,validDate:v,equal:aa,or:Y,and:Z,primitive:x,zero:y,date:m,instance:n,emptyObject:f,length:o,floatNumber:i,intNumber:h,startsWith:p,webUrl:r,semver:w,type:a(q)};Object.keys(ka).forEach(function(a){da.mixin(ka[a],a)}),"object"==typeof module&&(module.exports=da),"object"==typeof window&&(window.check=da),"object"==typeof global&&(global.check=da)}();
{
"name": "check-more-types",
"description": "Large collection of predicates.",
"version": "2.3.0",
"version": "2.4.0",
"author": "Gleb Bahmutov <gleb.bahmutov@gmail.com>",

@@ -27,2 +27,4 @@ "bugs": {

"devDependencies": {
"@semantic-release/condition-travis": "4.1.4",
"condition-node-version": "1.1.0",
"coveralls": "2.11.4",

@@ -38,3 +40,3 @@ "git-issues": "1.2.0",

"grunt-mocha-test": "0.12.7",
"grunt-nice-package": "0.9.6",
"grunt-nice-package": "0.10.1",
"grunt-npm2bower-sync": "0.9.1",

@@ -74,6 +76,11 @@ "grunt-readme": "0.4.5",

"release": {
"verifyConditions": {
"path": "./test/publish-from-specific-node",
"node": "4.2.2"
}
"verifyConditions": [
{
"path": "@semantic-release/condition-travis"
},
{
"path": "condition-node-version",
"node": "4.2.2"
}
]
},

@@ -80,0 +87,0 @@ "repository": {

@@ -54,2 +54,4 @@ # check-more-types

* [check.defined](#checkdefined)
* [check.semver](#checksemver)
* [check.type](#checktype)
* [check.bit](#checkbit)

@@ -130,2 +132,18 @@ * [check.primitive](#checkprimitive)

#### check.semver
check.semver('1.0.2'); // true
check.semver('1.0.2-alpha'); // false
---
#### check.type
check.type('string', 'foo'); // true
check.type('number', 42); // true
`check.type` is curried.
---
#### check.bit

@@ -132,0 +150,0 @@

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