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

typeof-arguments

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typeof-arguments - npm Package Compare versions

Comparing version 5.1.1 to 5.1.2

webpack.config.js

2

dist/typeof-arguments.js

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

var typeofArguments=function(modules){var installedModules={};function __webpack_require__(moduleId){if(installedModules[moduleId])return installedModules[moduleId].exports;var module=installedModules[moduleId]={i:moduleId,l:!1,exports:{}};return modules[moduleId].call(module.exports,module,module.exports,__webpack_require__),module.l=!0,module.exports}return __webpack_require__.m=modules,__webpack_require__.c=installedModules,__webpack_require__.d=function(exports,name,getter){__webpack_require__.o(exports,name)||Object.defineProperty(exports,name,{enumerable:!0,get:getter})},__webpack_require__.r=function(exports){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(exports,"__esModule",{value:!0})},__webpack_require__.t=function(value,mode){if(1&mode&&(value=__webpack_require__(value)),8&mode)return value;if(4&mode&&"object"==typeof value&&value&&value.__esModule)return value;var ns=Object.create(null);if(__webpack_require__.r(ns),Object.defineProperty(ns,"default",{enumerable:!0,value:value}),2&mode&&"string"!=typeof value)for(var key in value)__webpack_require__.d(ns,key,function(key){return value[key]}.bind(null,key));return ns},__webpack_require__.n=function(module){var getter=module&&module.__esModule?function(){return module.default}:function(){return module};return __webpack_require__.d(getter,"a",getter),getter},__webpack_require__.o=function(object,property){return Object.prototype.hasOwnProperty.call(object,property)},__webpack_require__.p="",__webpack_require__(__webpack_require__.s=1)}([function(module,exports,__webpack_require__){(function(global){module.exports=function(modules){var installedModules={};function __webpack_require__(moduleId){if(installedModules[moduleId])return installedModules[moduleId].exports;var module=installedModules[moduleId]={i:moduleId,l:!1,exports:{}};return modules[moduleId].call(module.exports,module,module.exports,__webpack_require__),module.l=!0,module.exports}return __webpack_require__.m=modules,__webpack_require__.c=installedModules,__webpack_require__.d=function(exports,name,getter){__webpack_require__.o(exports,name)||Object.defineProperty(exports,name,{enumerable:!0,get:getter})},__webpack_require__.r=function(exports){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(exports,"__esModule",{value:!0})},__webpack_require__.t=function(value,mode){if(1&mode&&(value=__webpack_require__(value)),8&mode)return value;if(4&mode&&"object"==typeof value&&value&&value.__esModule)return value;var ns=Object.create(null);if(__webpack_require__.r(ns),Object.defineProperty(ns,"default",{enumerable:!0,value:value}),2&mode&&"string"!=typeof value)for(var key in value)__webpack_require__.d(ns,key,function(key){return value[key]}.bind(null,key));return ns},__webpack_require__.n=function(module){var getter=module&&module.__esModule?function(){return module.default}:function(){return module};return __webpack_require__.d(getter,"a",getter),getter},__webpack_require__.o=function(object,property){return Object.prototype.hasOwnProperty.call(object,property)},__webpack_require__.p="",__webpack_require__(__webpack_require__.s=0)}([function(module,__webpack_exports__,__webpack_require__){"use strict";function _typeof(obj){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj})(obj)}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}__webpack_require__.r(__webpack_exports__);var _g=function(){return global||window}.bind(void 0),OfType=function(){function OfType(){!function(instance,Constructor){if(!(instance instanceof OfType))throw new TypeError("Cannot call a class as a function")}(this);var _this=this;return function(value,type){return _this._setInitials(arguments,value,type),_this._validate()}}return _defineProperties(OfType.prototype,[{key:"_setInitials",value:function(_arguments,value,type){this._arguments=_arguments,this._value=value,this._type=type}},{key:"_validate",value:function(){return!!this.isTypeDefined&&(this.isTypeNull?this.isValueNull:this.isTypeUndefined?void 0===this._value:this.isTypeFunction?this._typeConstructor():this.isTypeArray?this._typeArray():this.isTypeString?this._typeString():!!this.isTypeRegExp&&this._typeRegexp())}},{key:"_typeConstructor",value:function(){return!this.isValueUndefined&&!this.isValueNull&&Object.getPrototypeOf(this._value).constructor.name===this._type.name}},{key:"_typeArray",value:function(){if(!this._type.length)return!0;var _iteratorNormalCompletion=!0,_didIteratorError=!1,_iteratorError=void 0;try{for(var _step,_iterator=this._type[Symbol.iterator]();!(_iteratorNormalCompletion=(_step=_iterator.next()).done);_iteratorNormalCompletion=!0){var t=_step.value;if(null===t&&this.isValueNull)return!0;if(void 0===t&&this.isValueUndefined)return!0;if(!this.isValueNull&&!this.isValueUndefined&&null!=t&&Object.getPrototypeOf(this._value).constructor.name===t.name)return!0}}catch(err){_didIteratorError=!0,_iteratorError=err}finally{try{_iteratorNormalCompletion||null==_iterator.return||_iterator.return()}finally{if(_didIteratorError)throw _iteratorError}}return!1}},{key:"_typeString",value:function(){var _this2=this,typeList=this._type.toLowerCase().split("|");if(1===typeList.length&&""===typeList[0]||typeList.some(function(i){return"any"===i}))return!0;if(typeList.some(function(i){return"truthy"===i})&&this._value)return!0;if(typeList.some(function(i){return"falsy"===i})&&!this._value)return!0;if(this.isValueUndefined&&typeList.some(function(i){return"undefined"===i}))return!0;if(this.isValueNull&&typeList.some(function(i){return"null"===i}))return!0;if(this.isValueNull||void 0===this._value)return!1;var valueConstructor=Object.getPrototypeOf(this._value).constructor;return!!(this.argumentsRegExp.test(this._value.toString())&&valueConstructor&&"Object"===valueConstructor.name&&typeList.some(function(i){return"arguments"===i}))||!!(typeList.some(function(i){return"instance"===i})&&this.isValueObject&&valueConstructor&&valueConstructor!==_g()[valueConstructor.name])||!(!typeList.some(function(i){return"objectable"===i})||!this.isObjectInstance)||typeList.some(function(i){return i===Object.getPrototypeOf(_this2._value).constructor.name.toLowerCase()})}},{key:"_typeRegexp",value:function(){if(this._exec("any")||this._type.test(""))return!0;if(this._exec("truthy")&&this._value)return!0;if(this._exec("falsy")&&!this._value)return!0;if(this._type.test("undefined")&&this.isValueUndefined)return!0;if(this._type.test("null")&&this.isValueNull)return!0;if(this.isValueNull||void 0===this._value)return!1;var valueConstructor=Object.getPrototypeOf(this._value).constructor;return!!(this._exec("arguments")&&valueConstructor&&"Object"===valueConstructor.name&&this.argumentsRegExp.test(this._value.toString()))||!!(this._exec("instance")&&this.isValueObject&&valueConstructor&&valueConstructor!==_g()[valueConstructor.name])||!(!this._exec("objectable")||!this.isObjectInstance)||this._type.test(Object.getPrototypeOf(this._value).constructor.name)}},{key:"_exec",value:function(name){var _exec=this._type.exec(name);return null!==_exec&&_exec[0]===name}},{key:"isTypeDefined",get:function(){return 2<=this._arguments.length}},{key:"isTypeString",get:function(){return"string"==typeof this._type}},{key:"isTypeFunction",get:function(){return"function"==typeof this._type}},{key:"isTypeUndefined",get:function(){return void 0===this._type}},{key:"isValueUndefined",get:function(){return void 0===this._value}},{key:"isTypeNull",get:function(){return null===this._type}},{key:"isValueNull",get:function(){return null===this._value}},{key:"isValueObject",get:function(){return"object"===_typeof(this._value)}},{key:"isObjectInstance",get:function(){return this._value instanceof Object}},{key:"isTypeArray",get:function(){return!this.isTypeNull&&"object"===_typeof(this._type)&&"Array"===this._type.constructor.name}},{key:"isTypeRegExp",get:function(){return this._type&&"RegExp"===this._type.constructor.name}},{key:"argumentsRegExp",get:function(){return/^\[object Arguments\]$/i}}]),OfType}();__webpack_exports__.default=new OfType}]).default}).call(this,__webpack_require__(2))},function(module,__webpack_exports__,__webpack_require__){"use strict";__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,"default",function(){return typeofArguments});var of_type__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(0),of_type__WEBPACK_IMPORTED_MODULE_0___default=__webpack_require__.n(of_type__WEBPACK_IMPORTED_MODULE_0__);function _construct(Parent,args,Class){return(_construct=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(e){return!1}}()?Reflect.construct:function(Parent,args,Class){var a=[null];a.push.apply(a,args);var instance=new(Function.bind.apply(Parent,a));return Class&&_setPrototypeOf(instance,Class.prototype),instance}).apply(null,arguments)}function _setPrototypeOf(o,p){return(_setPrototypeOf=Object.setPrototypeOf||function(o,p){return o.__proto__=p,o})(o,p)}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}var TypeofArguments=function(){function TypeofArguments(getArgumentsObject,getExpectedArray,callbackFunction){if(function(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}(this,TypeofArguments),!of_type__WEBPACK_IMPORTED_MODULE_0___default()(getArgumentsObject,"arguments"))throw new TypeError("typeof-arguments: The [0] argument must be the [arguments] Object.");if(!of_type__WEBPACK_IMPORTED_MODULE_0___default()(getExpectedArray,Array))throw new TypeError("typeof-arguments: The [1] argument must be of type [Array].");for(var index=0;index<getExpectedArray.length;index++)if(!of_type__WEBPACK_IMPORTED_MODULE_0___default()(getArgumentsObject[index],getExpectedArray[index])){var actual=this.getActualType(getArgumentsObject[index]),types=this.getExpectedTypes(getExpectedArray[index]),textActual="[".concat(actual,"] ").concat(types.addons,"argument"),textExpected=types.message,message="Invalid argument [".concat(index,"]. The ").concat(textActual," has been passed, while the ").concat(textExpected," is expected.");if(of_type__WEBPACK_IMPORTED_MODULE_0___default()(callbackFunction,"function"))return callbackFunction({index:index,actual:actual,expected:types.expected,message:message,textActual:textActual,textExpected:textExpected}),function(){return!1};throw new TypeError(message)}return function(){return!0}}var Constructor,protoProps,staticProps;return Constructor=TypeofArguments,(protoProps=[{key:"getActualType",value:function(actualValue){return of_type__WEBPACK_IMPORTED_MODULE_0___default()(actualValue,null)?"null":of_type__WEBPACK_IMPORTED_MODULE_0___default()(actualValue,void 0)?"undefined":of_type__WEBPACK_IMPORTED_MODULE_0___default()(actualValue,"arguments")?"arguments":actualValue.constructor.name}},{key:"getExpectedTypes",value:function(expectedType){for(var types=["whenString","whenRegExp","whenObject","whenArray"],_i=0;_i<types.length;_i++){var check=this[types[_i]](expectedType);if(check)return check}throw new TypeError("typeof-arguments: The expected type is not callable.")}},{key:"whenString",value:function(stringType){if(!of_type__WEBPACK_IMPORTED_MODULE_0___default()(stringType,String))return null;var msg='argument of type matching string expression "'.concat(stringType,'"'),truthness="",objectable="";return stringType.split("|").forEach(function(i){"truthy"===i.toLowerCase()&&(truthness="<<falsy>> "),"falsy"===i.toLowerCase()&&(truthness="<<truthy>> "),"objectable"===i.toLowerCase()&&(objectable="<<non-objectable>> ")}),{message:msg,addons:truthness+objectable,expected:stringType}}},{key:"whenRegExp",value:function(regType){return of_type__WEBPACK_IMPORTED_MODULE_0___default()(regType,RegExp)?{message:"argument of type matching regular expression ".concat(regType),addons:function(regType){var isCaseInsensitive=regType.flags.match(/i/),str=regType.toString();str=isCaseInsensitive?str.toLowerCase():str;var truthness="",objectable="";str.match(/truthy/)&&(truthness="<<falsy>> ");str.match(/falsy/)&&(truthness="<<truthy>> ");str.match(/objectable/)&&(objectable="<<non-objectable>> ");return truthness+objectable}(regType),expected:regType.toString()}:null}},{key:"whenObject",value:function(objectType){return of_type__WEBPACK_IMPORTED_MODULE_0___default()(objectType,null)?{message:"argument of type [null]",addons:"",expected:"null"}:of_type__WEBPACK_IMPORTED_MODULE_0___default()(objectType,void 0)?{message:"argument of type [undefined]",addons:"",expected:"undefined"}:of_type__WEBPACK_IMPORTED_MODULE_0___default()(objectType,Function)?{message:"argument of type [".concat(objectType.name,"]"),addons:"",expected:objectType.name}:null}},{key:"whenArray",value:function(arrayTypes){if(!of_type__WEBPACK_IMPORTED_MODULE_0___default()(arrayTypes,Array))return null;var types={},_iteratorNormalCompletion=!0,_didIteratorError=!1,_iteratorError=void 0;try{for(var _step,_iterator=arrayTypes[Symbol.iterator]();!(_iteratorNormalCompletion=(_step=_iterator.next()).done);_iteratorNormalCompletion=!0){var _type=_step.value,exp=this.whenObject(_type);if(of_type__WEBPACK_IMPORTED_MODULE_0___default()(exp,null))return null;types[exp.expected]=exp.expected}}catch(err){_didIteratorError=!0,_iteratorError=err}finally{try{_iteratorNormalCompletion||null==_iterator.return||_iterator.return()}finally{if(_didIteratorError)throw _iteratorError}}var expected=Object.getOwnPropertyNames(types).join("|");return{message:"argument of type [".concat(expected,"]"),addons:"",expected:expected}}}])&&_defineProperties(Constructor.prototype,protoProps),staticProps&&_defineProperties(Constructor,staticProps),TypeofArguments}();function typeofArguments(){return _construct(TypeofArguments,Array.prototype.slice.call(arguments))()}},function(module,exports){var g;g=function(){return this}();try{g=g||new Function("return this")()}catch(e){"object"==typeof window&&(g=window)}module.exports=g}]).default;
var typeofArguments=function(e){var t={};function n(r){if(t[r])return t[r].exports;var u=t[r]={i:r,l:!1,exports:{}};return e[r].call(u.exports,u,u.exports,n),u.l=!0,u.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var u in e)n.d(r,u,function(t){return e[t]}.bind(null,u));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=1)}([function(e,t,n){(function(t){e.exports=function(e){var t={};function n(r){if(t[r])return t[r].exports;var u=t[r]={i:r,l:!1,exports:{}};return e[r].call(u.exports,u,u.exports,n),u.l=!0,u.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var u in e)n.d(r,u,function(t){return e[t]}.bind(null,u));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,n,r){"use strict";function u(e){return(u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return i(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?i(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,u=function(){};return{s:u,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:u}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,c=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return a=e.done,e},e:function(e){c=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(c)throw o}}}}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function a(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}r.r(n);var c=function(){return t||window}.bind(void 0),s=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e);var t=this;return function(e,n){return t._setInitials(arguments,e,n),t._validate()}}var t,n;return t=e,(n=[{key:"_setInitials",value:function(e,t,n){this._arguments=e,this._value=t,this._type=n}},{key:"_validate",value:function(){return!!this.isTypeDefined&&(this.isTypeNull?this.isValueNull:this.isTypeUndefined?void 0===this._value:this.isTypeFunction?this._typeConstructor():this.isTypeArray?this._typeArray():this.isTypeString?this._typeString():!!this.isTypeRegExp&&this._typeRegexp())}},{key:"_typeConstructor",value:function(){return!this.isValueUndefined&&!this.isValueNull&&Object.getPrototypeOf(this._value).constructor===this._type}},{key:"_typeArray",value:function(){if(!this._type.length)return!0;var e,t=o(this._type);try{for(t.s();!(e=t.n()).done;){var n=e.value;if(null===n&&this.isValueNull)return!0;if(void 0===n&&this.isValueUndefined)return!0;if(!this.isValueNull&&!this.isValueUndefined&&null!=n&&Object.getPrototypeOf(this._value).constructor===n)return!0}}catch(e){t.e(e)}finally{t.f()}return!1}},{key:"_typeString",value:function(){var e=this,t=this._type.toLowerCase().split("|");if(1===t.length&&""===t[0]||t.some((function(e){return"any"===e})))return!0;if(t.some((function(e){return"truthy"===e}))&&this._value)return!0;if(t.some((function(e){return"falsy"===e}))&&!this._value)return!0;if(this.isValueUndefined&&t.some((function(e){return"undefined"===e})))return!0;if(this.isValueNull&&t.some((function(e){return"null"===e})))return!0;if(this.isValueNull||void 0===this._value)return!1;var n=Object.getPrototypeOf(this._value).constructor;return!!(this.argumentsRegExp.test(this._value.toString())&&n&&n===Object&&t.some((function(e){return"arguments"===e})))||!!(t.some((function(e){return"instance"===e}))&&this.isValueObject&&n&&n!==c()[n.name])||!(!t.some((function(e){return"objectable"===e}))||!this.isObjectInstance)||t.some((function(t){return t===Object.getPrototypeOf(e._value).constructor.name.toLowerCase()}))}},{key:"_typeRegexp",value:function(){if(this._exec("any")||this._type.test(""))return!0;if(this._exec("truthy")&&this._value)return!0;if(this._exec("falsy")&&!this._value)return!0;if(this._type.test("undefined")&&this.isValueUndefined)return!0;if(this._type.test("null")&&this.isValueNull)return!0;if(this.isValueNull||void 0===this._value)return!1;var e=Object.getPrototypeOf(this._value).constructor;return!!(this._exec("arguments")&&e&&e===Object&&this.argumentsRegExp.test(this._value.toString()))||!!(this._exec("instance")&&this.isValueObject&&e&&e!==c()[e.name])||!(!this._exec("objectable")||!this.isObjectInstance)||this._type.test(Object.getPrototypeOf(this._value).constructor.name)}},{key:"_exec",value:function(e){var t=this._type.exec(e);return null!==t&&t[0]===e}},{key:"isTypeDefined",get:function(){return this._arguments.length>=2}},{key:"isTypeString",get:function(){return"string"==typeof this._type}},{key:"isTypeFunction",get:function(){return"function"==typeof this._type}},{key:"isTypeUndefined",get:function(){return void 0===this._type}},{key:"isValueUndefined",get:function(){return void 0===this._value}},{key:"isTypeNull",get:function(){return null===this._type}},{key:"isValueNull",get:function(){return null===this._value}},{key:"isValueObject",get:function(){return"object"===u(this._value)}},{key:"isObjectInstance",get:function(){return this._value instanceof Object}},{key:"isTypeArray",get:function(){return!this.isTypeNull&&"object"===u(this._type)&&this._type.constructor===Array}},{key:"isTypeRegExp",get:function(){return this._type&&this._type.constructor===RegExp}},{key:"argumentsRegExp",get:function(){return/^\[object Arguments\]$/i}}])&&a(t.prototype,n),e}();n.default=new s}]).default}).call(this,n(2))},function(e,t,n){"use strict";n.r(t),n.d(t,"default",(function(){return y}));var r=n(0),u=n.n(r);function o(e,t,n){return(o=i()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var u=new(Function.bind.apply(e,r));return n&&a(u,n.prototype),u}).apply(null,arguments)}function i(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function a(e,t){return(a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function c(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return s(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return s(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,u=function(){};return{s:u,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:u}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,i=!0,a=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return i=e.done,e},e:function(e){a=!0,o=e},f:function(){try{i||null==n.return||n.return()}finally{if(a)throw o}}}}function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function l(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var f=function(){function e(t,n,r){if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),!u()(t,"arguments"))throw new TypeError("typeof-arguments: The [0] argument must be the [arguments] Object.");if(!u()(n,Array))throw new TypeError("typeof-arguments: The [1] argument must be of type [Array].");for(var o=0;o<n.length;o++)if(!u()(t[o],n[o])){var i=this.getActualType(t[o]),a=this.getExpectedTypes(n[o]),c="[".concat(i,"] ").concat(a.addons,"argument"),s=a.message,l="Invalid argument [".concat(o,"]. The ").concat(c," has been passed, while the ").concat(s," is expected.");if(u()(r,"function"))return r({index:o,actual:i,expected:a.expected,message:l,textActual:c,textExpected:s}),function(){return!1};throw new TypeError(l)}return function(){return!0}}var t,n,r;return t=e,(n=[{key:"getActualType",value:function(e){return u()(e,null)?"null":u()(e,void 0)?"undefined":u()(e,"arguments")?"arguments":e.constructor.name}},{key:"getExpectedTypes",value:function(e){for(var t=0,n=["whenString","whenRegExp","whenObject","whenArray"];t<n.length;t++){var r=this[n[t]](e);if(r)return r}throw new TypeError("typeof-arguments: The expected type is not callable.")}},{key:"whenString",value:function(e){if(!u()(e,String))return null;var t='argument of type matching string expression "'.concat(e,'"'),n="",r="";return e.split("|").forEach((function(e){"truthy"===e.toLowerCase()&&(n="<<falsy>> "),"falsy"===e.toLowerCase()&&(n="<<truthy>> "),"objectable"===e.toLowerCase()&&(r="<<non-objectable>> ")})),{message:t,addons:n+r,expected:e}}},{key:"whenRegExp",value:function(e){return u()(e,RegExp)?{message:"argument of type matching regular expression ".concat(e),addons:function(e){var t=e.flags.match(/i/),n=e.toString();n=t?n.toLowerCase():n;var r="",u="";return n.match(/truthy/)&&(r="<<falsy>> "),n.match(/falsy/)&&(r="<<truthy>> "),n.match(/objectable/)&&(u="<<non-objectable>> "),r+u}(e),expected:e.toString()}:null}},{key:"whenObject",value:function(e){return u()(e,null)?{message:"argument of type [null]",addons:"",expected:"null"}:u()(e,void 0)?{message:"argument of type [undefined]",addons:"",expected:"undefined"}:u()(e,Function)?{message:"argument of type [".concat(e.name,"]"),addons:"",expected:e.name}:null}},{key:"whenArray",value:function(e){if(!u()(e,Array))return null;var t,n={},r=c(e);try{for(r.s();!(t=r.n()).done;){var o=t.value,i=this.whenObject(o);if(u()(i,null))return null;n[i.expected]=i.expected}}catch(e){r.e(e)}finally{r.f()}var a=Object.getOwnPropertyNames(n).join("|");return{message:"argument of type [".concat(a,"]"),addons:"",expected:a}}}])&&l(t.prototype,n),r&&l(t,r),e}();function y(){return o(f,Array.prototype.slice.call(arguments))()}},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n}]).default;

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

module.exports=function(modules){var installedModules={};function __webpack_require__(moduleId){if(installedModules[moduleId])return installedModules[moduleId].exports;var module=installedModules[moduleId]={i:moduleId,l:!1,exports:{}};return modules[moduleId].call(module.exports,module,module.exports,__webpack_require__),module.l=!0,module.exports}return __webpack_require__.m=modules,__webpack_require__.c=installedModules,__webpack_require__.d=function(exports,name,getter){__webpack_require__.o(exports,name)||Object.defineProperty(exports,name,{enumerable:!0,get:getter})},__webpack_require__.r=function(exports){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(exports,"__esModule",{value:!0})},__webpack_require__.t=function(value,mode){if(1&mode&&(value=__webpack_require__(value)),8&mode)return value;if(4&mode&&"object"==typeof value&&value&&value.__esModule)return value;var ns=Object.create(null);if(__webpack_require__.r(ns),Object.defineProperty(ns,"default",{enumerable:!0,value:value}),2&mode&&"string"!=typeof value)for(var key in value)__webpack_require__.d(ns,key,function(key){return value[key]}.bind(null,key));return ns},__webpack_require__.n=function(module){var getter=module&&module.__esModule?function(){return module.default}:function(){return module};return __webpack_require__.d(getter,"a",getter),getter},__webpack_require__.o=function(object,property){return Object.prototype.hasOwnProperty.call(object,property)},__webpack_require__.p="",__webpack_require__(__webpack_require__.s=1)}([function(module,exports){module.exports=require("of-type")},function(module,__webpack_exports__,__webpack_require__){"use strict";__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,"default",function(){return typeofArguments});var of_type__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(0),of_type__WEBPACK_IMPORTED_MODULE_0___default=__webpack_require__.n(of_type__WEBPACK_IMPORTED_MODULE_0__);function _construct(Parent,args,Class){return(_construct=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(e){return!1}}()?Reflect.construct:function(Parent,args,Class){var a=[null];a.push.apply(a,args);var instance=new(Function.bind.apply(Parent,a));return Class&&_setPrototypeOf(instance,Class.prototype),instance}).apply(null,arguments)}function _setPrototypeOf(o,p){return(_setPrototypeOf=Object.setPrototypeOf||function(o,p){return o.__proto__=p,o})(o,p)}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}var TypeofArguments=function(){function TypeofArguments(getArgumentsObject,getExpectedArray,callbackFunction){if(function(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}(this,TypeofArguments),!of_type__WEBPACK_IMPORTED_MODULE_0___default()(getArgumentsObject,"arguments"))throw new TypeError("typeof-arguments: The [0] argument must be the [arguments] Object.");if(!of_type__WEBPACK_IMPORTED_MODULE_0___default()(getExpectedArray,Array))throw new TypeError("typeof-arguments: The [1] argument must be of type [Array].");for(var index=0;index<getExpectedArray.length;index++)if(!of_type__WEBPACK_IMPORTED_MODULE_0___default()(getArgumentsObject[index],getExpectedArray[index])){var actual=this.getActualType(getArgumentsObject[index]),types=this.getExpectedTypes(getExpectedArray[index]),textActual="[".concat(actual,"] ").concat(types.addons,"argument"),textExpected=types.message,message="Invalid argument [".concat(index,"]. The ").concat(textActual," has been passed, while the ").concat(textExpected," is expected.");if(of_type__WEBPACK_IMPORTED_MODULE_0___default()(callbackFunction,"function"))return callbackFunction({index:index,actual:actual,expected:types.expected,message:message,textActual:textActual,textExpected:textExpected}),function(){return!1};throw new TypeError(message)}return function(){return!0}}var Constructor,protoProps,staticProps;return Constructor=TypeofArguments,(protoProps=[{key:"getActualType",value:function(actualValue){return of_type__WEBPACK_IMPORTED_MODULE_0___default()(actualValue,null)?"null":of_type__WEBPACK_IMPORTED_MODULE_0___default()(actualValue,void 0)?"undefined":of_type__WEBPACK_IMPORTED_MODULE_0___default()(actualValue,"arguments")?"arguments":actualValue.constructor.name}},{key:"getExpectedTypes",value:function(expectedType){for(var types=["whenString","whenRegExp","whenObject","whenArray"],_i=0;_i<types.length;_i++){var check=this[types[_i]](expectedType);if(check)return check}throw new TypeError("typeof-arguments: The expected type is not callable.")}},{key:"whenString",value:function(stringType){if(!of_type__WEBPACK_IMPORTED_MODULE_0___default()(stringType,String))return null;var msg='argument of type matching string expression "'.concat(stringType,'"'),truthness="",objectable="";return stringType.split("|").forEach(function(i){"truthy"===i.toLowerCase()&&(truthness="<<falsy>> "),"falsy"===i.toLowerCase()&&(truthness="<<truthy>> "),"objectable"===i.toLowerCase()&&(objectable="<<non-objectable>> ")}),{message:msg,addons:truthness+objectable,expected:stringType}}},{key:"whenRegExp",value:function(regType){return of_type__WEBPACK_IMPORTED_MODULE_0___default()(regType,RegExp)?{message:"argument of type matching regular expression ".concat(regType),addons:function(regType){var isCaseInsensitive=regType.flags.match(/i/),str=regType.toString();str=isCaseInsensitive?str.toLowerCase():str;var truthness="",objectable="";str.match(/truthy/)&&(truthness="<<falsy>> ");str.match(/falsy/)&&(truthness="<<truthy>> ");str.match(/objectable/)&&(objectable="<<non-objectable>> ");return truthness+objectable}(regType),expected:regType.toString()}:null}},{key:"whenObject",value:function(objectType){return of_type__WEBPACK_IMPORTED_MODULE_0___default()(objectType,null)?{message:"argument of type [null]",addons:"",expected:"null"}:of_type__WEBPACK_IMPORTED_MODULE_0___default()(objectType,void 0)?{message:"argument of type [undefined]",addons:"",expected:"undefined"}:of_type__WEBPACK_IMPORTED_MODULE_0___default()(objectType,Function)?{message:"argument of type [".concat(objectType.name,"]"),addons:"",expected:objectType.name}:null}},{key:"whenArray",value:function(arrayTypes){if(!of_type__WEBPACK_IMPORTED_MODULE_0___default()(arrayTypes,Array))return null;var types={},_iteratorNormalCompletion=!0,_didIteratorError=!1,_iteratorError=void 0;try{for(var _step,_iterator=arrayTypes[Symbol.iterator]();!(_iteratorNormalCompletion=(_step=_iterator.next()).done);_iteratorNormalCompletion=!0){var _type=_step.value,exp=this.whenObject(_type);if(of_type__WEBPACK_IMPORTED_MODULE_0___default()(exp,null))return null;types[exp.expected]=exp.expected}}catch(err){_didIteratorError=!0,_iteratorError=err}finally{try{_iteratorNormalCompletion||null==_iterator.return||_iterator.return()}finally{if(_didIteratorError)throw _iteratorError}}var expected=Object.getOwnPropertyNames(types).join("|");return{message:"argument of type [".concat(expected,"]"),addons:"",expected:expected}}}])&&_defineProperties(Constructor.prototype,protoProps),staticProps&&_defineProperties(Constructor,staticProps),TypeofArguments}();function typeofArguments(){return _construct(TypeofArguments,Array.prototype.slice.call(arguments))()}}]).default;
module.exports=function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=1)}([function(e,t){e.exports=require("of-type")},function(e,t,n){"use strict";n.r(t),n.d(t,"default",(function(){return p}));var r=n(0),o=n.n(r);function u(e,t,n){return(u=a()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&c(o,n.prototype),o}).apply(null,arguments)}function a(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function i(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return f(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return f(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var u,a=!0,c=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return a=e.done,e},e:function(e){c=!0,u=e},f:function(){try{a||null==n.return||n.return()}finally{if(c)throw u}}}}function f(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function l(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var s=function(){function e(t,n,r){if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),!o()(t,"arguments"))throw new TypeError("typeof-arguments: The [0] argument must be the [arguments] Object.");if(!o()(n,Array))throw new TypeError("typeof-arguments: The [1] argument must be of type [Array].");for(var u=0;u<n.length;u++)if(!o()(t[u],n[u])){var a=this.getActualType(t[u]),c=this.getExpectedTypes(n[u]),i="[".concat(a,"] ").concat(c.addons,"argument"),f=c.message,l="Invalid argument [".concat(u,"]. The ").concat(i," has been passed, while the ").concat(f," is expected.");if(o()(r,"function"))return r({index:u,actual:a,expected:c.expected,message:l,textActual:i,textExpected:f}),function(){return!1};throw new TypeError(l)}return function(){return!0}}var t,n,r;return t=e,(n=[{key:"getActualType",value:function(e){return o()(e,null)?"null":o()(e,void 0)?"undefined":o()(e,"arguments")?"arguments":e.constructor.name}},{key:"getExpectedTypes",value:function(e){for(var t=0,n=["whenString","whenRegExp","whenObject","whenArray"];t<n.length;t++){var r=this[n[t]](e);if(r)return r}throw new TypeError("typeof-arguments: The expected type is not callable.")}},{key:"whenString",value:function(e){if(!o()(e,String))return null;var t='argument of type matching string expression "'.concat(e,'"'),n="",r="";return e.split("|").forEach((function(e){"truthy"===e.toLowerCase()&&(n="<<falsy>> "),"falsy"===e.toLowerCase()&&(n="<<truthy>> "),"objectable"===e.toLowerCase()&&(r="<<non-objectable>> ")})),{message:t,addons:n+r,expected:e}}},{key:"whenRegExp",value:function(e){return o()(e,RegExp)?{message:"argument of type matching regular expression ".concat(e),addons:function(e){var t=e.flags.match(/i/),n=e.toString();n=t?n.toLowerCase():n;var r="",o="";return n.match(/truthy/)&&(r="<<falsy>> "),n.match(/falsy/)&&(r="<<truthy>> "),n.match(/objectable/)&&(o="<<non-objectable>> "),r+o}(e),expected:e.toString()}:null}},{key:"whenObject",value:function(e){return o()(e,null)?{message:"argument of type [null]",addons:"",expected:"null"}:o()(e,void 0)?{message:"argument of type [undefined]",addons:"",expected:"undefined"}:o()(e,Function)?{message:"argument of type [".concat(e.name,"]"),addons:"",expected:e.name}:null}},{key:"whenArray",value:function(e){if(!o()(e,Array))return null;var t,n={},r=i(e);try{for(r.s();!(t=r.n()).done;){var u=t.value,a=this.whenObject(u);if(o()(a,null))return null;n[a.expected]=a.expected}}catch(e){r.e(e)}finally{r.f()}var c=Object.getOwnPropertyNames(n).join("|");return{message:"argument of type [".concat(c,"]"),addons:"",expected:c}}}])&&l(t.prototype,n),r&&l(t,r),e}();function p(){return u(s,Array.prototype.slice.call(arguments))()}}]).default;
{
"name": "typeof-arguments",
"version": "5.1.1",
"version": "5.1.2",
"description": "Validate the type of arguments passed through the function.",
"main": "dist/typeof-arguments.node.js",
"scripts": {
"test": "babel-node jasmine.conf.js",
"start": "webpack --config webpack.dev.js",
"build": "webpack --config webpack.prod.js"
"start": "webpack --env.dev",
"build": "webpack --env.prod",
"test": "babel-node jasmine.conf.js"
},

@@ -22,3 +22,3 @@ "keywords": [

"dependencies": {
"of-type": "^3.0.2"
"of-type": "^3.0.3"
},

@@ -34,15 +34,15 @@ "homepage": "https://github.com/devrafalko/typeof-arguments#readme",

"devDependencies": {
"@babel/cli": "^7.1.0",
"@babel/core": "^7.0.1",
"@babel/node": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"babel-loader": "^8.0.2",
"jasmine": "^3.3.1",
"jasmine-spec-reporter": "^4.2.1",
"uglifyjs-webpack-plugin": "^2.1.1",
"webpack": "^4.19.1",
"webpack-cli": "^3.1.1",
"webpack-merge": "^4.1.4",
"webpack-node-externals": "^1.7.2"
"@babel/cli": "^7.10.5",
"@babel/core": "^7.11.1",
"@babel/node": "^7.10.5",
"@babel/preset-env": "^7.11.0",
"babel-loader": "^8.1.0",
"jasmine": "^3.6.1",
"jasmine-spec-reporter": "^5.0.2",
"terser-webpack-plugin": "^4.1.0",
"webpack": "^4.44.1",
"webpack-cli": "^3.3.12",
"webpack-merge": "^5.1.1",
"webpack-node-externals": "^2.5.1"
}
}
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