UNPKG

15.2 kBJavaScriptView Raw
1!function(r){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=r();else if("function"==typeof define&&define.amd)define([],r);else{var t;"undefined"!=typeof window?t=window:"undefined"!=typeof global?t=global:"undefined"!=typeof self&&(t=self),t.predicates=r()}}(function(){return function r(t,e,n){function i(u,o){if(!e[u]){if(!t[u]){var c="function"==typeof require&&require;if(!o&&c)return c(u,!0);if(s)return s(u,!0);var a=new Error("Cannot find module '"+u+"'");throw a.code="MODULE_NOT_FOUND",a}var l=e[u]={exports:{}};t[u][0].call(l.exports,function(r){var e=t[u][1][r];return i(e?e:r)},l,l.exports,r,t,e,n)}return e[u].exports}for(var s="function"==typeof require&&require,u=0;u<n.length;u++)i(n[u]);return i}({1:[function(r,t,e){"use strict";e.all=e.and=r("./src/all"),e.any=e.or=r("./src/any"),e.array=e.arr=r("./src/array"),e.arrayLike=e.arrLike=r("./src/arrayLike"),e.arrayOf=e.arrOf=r("./src/arrayOf"),e.blank=r("./src/blank"),e.boolean=e.bool=r("./src/boolean"),e.date=r("./src/date"),e.defined=r("./src/defined"),e.divisible=e.divisibleBy=e.divBy=r("./src/divisible"),e.divisibleWithRemainder=e.divisibleByWithRemainder=e.divByWithRemainder=r("./src/divisibleWithRemainder"),e.empty=r("./src/empty"),e.endsWith=r("./src/endsWith"),e.equal=e.equalTo=e.eq=r("./src/equal"),e.false=r("./src/false"),e.falsy=e.falsey=r("./src/falsy"),e.finite=r("./src/finite"),e.function=e.fn=e.func=r("./src/function"),e.greaterThan=e.greater=e.gt=r("./src/greaterThan"),e.greaterThanOrEqual=e.greaterOrEqual=e.greaterEq=e.gtEq=r("./src/greaterThanOrEqual"),e.hasOwnProperty=e.hasOwn=r("./src/hasOwnProperty"),e.hasProperty=e.has=r("./src/hasProperty"),e.in=r("./src/in"),e.instanceOf=e.instance=r("./src/instanceOf"),e.integer=e.int=r("./src/integer"),e.lessThan=e.less=e.lt=r("./src/lessThan"),e.lessThanOrEqual=e.lessOrEqual=e.lessEq=e.ltEq=r("./src/lessThanOrEqual"),e.matches=e.match=r("./src/matches"),e.notANumber=e.nan=e.NaN=r("./src/nan"),e.negative=r("./src/negative"),e.not=e.negate=r("./src/not"),e.notBlank=r("./src/notBlank"),e.notEmpty=r("./src/notEmpty"),e.null=r("./src/null"),e.number=e.num=r("./src/number"),e.object=e.obj=r("./src/object"),e.objectOf=e.objOf=r("./src/objectOf"),e.oneOf=r("./src/oneOf"),e.plainObject=r("./src/plainObject"),e.positive=r("./src/positive"),e.primitive=r("./src/primitive"),e.property=e.prop=r("./src/property"),e.regexp=e.regExp=r("./src/regexp"),e.startsWith=r("./src/startsWith"),e.strictEqual=e.strictEqualTo=r("./src/strictEqual"),e.string=e.str=r("./src/string"),e.structure=r("./src/structure"),e.true=r("./src/true"),e.truthy=r("./src/truthy"),e.undefined=r("./src/undefined"),e.undefinedOr=r("./src/undefinedOr")},{"./src/all":2,"./src/any":3,"./src/array":4,"./src/arrayLike":5,"./src/arrayOf":6,"./src/blank":7,"./src/boolean":8,"./src/date":9,"./src/defined":10,"./src/divisible":11,"./src/divisibleWithRemainder":12,"./src/empty":13,"./src/endsWith":14,"./src/equal":15,"./src/false":16,"./src/falsy":17,"./src/finite":18,"./src/function":21,"./src/greaterThan":22,"./src/greaterThanOrEqual":23,"./src/hasOwnProperty":24,"./src/hasProperty":25,"./src/in":26,"./src/instanceOf":27,"./src/integer":28,"./src/lessThan":31,"./src/lessThanOrEqual":32,"./src/matches":33,"./src/nan":34,"./src/negative":35,"./src/not":36,"./src/notBlank":37,"./src/notEmpty":38,"./src/null":39,"./src/number":40,"./src/object":41,"./src/objectOf":42,"./src/oneOf":43,"./src/plainObject":44,"./src/positive":45,"./src/primitive":46,"./src/property":47,"./src/regexp":48,"./src/startsWith":49,"./src/strictEqual":50,"./src/string":51,"./src/structure":52,"./src/true":53,"./src/truthy":54,"./src/undefined":55,"./src/undefinedOr":56}],2:[function(r,t){"use strict";var e=r("./utils/assertPredicates");t.exports=function(){var r=Array.prototype.slice.call(arguments);return e(r),function(){var t=Array.prototype.slice.call(arguments);return r.every(function(r){return r.apply(this,t)},this)}}},{"./utils/assertPredicates":57}],3:[function(r,t){"use strict";var e=r("./utils/assertPredicates");t.exports=function(){var r=Array.prototype.slice.call(arguments);return e(r),function(){var t=Array.prototype.slice.call(arguments);return r.some(function(r){return r.apply(this,t)},this)}}},{"./utils/assertPredicates":57}],4:[function(r,t){"use strict";t.exports=Array.isArray},{}],5:[function(r,t){"use strict";var e=r("./object"),n=r("./number");t.exports=function(r){return e(r)&&n(r.length)&&r.length>=0}},{"./number":40,"./object":41}],6:[function(r,t){"use strict";var e=r("./array"),n=r("./function"),i=r("./utils/handleCurry");t.exports=function(r){if(!n(r))throw new TypeError("Predicate must be a function");return i.call(this,arguments,function(t){var n=Array.prototype.slice.call(arguments,1);return e(t)&&t.every(function(t){return r.apply(this,[t].concat(n))},this)})}},{"./array":4,"./function":21,"./utils/handleCurry":58}],7:[function(r,t){"use strict";var e=r("./string"),n=/^\s*$/;t.exports=function(r){return e(r)&&(""===r||n.test(r))}},{"./string":51}],8:[function(r,t){"use strict";t.exports=function(r){return"boolean"==typeof r||"[object Boolean]"===Object.prototype.toString.call(r)}},{}],9:[function(r,t){"use strict";t.exports=function(r){return"[object Date]"===Object.prototype.toString.call(r)}},{}],10:[function(r,t){"use strict";var e=r("./undefined");t.exports=function(r){return!e(r)}},{"./undefined":55}],11:[function(r,t){"use strict";var e=r("./divisibleWithRemainder");t.exports=function(){var r=Array.prototype.slice.call(arguments);return r.splice(1,0,0),e.apply(this,r)}},{"./divisibleWithRemainder":12}],12:[function(r,t){"use strict";var e=r("./utils/handleCurry"),n=r("./finite"),i=r("./number");t.exports=function(r,t){if(arguments.length<2)throw new Error("Missing remainder");if(!n(r))throw new TypeError("Divisor is not a finite number");if(0===r)throw new Error("Divisor cannot be 0");if(!n(t))throw new TypeError("Remainder is not a finite number");if(t>=r)throw new Error("Remainder cannot be greater than divisor");return e.call(this,arguments,function(e){return i(e)&&e%r===t},2)}},{"./finite":18,"./number":40,"./utils/handleCurry":58}],13:[function(r,t){"use strict";var e=r("./arrayLike"),n=r("./object"),i=r("./string");t.exports=function(r){return e(r)?0===r.length:n(r)?0===Object.keys(r).length:i(r)?""==r:!1}},{"./arrayLike":5,"./object":41,"./string":51}],14:[function(r,t){"use strict";var e=r("./string"),n=r("./utils/handleCurry");t.exports=function(r){if(!e(r))throw new TypeError("Suffix must be a string");if(""===r)throw new Error("Suffix cannot be empty");return n.call(this,arguments,function(t){return e(t)&&t.indexOf(r)===t.length-r.length})}},{"./string":51,"./utils/handleCurry":58}],15:[function(r,t){"use strict";var e=r("./utils/handleCurry");t.exports=function(r){return e.call(this,arguments,function(t){return r==t})}},{"./utils/handleCurry":58}],16:[function(r,t){"use strict";var e=r("./boolean");t.exports=function(r){return r===!1||e(r)&&0==r}},{"./boolean":8}],17:[function(r,t){"use strict";t.exports=function(r){return!r}},{}],18:[function(r,t){"use strict";t.exports=r("./finite/native")||r("./finite/polyfill")},{"./finite/native":19,"./finite/polyfill":20}],19:[function(r,t){"use strict";t.exports=Number.isFinite},{}],20:[function(r,t){"use strict";var e=r("../number");t.exports=function(r){return e(r)&&1/0!==r&&r!==-1/0&&!isNaN(r)}},{"../number":40}],21:[function(r,t){"use strict";t.exports=function(r){return"[object Function]"===Object.prototype.toString.call(r)}},{}],22:[function(r,t){"use strict";var e=r("./utils/handleCurry");t.exports=function(r){return e.call(this,arguments,function(t){return t>r})}},{"./utils/handleCurry":58}],23:[function(r,t){"use strict";var e=r("./utils/handleCurry");t.exports=function(r){return e.call(this,arguments,function(t){return t>=r})}},{"./utils/handleCurry":58}],24:[function(r,t){"use strict";var e=r("./object"),n=r("./string"),i=r("./utils/handleCurry");t.exports=function(r){if(!n(r))throw new TypeError("Property name must be a string");return i.call(this,arguments,function(t){return e(t)&&Object.prototype.hasOwnProperty.call(t,r)})}},{"./object":41,"./string":51,"./utils/handleCurry":58}],25:[function(r,t){"use strict";var e=r("./object"),n=r("./string"),i=r("./utils/handleCurry");t.exports=function(r){if(!n(r))throw new TypeError("Property name must be a string");return i.call(this,arguments,function(t){return e(t)&&r in t})}},{"./object":41,"./string":51,"./utils/handleCurry":58}],26:[function(r,t){"use strict";var e=r("./array"),n=r("./utils/handleCurry");t.exports=function(r){if(!e(r))throw new TypeError("Collection must be an array");if(0===r.length)throw new Error("Collection cannot be empty");return n.call(this,arguments,function(t){return-1!==r.indexOf(t)})}},{"./array":4,"./utils/handleCurry":58}],27:[function(r,t){"use strict";var e=r("./utils/handleCurry"),n=r("./function");t.exports=function(r){if(!n(r))throw new TypeError("Class must be a function");return e.call(this,arguments,function(t){return t instanceof r})}},{"./function":21,"./utils/handleCurry":58}],28:[function(r,t){"use strict";t.exports=r("./integer/native")||r("./integer/polyfill")},{"./integer/native":29,"./integer/polyfill":30}],29:[function(r,t){"use strict";t.exports=Number.isInteger},{}],30:[function(r,t){"use strict";var e=r("../finite");t.exports=function(r){return e(r)&&r>-9007199254740992&&9007199254740992>r&&Math.floor(r)===r}},{"../finite":18}],31:[function(r,t){"use strict";var e=r("./utils/handleCurry");t.exports=function(r){return e.call(this,arguments,function(t){return r>t})}},{"./utils/handleCurry":58}],32:[function(r,t){"use strict";var e=r("./utils/handleCurry");t.exports=function(r){return e.call(this,arguments,function(t){return r>=t})}},{"./utils/handleCurry":58}],33:[function(r,t){"use strict";var e=r("./regexp"),n=r("./utils/handleCurry");t.exports=function(r){if(!e(r))throw new TypeError("Regexp must be a RegExp object");return n.call(this,arguments,function(t){return r.test(t)})}},{"./regexp":48,"./utils/handleCurry":58}],34:[function(r,t){"use strict";var e=r("./number");t.exports=function(r){return e(r)&&isNaN(r)}},{"./number":40}],35:[function(r,t){"use strict";var e=r("./number");t.exports=function(r){return e(r)&&0>r}},{"./number":40}],36:[function(r,t){"use strict";var e=r("./function"),n=r("./utils/handleCurry");t.exports=function(r){if(!e(r))throw new TypeError("Predicate must be a function");return n.call(this,arguments,function(){return!r.apply(this,arguments)})}},{"./function":21,"./utils/handleCurry":58}],37:[function(r,t){"use strict";var e=r("./string"),n=/\S/;t.exports=function(r){return e(r)&&n.test(r)}},{"./string":51}],38:[function(r,t){"use strict";var e=r("./empty"),n=r("./not");t.exports=n(e)},{"./empty":13,"./not":36}],39:[function(r,t){"use strict";t.exports=function(r){return null===r}},{}],40:[function(r,t){"use strict";t.exports=function(r){return"number"==typeof r||"[object Number]"===Object.prototype.toString.call(r)}},{}],41:[function(r,t){"use strict";t.exports=function(r){return r instanceof Object||"object"==typeof r&&null!==r}},{}],42:[function(r,t){"use strict";var e=r("./object"),n=r("./function"),i=r("./utils/handleCurry");t.exports=function(r){if(!n(r))throw new TypeError("Predicate must be a function");return i.call(this,arguments,function(t){var n=Array.prototype.slice.call(arguments,1);return e(t)&&Object.keys(t).every(function(e){return r.apply(this,[t[e]].concat(n))},this)})}},{"./function":21,"./object":41,"./utils/handleCurry":58}],43:[function(r,t){"use strict";t.exports=function(){var r=Array.prototype.slice.call(arguments);if(r.length<2)throw new Error("At least 2 allowed values are required");return function(t){return-1!==r.indexOf(t)}}},{}],44:[function(r,t){"use strict";var e=r("./object");t.exports=function(r){if(!e(r))return!1;var t=Object.getPrototypeOf(r);return t===Object.prototype||null===t}},{"./object":41}],45:[function(r,t){"use strict";var e=r("./number");t.exports=function(r){return e(r)&&r>0}},{"./number":40}],46:[function(r,t){"use strict";var e=r("./string"),n=r("./number"),i=r("./boolean"),s=r("./undefined"),u=r("./null"),o=r("./object");t.exports=function(r){return!o(r)&&(e(r)||n(r)||i(r)||s(r)||u(r))}},{"./boolean":8,"./null":39,"./number":40,"./object":41,"./string":51,"./undefined":55}],47:[function(r,t){"use strict";var e=r("./object"),n=r("./function"),i=r("./utils/handleCurry");t.exports=function(r,t){if(arguments.length<2)throw new Error("Too few arguments - 2 required");if(!n(t))throw new TypeError("Predicate is not a function");return i.call(this,arguments,function(n){var i=Array.prototype.slice.call(arguments);return i.splice(0,1,e(n)?n[r]:void 0),e(n)&&t.apply(this,i)},2)}},{"./function":21,"./object":41,"./utils/handleCurry":58}],48:[function(r,t){"use strict";t.exports=function(r){return"[object RegExp]"===Object.prototype.toString.call(r)}},{}],49:[function(r,t){"use strict";var e=r("./string"),n=r("./utils/handleCurry");t.exports=function(r){if(!e(r))throw new TypeError("Prefix must be a string");if(""===r)throw new Error("Prefix cannot be empty");return n.call(this,arguments,function(t){return e(t)&&0===t.indexOf(r)})}},{"./string":51,"./utils/handleCurry":58}],50:[function(r,t){"use strict";var e=r("./utils/handleCurry");t.exports=function(r){return e.call(this,arguments,function(t){return r===t})}},{"./utils/handleCurry":58}],51:[function(r,t){"use strict";t.exports=function(r){return"string"==typeof r||"[object String]"===Object.prototype.toString.call(r)}},{}],52:[function(r,t){"use strict";var e=r("./object"),n=r("./utils/handleCurry"),i=r("./objectOf"),s=r("./function"),u=i(s);t.exports=function(r){if(!e(r))throw new TypeError("Structure must be an object");var t=Object.keys(r);if(0===t.length)throw new Error("Structure object cannot be empty. No enumerable properties found");if(!u(r))throw new TypeError("Structure object must consist of predicates");return n.call(this,arguments,function(n){var i=Array.prototype.slice.call(arguments,1);return e(n)&&t.every(function(t){return r[t].apply(this,[n[t]].concat(i))},this)})}},{"./function":21,"./object":41,"./objectOf":42,"./utils/handleCurry":58}],53:[function(r,t){"use strict";var e=r("./boolean");t.exports=function(r){return r===!0||e(r)&&1==r}},{"./boolean":8}],54:[function(r,t){"use strict";t.exports=function(r){return!!r}},{}],55:[function(r,t){"use strict";t.exports=function(r){return"undefined"==typeof r}},{}],56:[function(r,t){"use strict";var e=r("./function"),n=r("./undefined"),i=r("./utils/handleCurry");t.exports=function(r){if(!e(r))throw new TypeError("Predicate must be a function");return i.call(this,arguments,function(t){return n(t)||r.apply(this,arguments)})}},{"./function":21,"./undefined":55,"./utils/handleCurry":58}],57:[function(r,t){"use strict";var e=r("../function"),n=r("../arrayOf");t.exports=function(r){if(!n(e,r))throw new TypeError("Every predicate must be a function");if(r.length<2)throw new Error("You need to provide at least two predicates")}},{"../arrayOf":6,"../function":21}],58:[function(r,t){"use strict";t.exports=function(r,t,e){return e=e||1,r.length>e?t.apply(this,Array.prototype.slice.call(r,e)):t}},{}]},{},[1])(1)});
\No newline at end of file