New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

util-array-object-or-both

Package Overview
Dependencies
Maintainers
1
Versions
152
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

util-array-object-or-both - npm Package Compare versions

Comparing version 2.0.2 to 2.0.3

2

dist/util-array-object-or-both.umd.js

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

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.arrObjOrBoth=e()}(this,function(){"use strict";var t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},e=1/0,r=9007199254740991,n=1.7976931348623157e308,o=NaN,i="[object Arguments]",a="[object Function]",c="[object GeneratorFunction]",u="[object String]",s="[object Symbol]",f=/^\s+|\s+$/g,l=/^[-+]0x[0-9a-f]+$/i,y=/^0b[01]+$/i,p=/^0o[0-7]+$/i,h=/^(?:0|[1-9]\d*)$/,m=parseInt;function g(t){return t!=t}function b(t,e){return function(t,e){for(var r=-1,n=t?t.length:0,o=Array(n);++r<n;)o[r]=e(t[r],r,t);return o}(e,function(e){return t[e]})}var d,v,w=Object.prototype,j=w.hasOwnProperty,_=w.toString,O=w.propertyIsEnumerable,S=(d=Object.keys,v=Object,function(t){return d(v(t))}),k=Math.max;function T(t,e){var r=N(t)||function(t){return function(t){return I(t)&&M(t)}(t)&&j.call(t,"callee")&&(!O.call(t,"callee")||_.call(t)==i)}(t)?function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}(t.length,String):[],n=r.length,o=!!n;for(var a in t)!e&&!j.call(t,a)||o&&("length"==a||E(a,n))||r.push(a);return r}function A(t){if(r=(e=t)&&e.constructor,n="function"==typeof r&&r.prototype||w,e!==n)return S(t);var e,r,n,o=[];for(var i in Object(t))j.call(t,i)&&"constructor"!=i&&o.push(i);return o}function E(t,e){return!!(e=null==e?r:e)&&("number"==typeof t||h.test(t))&&t>-1&&t%1==0&&t<e}var N=Array.isArray;function M(t){return null!=t&&function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=r}(t.length)&&!function(t){var e=V(t)?_.call(t):"";return e==a||e==c}(t)}function V(e){var r=void 0===e?"undefined":t(e);return!!e&&("object"==r||"function"==r)}function I(e){return!!e&&"object"==(void 0===e?"undefined":t(e))}var P=function(r,i,a,c){var h;r=M(r)?r:(h=r)?b(h,function(t){return M(t)?T(t):A(t)}(h)):[],a=a&&!c?function(r){var i=function(r){if(!r)return 0===r?r:0;if((r=function(e){if("number"==typeof e)return e;if(function(e){return"symbol"==(void 0===e?"undefined":t(e))||I(e)&&_.call(e)==s}(e))return o;if(V(e)){var r="function"==typeof e.valueOf?e.valueOf():e;e=V(r)?r+"":r}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(f,"");var n=y.test(e);return n||p.test(e)?m(e.slice(2),n?2:8):l.test(e)?o:+e}(r))===e||r===-e){var i=r<0?-1:1;return i*n}return r==r?r:0}(r),a=i%1;return i==i?a?i-a:i:0}(a):0;var d=r.length;return a<0&&(a=k(d+a,0)),function(t){return"string"==typeof t||!N(t)&&I(t)&&_.call(t)==u}(r)?a<=d&&r.indexOf(i,a)>-1:!!d&&function(t,e,r){if(e!=e)return function(t,e,r,n){for(var o=t.length,i=r+(n?1:-1);n?i--:++i<o;)if(e(t[i],i,t))return i;return-1}(t,g,r);for(var n=r-1,o=t.length;++n<o;)if(t[n]===e)return n;return-1}(r,i,a)>-1},C="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var L,K="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},x=(function(t,e){var r,n,o,i,a,c,u,s,f,l,y,p,h,m,g,b,d,v,w,j;t.exports=(r="function"==typeof Promise,n="object"===("undefined"==typeof self?"undefined":K(self))?self:C,o="undefined"!=typeof Symbol,i="undefined"!=typeof Map,a="undefined"!=typeof Set,c="undefined"!=typeof WeakMap,u="undefined"!=typeof WeakSet,s="undefined"!=typeof DataView,f=o&&void 0!==Symbol.iterator,l=o&&void 0!==Symbol.toStringTag,y=a&&"function"==typeof Set.prototype.entries,p=i&&"function"==typeof Map.prototype.entries,h=y&&Object.getPrototypeOf((new Set).entries()),m=p&&Object.getPrototypeOf((new Map).entries()),g=f&&"function"==typeof Array.prototype[Symbol.iterator],b=g&&Object.getPrototypeOf([][Symbol.iterator]()),d=f&&"function"==typeof String.prototype[Symbol.iterator],v=d&&Object.getPrototypeOf(""[Symbol.iterator]()),w=8,j=-1,function(t){var e=void 0===t?"undefined":K(t);if("object"!==e)return e;if(null===t)return"null";if(t===n)return"global";if(Array.isArray(t)&&(!1===l||!(Symbol.toStringTag in t)))return"Array";if("object"===("undefined"==typeof window?"undefined":K(window))){if("object"===K(window.location)&&t===window.location)return"Location";if("object"===K(window.document)&&t===window.document)return"Document";if("object"===K(window.navigator)){if("object"===K(window.navigator.mimeTypes)&&t===window.navigator.mimeTypes)return"MimeTypeArray";if("object"===K(window.navigator.plugins)&&t===window.navigator.plugins)return"PluginArray"}if(("function"==typeof window.HTMLElement||"object"===K(window.HTMLElement))&&t instanceof window.HTMLElement){if("BLOCKQUOTE"===t.tagName)return"HTMLQuoteElement";if("TD"===t.tagName)return"HTMLTableDataCellElement";if("TH"===t.tagName)return"HTMLTableHeaderCellElement"}}var o=l&&t[Symbol.toStringTag];if("string"==typeof o)return o;var f=Object.getPrototypeOf(t);return f===RegExp.prototype?"RegExp":f===Date.prototype?"Date":r&&f===Promise.prototype?"Promise":a&&f===Set.prototype?"Set":i&&f===Map.prototype?"Map":u&&f===WeakSet.prototype?"WeakSet":c&&f===WeakMap.prototype?"WeakMap":s&&f===DataView.prototype?"DataView":i&&f===m?"Map Iterator":a&&f===h?"Set Iterator":g&&f===b?"Array Iterator":d&&f===v?"String Iterator":null===f?"Object":Object.prototype.toString.call(t).slice(w,j)})}(L={exports:{}},L.exports),L.exports);function D(t,e,r){if(e!=e)return function(t,e,r,n){for(var o=t.length,i=r+(n?1:-1);n?i--:++i<o;)if(e(t[i],i,t))return i;return-1}(t,W,r);for(var n=r-1,o=t.length;++n<o;)if(t[n]===e)return n;return-1}function H(t,e,r,n){for(var o=r-1,i=t.length;++o<i;)if(n(t[o],e))return o;return-1}function W(t){return t!=t}var $=Array.prototype.splice;function J(t,e,r,n){var o,i=n?H:D,a=-1,c=e.length,u=t;for(t===e&&(e=function(t,e){var r=-1,n=t.length;e||(e=Array(n));for(;++r<n;)e[r]=t[r];return e}(e)),r&&(u=function(t,e){for(var r=-1,n=t?t.length:0,o=Array(n);++r<n;)o[r]=e(t[r],r,t);return o}(t,(o=r,function(t){return o(t)})));++a<c;)for(var s=0,f=e[a],l=r?r(f):f;(s=i(u,l,s,n))>-1;)u!==t&&$.call(u,s,1),$.call(t,s,1);return t}var R=function(t,e){return t&&t.length&&e&&e.length?J(t,e):t},F="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},q="__lodash_hash_undefined__",B=9007199254740991,G="[object Function]",Q="[object GeneratorFunction]",U=/^\[object .+?Constructor\]$/,z="object"==F(C)&&C&&C.Object===Object&&C,X="object"==("undefined"==typeof self?"undefined":F(self))&&self&&self.Object===Object&&self,Y=z||X||Function("return this")();function Z(t,e){return!!(t?t.length:0)&&function(t,e,r){if(e!=e)return function(t,e,r,n){var o=t.length,i=r+(n?1:-1);for(;n?i--:++i<o;)if(e(t[i],i,t))return i;return-1}(t,rt,r);var n=r-1,o=t.length;for(;++n<o;)if(t[n]===e)return n;return-1}(t,e,0)>-1}function tt(t,e,r){for(var n=-1,o=t?t.length:0;++n<o;)if(r(e,t[n]))return!0;return!1}function et(t,e){for(var r=-1,n=t?t.length:0,o=Array(n);++r<n;)o[r]=e(t[r],r,t);return o}function rt(t){return t!=t}function nt(t){return function(e){return t(e)}}function ot(t,e){return t.has(e)}var it,at=Array.prototype,ct=Function.prototype,ut=Object.prototype,st=Y["__core-js_shared__"],ft=(it=/[^.]+$/.exec(st&&st.keys&&st.keys.IE_PROTO||""))?"Symbol(src)_1."+it:"",lt=ct.toString,yt=ut.hasOwnProperty,pt=ut.toString,ht=RegExp("^"+lt.call(yt).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),mt=at.splice,gt=Math.max,bt=Math.min,dt=Et(Y,"Map"),vt=Et(Object,"create");function wt(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function jt(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function _t(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function Ot(t){var e=-1,r=t?t.length:0;for(this.__data__=new _t;++e<r;)this.add(t[e])}function St(t,e){for(var r,n,o=t.length;o--;)if((r=t[o][0])===(n=e)||r!=r&&n!=n)return o;return-1}function kt(t){return!(!Mt(t)||ft&&ft in t)&&(Nt(t)||function(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}(t)?ht:U).test(function(t){if(null!=t){try{return lt.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t))}function Tt(t){return function(t){return function(t){return!!t&&"object"==(void 0===t?"undefined":F(t))}(t)&&function(t){return null!=t&&function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=B}(t.length)&&!Nt(t)}(t)}(t)?t:[]}function At(t,e){var r,n,o=t.__data__;return("string"==(n=void 0===(r=e)?"undefined":F(r))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==r:null===r)?o["string"==typeof e?"string":"hash"]:o.map}function Et(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return kt(r)?r:void 0}function Nt(t){var e=Mt(t)?pt.call(t):"";return e==G||e==Q}function Mt(t){var e=void 0===t?"undefined":F(t);return!!t&&("object"==e||"function"==e)}wt.prototype.clear=function(){this.__data__=vt?vt(null):{}},wt.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},wt.prototype.get=function(t){var e=this.__data__;if(vt){var r=e[t];return r===q?void 0:r}return yt.call(e,t)?e[t]:void 0},wt.prototype.has=function(t){var e=this.__data__;return vt?void 0!==e[t]:yt.call(e,t)},wt.prototype.set=function(t,e){return this.__data__[t]=vt&&void 0===e?q:e,this},jt.prototype.clear=function(){this.__data__=[]},jt.prototype.delete=function(t){var e=this.__data__,r=St(e,t);return!(r<0||(r==e.length-1?e.pop():mt.call(e,r,1),0))},jt.prototype.get=function(t){var e=this.__data__,r=St(e,t);return r<0?void 0:e[r][1]},jt.prototype.has=function(t){return St(this.__data__,t)>-1},jt.prototype.set=function(t,e){var r=this.__data__,n=St(r,t);return n<0?r.push([t,e]):r[n][1]=e,this},_t.prototype.clear=function(){this.__data__={hash:new wt,map:new(dt||jt),string:new wt}},_t.prototype.delete=function(t){return At(this,t).delete(t)},_t.prototype.get=function(t){return At(this,t).get(t)},_t.prototype.has=function(t){return At(this,t).has(t)},_t.prototype.set=function(t,e){return At(this,t).set(t,e),this},Ot.prototype.add=Ot.prototype.push=function(t){return this.__data__.set(t,q),this},Ot.prototype.has=function(t){return this.__data__.has(t)};var Vt=function(t,e){return e=gt(void 0===e?t.length-1:e,0),function(){for(var r=arguments,n=-1,o=gt(r.length-e,0),i=Array(o);++n<o;)i[n]=r[e+n];n=-1;for(var a=Array(e+1);++n<e;)a[n]=r[n];return a[e]=i,function(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}(t,this,a)}}(function(t){var e=et(t,Tt);return e.length&&e[0]===t[0]?function(t,e,r){for(var n=r?tt:Z,o=t[0].length,i=t.length,a=i,c=Array(i),u=1/0,s=[];a--;){var f=t[a];a&&e&&(f=et(f,nt(e))),u=bt(f.length,u),c[a]=!r&&(e||o>=120&&f.length>=120)?new Ot(a&&f):void 0}f=t[0];var l=-1,y=c[0];t:for(;++l<o&&s.length<u;){var p=f[l],h=e?e(p):p;if(p=r||0!==p?p:0,!(y?ot(y,h):n(s,h,r))){for(a=i;--a;){var m=c[a];if(!(m?ot(m,h):n(t[a],h,r)))continue t}y&&y.push(h),s.push(p)}}return s}(e):[]});function It(t){return"string"==typeof t?t.length>0?[t]:[]:t}var Pt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ct="[object Object]";var Lt=Function.prototype,Kt=Object.prototype,xt=Lt.toString,Dt=Kt.hasOwnProperty,Ht=xt.call(Object),Wt=Kt.toString,$t=function(t,e){return function(r){return t(e(r))}}(Object.getPrototypeOf,Object);var Jt=function(t){if(!function(t){return!!t&&"object"==(void 0===t?"undefined":Pt(t))}(t)||Wt.call(t)!=Ct||function(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}(t))return!1;var e=$t(t);if(null===e)return!0;var r=Dt.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&xt.call(r)==Ht},Rt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};return function(t,e){function r(t){return null!=t}if(!r(t))throw new Error("util-array-object-or-both/validate(): [THROW_ID_01] Please provide a string to work on. Currently it's equal to "+JSON.stringify(t,null,4));if("string"!=typeof t)throw new Error("util-array-object-or-both/validate(): [THROW_ID_02] Input must be string! Currently it's "+(void 0===t?"undefined":Rt(t))+", equal to: "+JSON.stringify(t,null,4));if(r(e)&&!Jt(e))throw new Error("util-array-object-or-both/validate(): [THROW_ID_03] Second argument, options object, must be, well, object! Currenlty it's: "+(void 0===e?"undefined":Rt(e))+", equal to: "+JSON.stringify(e,null,4));var n={msg:"",optsVarName:"given variable"},o=Object.assign({},n,e);if(function(t,e,r){function n(t){return null!=t}function o(t){return"boolean"===x(t)}function i(t){return"string"===x(t)}function a(t){return"Object"===x(t)}var c=["any","anything","every","everything","all","whatever","whatevs"],u=Array.isArray;if(0===arguments.length)throw new Error("check-types-mini/checkTypes(): Missing all arguments!");if(1===arguments.length)throw new Error("check-types-mini/checkTypes(): Missing second argument!");var s=a(e)?e:{},f={ignoreKeys:[],acceptArrays:!1,acceptArraysIgnore:[],enforceStrictKeyset:!0,schema:{},msg:"check-types-mini/checkTypes()",optsVarName:"opts"},l=void 0;if(!i((l=n(r)&&a(r)?Object.assign({},f,r):Object.assign({},f)).msg))throw new Error("check-types-mini/checkTypes(): opts.msg must be string! Currently it's: "+x(l.msg)+", equal to "+JSON.stringify(l.msg,null,4));if(l.msg=l.msg.trim(),":"===l.msg[l.msg.length-1]&&(l.msg=l.msg.slice(0,l.msg.length-1)),!i(l.optsVarName))throw new Error("check-types-mini/checkTypes(): opts.optsVarName must be string! Currently it's: "+x(l.optsVarName)+", equal to "+JSON.stringify(l.optsVarName,null,4));if(l.ignoreKeys=It(l.ignoreKeys),l.acceptArraysIgnore=It(l.acceptArraysIgnore),!u(l.ignoreKeys))throw new TypeError("check-types-mini/checkTypes(): opts.ignoreKeys should be an array, currently it's: "+x(l.ignoreKeys));if(!o(l.acceptArrays))throw new TypeError("check-types-mini/checkTypes(): opts.acceptArrays should be a Boolean, currently it's: "+x(l.acceptArrays));if(!u(l.acceptArraysIgnore))throw new TypeError("check-types-mini/checkTypes(): opts.acceptArraysIgnore should be an array, currently it's: "+x(l.acceptArraysIgnore));if(!o(l.enforceStrictKeyset))throw new TypeError("check-types-mini/checkTypes(): opts.enforceStrictKeyset should be a Boolean, currently it's: "+x(l.enforceStrictKeyset));if(Object.keys(l.schema).forEach(function(t){u(l.schema[t])||(l.schema[t]=[l.schema[t]]),l.schema[t]=l.schema[t].map(String).map(function(t){return t.toLowerCase()}).map(function(t){return t.trim()})}),l.enforceStrictKeyset)if(n(l.schema)&&Object.keys(l.schema).length>0){if(0!==R(Object.keys(t),Object.keys(s).concat(Object.keys(l.schema))).length)throw new TypeError(l.msg+": "+l.optsVarName+".enforceStrictKeyset is on and the following keys are not covered by schema and/or reference objects: "+JSON.stringify(R(Object.keys(t),Object.keys(s).concat(Object.keys(l.schema))),null,4))}else{if(!(n(s)&&Object.keys(s).length>0))throw new TypeError(l.msg+": Both "+l.optsVarName+".schema and reference objects are missing! We don't have anything to match the keys as you requested via opts.enforceStrictKeyset!");if(0!==R(Object.keys(t),Object.keys(s)).length)throw new TypeError(l.msg+": The input object has keys that are not covered by reference object: "+JSON.stringify(R(Object.keys(t),Object.keys(s)),null,4));if(0!==R(Object.keys(s),Object.keys(t)).length)throw new TypeError(l.msg+": The reference object has keys that are not present in the input object: "+JSON.stringify(R(Object.keys(s),Object.keys(t)),null,4))}Object.keys(t).forEach(function(e){if(n(l.schema)&&Object.prototype.hasOwnProperty.call(l.schema,e)){if(l.schema[e]=It(l.schema[e]).map(String).map(function(t){return t.toLowerCase()}),!Vt(l.schema[e],c).length&&!P(l.schema[e],x(t[e]).toLowerCase())){if(!u(t[e])||!l.acceptArrays)throw new TypeError(l.msg+": "+l.optsVarName+"."+e+" was customised to "+JSON.stringify(t[e],null,4)+" which is not among the allowed types in schema ("+l.schema[e]+") but "+x(t[e]));for(var r=0,o=t[e].length;r<o;r++)if(!P(l.schema[e],x(t[e][r]).toLowerCase()))throw new TypeError(l.msg+": "+l.optsVarName+"."+e+" is of type "+x(t[e][r]).toLowerCase()+", but only the following are allowed in "+l.optsVarName+".schema: "+l.schema[e])}}else if(n(s)&&Object.prototype.hasOwnProperty.call(s,e)&&x(t[e])!==x(s[e])&&!P(l.ignoreKeys,e)){if(!l.acceptArrays||!u(t[e])||P(l.acceptArraysIgnore,e))throw new TypeError(l.msg+": "+l.optsVarName+"."+e+" was customised to "+JSON.stringify(t[e],null,4)+" which is not "+x(s[e])+" but "+x(t[e]));if(!t[e].every(function(t){return x(t)===x(s[e])}))throw new TypeError(l.msg+": "+l.optsVarName+"."+e+" was customised to be array, but not all of its elements are "+x(s[e])+"-type")}})}(o,n,{msg:"util-array-object-or-both/validate(): [THROW_ID_03]",optsVarName:"opts",schema:{msg:["string",null],optsVarName:["string",null]}}),r(o.msg)&&o.msg.length>0&&(o.msg=o.msg.trim()+" "),"given variable"!==o.optsVarName&&(o.optsVarName='variable "'+o.optsVarName+'"'),P(["object","objects","obj","ob","o"],t.toLowerCase().trim()))return"object";if(P(["array","arrays","arr","aray","arr","a"],t.toLowerCase().trim()))return"array";if(P(["any","all","everything","both","either","each","whatever","whatevs","e"],t.toLowerCase().trim()))return"any";throw new TypeError(o.msg+"The "+o.optsVarName+" was customised to an unrecognised value: "+t+". Please check it against the API documentation.")}});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.arrObjOrBoth=e()}(this,function(){"use strict";var t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},e=1/0,r=9007199254740991,n=1.7976931348623157e308,o=NaN,i="[object Arguments]",a="[object Function]",c="[object GeneratorFunction]",u="[object String]",s="[object Symbol]",f=/^\s+|\s+$/g,l=/^[-+]0x[0-9a-f]+$/i,y=/^0b[01]+$/i,p=/^0o[0-7]+$/i,h=/^(?:0|[1-9]\d*)$/,m=parseInt;function g(t){return t!=t}function b(t,e){return function(t,e){for(var r=-1,n=t?t.length:0,o=Array(n);++r<n;)o[r]=e(t[r],r,t);return o}(e,function(e){return t[e]})}var d,v,w=Object.prototype,_=w.hasOwnProperty,j=w.toString,O=w.propertyIsEnumerable,S=(d=Object.keys,v=Object,function(t){return d(v(t))}),T=Math.max;function k(t,e){var r=N(t)||function(t){return function(t){return V(t)&&I(t)}(t)&&_.call(t,"callee")&&(!O.call(t,"callee")||j.call(t)==i)}(t)?function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}(t.length,String):[],n=r.length,o=!!n;for(var a in t)!e&&!_.call(t,a)||o&&("length"==a||E(a,n))||r.push(a);return r}function A(t){if(r=(e=t)&&e.constructor,n="function"==typeof r&&r.prototype||w,e!==n)return S(t);var e,r,n,o=[];for(var i in Object(t))_.call(t,i)&&"constructor"!=i&&o.push(i);return o}function E(t,e){return!!(e=null==e?r:e)&&("number"==typeof t||h.test(t))&&t>-1&&t%1==0&&t<e}var N=Array.isArray;function I(t){return null!=t&&function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=r}(t.length)&&!function(t){var e=M(t)?j.call(t):"";return e==a||e==c}(t)}function M(e){var r=void 0===e?"undefined":t(e);return!!e&&("object"==r||"function"==r)}function V(e){return!!e&&"object"==(void 0===e?"undefined":t(e))}var D=function(r,i,a,c){var h;r=I(r)?r:(h=r)?b(h,function(t){return I(t)?k(t):A(t)}(h)):[],a=a&&!c?function(r){var i=function(r){if(!r)return 0===r?r:0;if((r=function(e){if("number"==typeof e)return e;if(function(e){return"symbol"==(void 0===e?"undefined":t(e))||V(e)&&j.call(e)==s}(e))return o;if(M(e)){var r="function"==typeof e.valueOf?e.valueOf():e;e=M(r)?r+"":r}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(f,"");var n=y.test(e);return n||p.test(e)?m(e.slice(2),n?2:8):l.test(e)?o:+e}(r))===e||r===-e){var i=r<0?-1:1;return i*n}return r==r?r:0}(r),a=i%1;return i==i?a?i-a:i:0}(a):0;var d=r.length;return a<0&&(a=T(d+a,0)),function(t){return"string"==typeof t||!N(t)&&V(t)&&j.call(t)==u}(r)?a<=d&&r.indexOf(i,a)>-1:!!d&&function(t,e,r){if(e!=e)return function(t,e,r,n){for(var o=t.length,i=r+(n?1:-1);n?i--:++i<o;)if(e(t[i],i,t))return i;return-1}(t,g,r);for(var n=r-1,o=t.length;++n<o;)if(t[n]===e)return n;return-1}(r,i,a)>-1},H="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var P,W="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},C=(function(t,e){var r,n,o,i,a,c,u,s,f,l,y,p,h,m,g,b,d,v,w,_;t.exports=(r="function"==typeof Promise,n="object"===("undefined"==typeof self?"undefined":W(self))?self:H,o="undefined"!=typeof Symbol,i="undefined"!=typeof Map,a="undefined"!=typeof Set,c="undefined"!=typeof WeakMap,u="undefined"!=typeof WeakSet,s="undefined"!=typeof DataView,f=o&&void 0!==Symbol.iterator,l=o&&void 0!==Symbol.toStringTag,y=a&&"function"==typeof Set.prototype.entries,p=i&&"function"==typeof Map.prototype.entries,h=y&&Object.getPrototypeOf((new Set).entries()),m=p&&Object.getPrototypeOf((new Map).entries()),g=f&&"function"==typeof Array.prototype[Symbol.iterator],b=g&&Object.getPrototypeOf([][Symbol.iterator]()),d=f&&"function"==typeof String.prototype[Symbol.iterator],v=d&&Object.getPrototypeOf(""[Symbol.iterator]()),w=8,_=-1,function(t){var e=void 0===t?"undefined":W(t);if("object"!==e)return e;if(null===t)return"null";if(t===n)return"global";if(Array.isArray(t)&&(!1===l||!(Symbol.toStringTag in t)))return"Array";if("object"===("undefined"==typeof window?"undefined":W(window))){if("object"===W(window.location)&&t===window.location)return"Location";if("object"===W(window.document)&&t===window.document)return"Document";if("object"===W(window.navigator)){if("object"===W(window.navigator.mimeTypes)&&t===window.navigator.mimeTypes)return"MimeTypeArray";if("object"===W(window.navigator.plugins)&&t===window.navigator.plugins)return"PluginArray"}if(("function"==typeof window.HTMLElement||"object"===W(window.HTMLElement))&&t instanceof window.HTMLElement){if("BLOCKQUOTE"===t.tagName)return"HTMLQuoteElement";if("TD"===t.tagName)return"HTMLTableDataCellElement";if("TH"===t.tagName)return"HTMLTableHeaderCellElement"}}var o=l&&t[Symbol.toStringTag];if("string"==typeof o)return o;var f=Object.getPrototypeOf(t);return f===RegExp.prototype?"RegExp":f===Date.prototype?"Date":r&&f===Promise.prototype?"Promise":a&&f===Set.prototype?"Set":i&&f===Map.prototype?"Map":u&&f===WeakSet.prototype?"WeakSet":c&&f===WeakMap.prototype?"WeakMap":s&&f===DataView.prototype?"DataView":i&&f===m?"Map Iterator":a&&f===h?"Set Iterator":g&&f===b?"Array Iterator":d&&f===v?"String Iterator":null===f?"Object":Object.prototype.toString.call(t).slice(w,_)})}(P={exports:{}},P.exports),P.exports);function L(t,e,r){if(e!=e)return function(t,e,r,n){for(var o=t.length,i=r+(n?1:-1);n?i--:++i<o;)if(e(t[i],i,t))return i;return-1}(t,K,r);for(var n=r-1,o=t.length;++n<o;)if(t[n]===e)return n;return-1}function R(t,e,r,n){for(var o=r-1,i=t.length;++o<i;)if(n(t[o],e))return o;return-1}function K(t){return t!=t}var x=Array.prototype.splice;function $(t,e,r,n){var o,i=n?R:L,a=-1,c=e.length,u=t;for(t===e&&(e=function(t,e){var r=-1,n=t.length;e||(e=Array(n));for(;++r<n;)e[r]=t[r];return e}(e)),r&&(u=function(t,e){for(var r=-1,n=t?t.length:0,o=Array(n);++r<n;)o[r]=e(t[r],r,t);return o}(t,(o=r,function(t){return o(t)})));++a<c;)for(var s=0,f=e[a],l=r?r(f):f;(s=i(u,l,s,n))>-1;)u!==t&&x.call(u,s,1),x.call(t,s,1);return t}var J=function(t,e){return t&&t.length&&e&&e.length?$(t,e):t},F="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},q="__lodash_hash_undefined__",B=9007199254740991,G="[object Function]",Q="[object GeneratorFunction]",U=/^\[object .+?Constructor\]$/,z="object"==F(H)&&H&&H.Object===Object&&H,X="object"==("undefined"==typeof self?"undefined":F(self))&&self&&self.Object===Object&&self,Y=z||X||Function("return this")();function Z(t,e){return!!(t?t.length:0)&&function(t,e,r){if(e!=e)return function(t,e,r,n){var o=t.length,i=r+(n?1:-1);for(;n?i--:++i<o;)if(e(t[i],i,t))return i;return-1}(t,rt,r);var n=r-1,o=t.length;for(;++n<o;)if(t[n]===e)return n;return-1}(t,e,0)>-1}function tt(t,e,r){for(var n=-1,o=t?t.length:0;++n<o;)if(r(e,t[n]))return!0;return!1}function et(t,e){for(var r=-1,n=t?t.length:0,o=Array(n);++r<n;)o[r]=e(t[r],r,t);return o}function rt(t){return t!=t}function nt(t){return function(e){return t(e)}}function ot(t,e){return t.has(e)}var it,at=Array.prototype,ct=Function.prototype,ut=Object.prototype,st=Y["__core-js_shared__"],ft=(it=/[^.]+$/.exec(st&&st.keys&&st.keys.IE_PROTO||""))?"Symbol(src)_1."+it:"",lt=ct.toString,yt=ut.hasOwnProperty,pt=ut.toString,ht=RegExp("^"+lt.call(yt).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),mt=at.splice,gt=Math.max,bt=Math.min,dt=Et(Y,"Map"),vt=Et(Object,"create");function wt(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function _t(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function jt(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function Ot(t){var e=-1,r=t?t.length:0;for(this.__data__=new jt;++e<r;)this.add(t[e])}function St(t,e){for(var r,n,o=t.length;o--;)if((r=t[o][0])===(n=e)||r!=r&&n!=n)return o;return-1}function Tt(t){return!(!It(t)||ft&&ft in t)&&(Nt(t)||function(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}(t)?ht:U).test(function(t){if(null!=t){try{return lt.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t))}function kt(t){return function(t){return function(t){return!!t&&"object"==(void 0===t?"undefined":F(t))}(t)&&function(t){return null!=t&&function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=B}(t.length)&&!Nt(t)}(t)}(t)?t:[]}function At(t,e){var r,n,o=t.__data__;return("string"==(n=void 0===(r=e)?"undefined":F(r))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==r:null===r)?o["string"==typeof e?"string":"hash"]:o.map}function Et(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return Tt(r)?r:void 0}function Nt(t){var e=It(t)?pt.call(t):"";return e==G||e==Q}function It(t){var e=void 0===t?"undefined":F(t);return!!t&&("object"==e||"function"==e)}wt.prototype.clear=function(){this.__data__=vt?vt(null):{}},wt.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},wt.prototype.get=function(t){var e=this.__data__;if(vt){var r=e[t];return r===q?void 0:r}return yt.call(e,t)?e[t]:void 0},wt.prototype.has=function(t){var e=this.__data__;return vt?void 0!==e[t]:yt.call(e,t)},wt.prototype.set=function(t,e){return this.__data__[t]=vt&&void 0===e?q:e,this},_t.prototype.clear=function(){this.__data__=[]},_t.prototype.delete=function(t){var e=this.__data__,r=St(e,t);return!(r<0||(r==e.length-1?e.pop():mt.call(e,r,1),0))},_t.prototype.get=function(t){var e=this.__data__,r=St(e,t);return r<0?void 0:e[r][1]},_t.prototype.has=function(t){return St(this.__data__,t)>-1},_t.prototype.set=function(t,e){var r=this.__data__,n=St(r,t);return n<0?r.push([t,e]):r[n][1]=e,this},jt.prototype.clear=function(){this.__data__={hash:new wt,map:new(dt||_t),string:new wt}},jt.prototype.delete=function(t){return At(this,t).delete(t)},jt.prototype.get=function(t){return At(this,t).get(t)},jt.prototype.has=function(t){return At(this,t).has(t)},jt.prototype.set=function(t,e){return At(this,t).set(t,e),this},Ot.prototype.add=Ot.prototype.push=function(t){return this.__data__.set(t,q),this},Ot.prototype.has=function(t){return this.__data__.has(t)};var Mt=function(t,e){return e=gt(void 0===e?t.length-1:e,0),function(){for(var r=arguments,n=-1,o=gt(r.length-e,0),i=Array(o);++n<o;)i[n]=r[e+n];n=-1;for(var a=Array(e+1);++n<e;)a[n]=r[n];return a[e]=i,function(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}(t,this,a)}}(function(t){var e=et(t,kt);return e.length&&e[0]===t[0]?function(t,e,r){for(var n=r?tt:Z,o=t[0].length,i=t.length,a=i,c=Array(i),u=1/0,s=[];a--;){var f=t[a];a&&e&&(f=et(f,nt(e))),u=bt(f.length,u),c[a]=!r&&(e||o>=120&&f.length>=120)?new Ot(a&&f):void 0}f=t[0];var l=-1,y=c[0];t:for(;++l<o&&s.length<u;){var p=f[l],h=e?e(p):p;if(p=r||0!==p?p:0,!(y?ot(y,h):n(s,h,r))){for(a=i;--a;){var m=c[a];if(!(m?ot(m,h):n(t[a],h,r)))continue t}y&&y.push(h),s.push(p)}}return s}(e):[]});function Vt(t){return"string"==typeof t?t.length>0?[t]:[]:t}var Dt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ht="[object Object]";var Pt=Function.prototype,Wt=Object.prototype,Ct=Pt.toString,Lt=Wt.hasOwnProperty,Rt=Ct.call(Object),Kt=Wt.toString,xt=function(t,e){return function(r){return t(e(r))}}(Object.getPrototypeOf,Object);var $t=function(t){if(!function(t){return!!t&&"object"==(void 0===t?"undefined":Dt(t))}(t)||Kt.call(t)!=Ht||function(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}(t))return!1;var e=xt(t);if(null===e)return!0;var r=Lt.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&Ct.call(r)==Rt},Jt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};return function(t,e){function r(t){return null!=t}if(!r(t))throw new Error("util-array-object-or-both/validate(): [THROW_ID_01] Please provide a string to work on. Currently it's equal to "+JSON.stringify(t,null,4));if("string"!=typeof t)throw new Error("util-array-object-or-both/validate(): [THROW_ID_02] Input must be string! Currently it's "+(void 0===t?"undefined":Jt(t))+", equal to: "+JSON.stringify(t,null,4));if(r(e)&&!$t(e))throw new Error("util-array-object-or-both/validate(): [THROW_ID_03] Second argument, options object, must be, well, object! Currenlty it's: "+(void 0===e?"undefined":Jt(e))+", equal to: "+JSON.stringify(e,null,4));var n={msg:"",optsVarName:"given variable"},o=Object.assign({},n,e);if(function(t,e,r){function n(t){return null!=t}function o(t){return"boolean"===C(t)}function i(t){return"string"===C(t)}function a(t){return"Object"===C(t)}var c=["any","anything","every","everything","all","whatever","whatevs"],u=Array.isArray;if(0===arguments.length)throw new Error("check-types-mini: [THROW_ID_01] Missing all arguments!");if(1===arguments.length)throw new Error("check-types-mini: [THROW_ID_02] Missing second argument!");var s=a(e)?e:{},f={ignoreKeys:[],acceptArrays:!1,acceptArraysIgnore:[],enforceStrictKeyset:!0,schema:{},msg:"check-types-mini",optsVarName:"opts"},l=void 0;if(!i((l=n(r)&&a(r)?Object.assign({},f,r):Object.assign({},f)).msg))throw new Error("check-types-mini: [THROW_ID_03] opts.msg must be string! Currently it's: "+C(l.msg)+", equal to "+JSON.stringify(l.msg,null,4));if(l.msg=l.msg.trim(),":"===l.msg[l.msg.length-1]&&(l.msg=l.msg.slice(0,l.msg.length-1)),!i(l.optsVarName))throw new Error("check-types-mini: [THROW_ID_04] opts.optsVarName must be string! Currently it's: "+C(l.optsVarName)+", equal to "+JSON.stringify(l.optsVarName,null,4));if(l.ignoreKeys=Vt(l.ignoreKeys),l.acceptArraysIgnore=Vt(l.acceptArraysIgnore),!u(l.ignoreKeys))throw new TypeError("check-types-mini: [THROW_ID_05] opts.ignoreKeys should be an array, currently it's: "+C(l.ignoreKeys));if(!o(l.acceptArrays))throw new TypeError("check-types-mini: [THROW_ID_06] opts.acceptArrays should be a Boolean, currently it's: "+C(l.acceptArrays));if(!u(l.acceptArraysIgnore))throw new TypeError("check-types-mini: [THROW_ID_07] opts.acceptArraysIgnore should be an array, currently it's: "+C(l.acceptArraysIgnore));if(!o(l.enforceStrictKeyset))throw new TypeError("check-types-mini: [THROW_ID_08] opts.enforceStrictKeyset should be a Boolean, currently it's: "+C(l.enforceStrictKeyset));if(Object.keys(l.schema).forEach(function(t){u(l.schema[t])||(l.schema[t]=[l.schema[t]]),l.schema[t]=l.schema[t].map(String).map(function(t){return t.toLowerCase()}).map(function(t){return t.trim()})}),l.enforceStrictKeyset)if(n(l.schema)&&Object.keys(l.schema).length>0){if(0!==J(Object.keys(t),Object.keys(s).concat(Object.keys(l.schema))).length)throw new TypeError(l.msg+": "+l.optsVarName+".enforceStrictKeyset is on and the following keys are not covered by schema and/or reference objects: "+JSON.stringify(J(Object.keys(t),Object.keys(s).concat(Object.keys(l.schema))),null,4))}else{if(!(n(s)&&Object.keys(s).length>0))throw new TypeError(l.msg+": Both "+l.optsVarName+".schema and reference objects are missing! We don't have anything to match the keys as you requested via opts.enforceStrictKeyset!");if(0!==J(Object.keys(t),Object.keys(s)).length)throw new TypeError(l.msg+": The input object has keys that are not covered by reference object: "+JSON.stringify(J(Object.keys(t),Object.keys(s)),null,4));if(0!==J(Object.keys(s),Object.keys(t)).length)throw new TypeError(l.msg+": The reference object has keys that are not present in the input object: "+JSON.stringify(J(Object.keys(s),Object.keys(t)),null,4))}Object.keys(t).forEach(function(e){if(n(l.schema)&&Object.prototype.hasOwnProperty.call(l.schema,e)){if(l.schema[e]=Vt(l.schema[e]).map(String).map(function(t){return t.toLowerCase()}),!(Mt(l.schema[e],c).length||(!0===t[e]||!1===t[e]||l.schema[e].includes(C(t[e]).toLowerCase()))&&(!0!==t[e]&&!1!==t[e]||l.schema[e].includes(String(t[e]))||l.schema[e].includes("boolean")))){if(!u(t[e])||!l.acceptArrays)throw new TypeError(l.msg+": "+l.optsVarName+"."+e+" was customised to "+JSON.stringify(t[e],null,4)+" which is not among the allowed types in schema ("+l.schema[e]+") but "+C(t[e]));for(var r=0,o=t[e].length;r<o;r++)if(!l.schema[e].includes(C(t[e][r]).toLowerCase()))throw new TypeError(l.msg+": "+l.optsVarName+"."+e+" is of type "+C(t[e][r]).toLowerCase()+", but only the following are allowed in "+l.optsVarName+".schema: "+l.schema[e])}}else if(n(s)&&Object.prototype.hasOwnProperty.call(s,e)&&C(t[e])!==C(s[e])&&!l.ignoreKeys.includes(e)){if(!l.acceptArrays||!u(t[e])||l.acceptArraysIgnore.includes(e))throw new TypeError(l.msg+": "+l.optsVarName+"."+e+" was customised to "+JSON.stringify(t[e],null,4)+" which is not "+C(s[e])+" but "+C(t[e]));if(!t[e].every(function(t){return C(t)===C(s[e])}))throw new TypeError(l.msg+": "+l.optsVarName+"."+e+" was customised to be array, but not all of its elements are "+C(s[e])+"-type")}})}(o,n,{msg:"util-array-object-or-both/validate(): [THROW_ID_03]",optsVarName:"opts",schema:{msg:["string",null],optsVarName:["string",null]}}),r(o.msg)&&o.msg.length>0&&(o.msg=o.msg.trim()+" "),"given variable"!==o.optsVarName&&(o.optsVarName='variable "'+o.optsVarName+'"'),D(["object","objects","obj","ob","o"],t.toLowerCase().trim()))return"object";if(D(["array","arrays","arr","aray","arr","a"],t.toLowerCase().trim()))return"array";if(D(["any","all","everything","both","either","each","whatever","whatevs","e"],t.toLowerCase().trim()))return"any";throw new TypeError(o.msg+"The "+o.optsVarName+" was customised to an unrecognised value: "+t+". Please check it against the API documentation.")}});
{
"name": "util-array-object-or-both",
"version": "2.0.2",
"version": "2.0.3",
"description": "Validate and normalise user choice: array, object or both?",

@@ -132,3 +132,3 @@ "license": "MIT",

"dependencies": {
"check-types-mini": "^3.0.3",
"check-types-mini": "^3.1.0",
"lodash.includes": "*",

@@ -147,9 +147,9 @@ "lodash.isplainobject": "*"

"nyc": "*",
"rollup": "^0.55.0",
"rollup": "^0.55.3",
"rollup-plugin-babel": "^3.0.3",
"rollup-plugin-commonjs": "^8.2.6",
"rollup-plugin-commonjs": "^8.3.0",
"rollup-plugin-node-resolve": "^3.0.2",
"rollup-plugin-uglify": "^3.0.0",
"uglify-es": "^3.3.8"
"uglify-es": "^3.3.9"
}
}
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