is-array-buffer-x
Version:
Detect whether or not an object is an ArrayBuffer.
15 lines • 17.5 kB
JavaScript
/*!
{
"author": "Graham Fairweather",
"copywrite": "Copyright (c) 2015-2017",
"date": "2019-08-28T17:56:36.162Z",
"describe": "",
"description": "Detect whether or not an object is an ArrayBuffer.",
"file": "is-array-buffer-x.min.js",
"hash": "cb9a927ec423809d4af4",
"license": "MIT",
"version": "2.1.2"
}
*/
!function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.isArrayBufferX=n():t.isArrayBufferX=n()}(function(){"use strict";var t,n={}.constructor,e=n.prototype,r=n.defineProperty,o=function(){return"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:void 0},u=function(){return this};try{return r?r(e,"$$globalThis$$",{get:u,configurable:!0}):e.__defineGetter__("$$globalThis$$",u),t="undefined"==typeof $$globalThis$$?o():$$globalThis$$,delete e.$$globalThis$$,t}catch(t){return o()}}(),function(){return function(t){var n={};function e(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,e),o.l=!0,o.exports}return e.m=t,e.c=n,e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:r})},e.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},e.t=function(t,n){if(1&n&&(t=e(t)),8&n)return t;if(4&n&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(e.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&n&&"string"!=typeof t)for(var o in t)e.d(r,o,function(n){return t[n]}.bind(null,o));return r},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},e.p="",e(e.s=6)}([function(t,n,e){"use strict";var r=Object.prototype.toString;if(e(3)()){var o=Symbol.prototype.toString,u=/^Symbol\(.*\)$/;t.exports=function(t){if("symbol"==typeof t)return!0;if("[object Symbol]"!==r.call(t))return!1;try{return function(t){return"symbol"==typeof t.valueOf()&&u.test(o.call(t))}(t)}catch(t){return!1}}}else t.exports=function(t){return!1}},function(t,n,e){"use strict";var r=String.prototype.valueOf,o=Object.prototype.toString,u="function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag;t.exports=function(t){return"string"==typeof t||"object"==typeof t&&(u?function(t){try{return r.call(t),!0}catch(t){return!1}}(t):"[object String]"===o.call(t))}},function(t,n,e){"use strict";var r=Date.prototype.getDay,o=Object.prototype.toString,u="function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag;t.exports=function(t){return"object"==typeof t&&null!==t&&(u?function(t){try{return r.call(t),!0}catch(t){return!1}}(t):"[object Date]"===o.call(t))}},function(t,n,e){"use strict";(function(n){var r=n.Symbol,o=e(5);t.exports=function(){return"function"==typeof r&&("function"==typeof Symbol&&("symbol"==typeof r("foo")&&("symbol"==typeof Symbol("bar")&&o())))}}).call(this,e(4))},function(t,n){var e;e=function(){return this}();try{e=e||new Function("return this")()}catch(t){"object"==typeof window&&(e=window)}t.exports=e},function(t,n,e){"use strict";t.exports=function(){if("function"!=typeof Symbol||"function"!=typeof Object.getOwnPropertySymbols)return!1;if("symbol"==typeof Symbol.iterator)return!0;var t={},n=Symbol("test"),e=Object(n);if("string"==typeof n)return!1;if("[object Symbol]"!==Object.prototype.toString.call(n))return!1;if("[object Symbol]"!==Object.prototype.toString.call(e))return!1;for(n in t[n]=42,t)return!1;if("function"==typeof Object.keys&&0!==Object.keys(t).length)return!1;if("function"==typeof Object.getOwnPropertyNames&&0!==Object.getOwnPropertyNames(t).length)return!1;var r=Object.getOwnPropertySymbols(t);if(1!==r.length||r[0]!==n)return!1;if(!Object.prototype.propertyIsEnumerable.call(t,n))return!1;if("function"==typeof Object.getOwnPropertyDescriptor){var o=Object.getOwnPropertyDescriptor(t,n);if(42!==o.value||!0!==o.enumerable)return!1}return!0}},function(t,n,e){"use strict";function r(t){return(r="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})(t)}e.r(n);var o=function(t){return"object"===r(t)?null===t:"function"!=typeof t},u=e(1),i=e.n(u),c={}.constructor("a"),f="a"===c[0]&&0 in c,s=function(){}.bind,a="function"==typeof s&&function(){var t=null,n=null,e=null,r=[];try{var o=s.apply(function(r,o){return e=this,t=r,n=o,arguments},[r,1]),u=o(2);return 1===o.length&&2===u.length&&1===t&&2===n&&e===r}catch(t){return!1}}()&&function(){var t=null,n=null,e=null,r=[1,2,3],o=function(o,u){return t=o,n=u,e=this,r};try{var u=s.apply(o,[null]),i=new u(1,2);return u.length===o.length&&i===r&&1===t&&2===n&&e!==r}catch(t){return!1}}(),l="".split,p=Math.max,y=o.bind,b=o.call,d=a?y.call(b,l):function(t,n){return l.call(t,n)},g=function(t){return i()(t)?d(t,""):t},v=function(t,n){var e=arguments.length>2?arguments[2]:[];if("string"!=typeof t&&o(t))return e;for(var r=f?t:g(t),u=r.length,i=p(0,n)||0;i<u;i+=1)e[e.length]=t[i];return e};function m(t,n){return function(t){if(Array.isArray(t))return t}(t)||function(t,n){var e=[],r=!0,o=!1,u=void 0;try{for(var i,c=t[Symbol.iterator]();!(r=(i=c.next()).done)&&(e.push(i.value),!n||e.length!==n);r=!0);}catch(t){o=!0,u=t}finally{try{r||null==c.return||c.return()}finally{if(o)throw u}}return e}(t,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}var h=v.bind,w=v.call,S={},j=S.constructor,O=S.toString,_=function(t,n){return t>=n?t:n},x=function(t){if("function"!=typeof t&&"[object Function]"!==O.apply(t))throw new TypeError("bind called on incompatible "+t)},T=[function(t){return function(){return t.apply(this,v(arguments))}},function(t,n){return function(e){return t.apply(this,v(arguments,n,[e]))}},function(t,n){return function(e,r){return t.apply(this,v(arguments,n,[e,r]))}},function(t,n){return function(e,r,o){return t.apply(this,v(arguments,n,[e,r,o]))}},function(t,n){return function(e,r,o,u){return t.apply(this,v(arguments,n,[e,r,o,u]))}},function(t,n){return function(e,r,o,u,i){return t.apply(this,v(arguments,n,[e,r,o,u,i]))}},function(t,n){return function(e,r,o,u,i,c){return t.apply(this,v(arguments,n,[e,r,o,u,i,c]))}},function(t,n){return function(e,r,o,u,i,c,f){return t.apply(this,v(arguments,n,[e,r,o,u,i,c,f]))}},function(t,n){return function(e,r,o,u,i,c,f,s){return t.apply(this,v(arguments,n,[e,r,o,u,i,c,f,s]))}}],$=function(t){var n=m(t,3),e=n[0],r=n[1],o=n[2],u=_(0,r.length-_(0,o.length-2)),i=T[u],c=i?i(e,u):T[0](e);if(r.prototype){var f=function(){};f.prototype=r.prototype,c.prototype=new f,f.prototype=null}return c},E=function(t,n){var e=t.apply(this,n);return j(e)===e?e:this},P=a?w.bind(h):function(t,n){x(t);var e,r=arguments,o=function(){var o=v(arguments,0,v(r,2));return this instanceof e?E.apply(this,[t,o]):t.apply(n,o)};return e=$([o,t,r])},F=TypeError,M=P.apply,A=P(P.call,M),N=P(M,{}.toString),k=function(t){if("function"!=typeof t&&"[object Function]"!==N(t))throw new F(t+" is not a function");return t},C=function(t,n){return A(k(t),n,v(arguments[2]))},B=function(t){try{return{threw:!1,value:C(t,this,v(arguments,1))}}catch(t){return{threw:!0,value:t}}},D=function(t){return!!t},I={}.toString,G=function(t){return function(t){if("function"!=typeof t&&"[object Function]"!==C(I,t))throw new TypeError("methodize called on incompatible "+t)}(t),function(){return C(t,arguments[0],v(arguments,1))}},L=G({}.toString),X=function(t){return null===t?"[object Null]":void 0===t?"[object Undefined]":L(t)},q=e(0),R=e.n(q);for(var z=B(function(){return function(t,n){if(t!==n)throw new TypeError("Cannot instantiate an arrow function")}(this,void 0),"function"==typeof Symbol&&R()(Symbol(""))}.bind(void 0)),H=!1===z.threw&&!0===z.value,U=H&&R()(Symbol.toStringTag),V=function(t){return null==t},J=function(t){if(V(t))throw new TypeError("Cannot call method on ".concat(t));return t},K="Cannot convert a Symbol value to a string".constructor,Q=function(t){if(R()(t))throw new TypeError("Cannot convert a Symbol value to a string");return K(t)},W=function(t){return Q(J(t))},Y=[{code:9,description:"Tab",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:"\t"},{code:10,description:"Line Feed",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:"\n"},{code:11,description:"Vertical Tab",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:"\v"},{code:12,description:"Form Feed",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:"\f"},{code:13,description:"Carriage Return",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:"\r"},{code:32,description:"Space",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:" "},{code:160,description:"No-break space",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:" "},{code:5760,description:"Ogham space mark",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:" "},{code:6158,description:"Mongolian vowel separator",es5:!0,es2015:!0,es2016:!0,es2017:!1,es2018:!1,string:""},{code:8192,description:"En quad",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:" "},{code:8193,description:"Em quad",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:" "},{code:8194,description:"En space",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:" "},{code:8195,description:"Em space",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:" "},{code:8196,description:"Three-per-em space",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:" "},{code:8197,description:"Four-per-em space",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:" "},{code:8198,description:"Six-per-em space",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:" "},{code:8199,description:"Figure space",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:" "},{code:8200,description:"Punctuation space",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:" "},{code:8201,description:"Thin space",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:" "},{code:8202,description:"Hair space",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:" "},{code:8232,description:"Line separator",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:"\u2028"},{code:8233,description:"Paragraph separator",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:"\u2029"},{code:8239,description:"Narrow no-break space",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:" "},{code:8287,description:"Medium mathematical space",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:" "},{code:12288,description:"Ideographic space",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:" "},{code:65279,description:"Byte Order Mark",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:"\ufeff"}],Z="",tt=Y.length,nt=0;nt<tt;nt+=1)Y[nt].es2016&&Y[nt].string,Y[nt].es2018&&(Z+=Y[nt].string);var et=Z,rt=new(0,/none/.constructor)("^[".concat(et,"]+")),ot=G("".replace),ut=function(t){return ot(W(t),rt,"")},it=new(0,/none/.constructor)("[".concat(et,"]+$")),ct=G("".replace),ft=function(t){return ct(W(t),it,"")},st=function(t){return ut(ft(t))},at=new(0,/none/.constructor)("[".concat(et,"]+"),"g"),lt=G(" ".replace),pt=function(t){return lt(st(t),at," ")},yt=/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm,bt=G("".replace),dt=function(t,n){return bt(W(t),yt,arguments.length>1?Q(n):"")},gt=B.constructor,vt=G(B.toString),mt=/^class /,ht=G(mt.test),wt=!1===B(function(){return gt('"use strict"; return class My {};')()}).threw,St=function(t){return ht(mt,pt(dt(vt(t)," ")))},jt=function(t){var n=B(St,t);return!1===n.threw&&n.value},Ot=function(t,n){return!o(t)&&(U?function(t,n){return!(wt&&!1===n&&jt(t)||!1!==B(function(){return vt(t)}).threw)}(t,D(n)):(!wt||!1!==D(n)||!jt(t))&&function(t){var n=X(t);return"[object Function]"===n||"[object GeneratorFunction]"===n||"[object AsyncFunction]"===n}(t))},_t=function(t){return!1===o(t)&&!1===Ot(t,!0)},xt={}.constructor,Tt=function(t){return xt(J(t))},$t=e(2),Et=e.n($t),Pt="string".constructor,Ft=(0).constructor,Mt=H&&Symbol.toPrimitive,At=H&&Symbol.prototype.valueOf,Nt=["toString","valueOf"],kt=["valueOf","toString"],Ct=function(t,n){J(t),function(t){if("string"!=typeof t||"number"!==t&&"string"!==t)throw new TypeError('hint must be "string" or "number"')}(n);for(var e="string"===n?Nt:kt,r=0;r<2;r+=1){var u=t[e[r]];if(Ot(u)){var i=C(u,t);if(o(i))return i}}throw new TypeError("No default value")},Bt=function(t,n){if(n){if(t===Pt)return"string";if(t===Ft)return"number"}return"default"},Dt=function(t){if(H){if(Mt)return function(t,n){var e=t[n];if(!1===V(e)){if(!1===Ot(e))throw new TypeError("".concat(e," returned for property ").concat(n," of object ").concat(t," is not a function"));return e}}(t,Mt);if(R()(t))return At}},It=function(t){var n=t.exoticToPrim,e=t.input,r=t.hint,u=C(n,e,[r]);if(o(u))return u;throw new TypeError("unable to convert exotic object to primitive")},Gt=function(t,n){var e="default"===n&&(Et()(t)||R()(t))?"string":n;return Ct(t,"default"===e?"number":e)},Lt=function(t,n){if(o(t))return t;var e=Bt(n,arguments.length>1),r=Dt(t);return void 0===r?Gt(t,e):It({exoticToPrim:r,input:t,hint:e})};function Xt(t){return(Xt="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})(t)}var qt,Rt,zt,Ht=function(t){var n=Lt(t,String);return H&&"symbol"===Xt(n)?n:Q(n)},Ut=G({}.hasOwnProperty),Vt=function(t,n){return Ut(Tt(t),Ht(n))},Jt=H&&Symbol.prototype.toString,Kt="function"==typeof Jt&&R.a,Qt="".constructor,Wt=function(t){return Kt&&Kt(t)?Jt.call(t):Qt(t)},Yt=parseInt,Zt=(0).constructor,tn=G("".charAt),nn=/^[-+]?0[xX]/,en=G(nn.test),rn=function(t,n){var e=ut(Q(t));return""===tn(e,0)?NaN:Yt(e,Zt(n)||(en(nn,e)?16:10))},on=2..constructor,un=G("Cannot convert a Symbol value to a number".slice),cn=/^0b[01]+$/i,fn=cn.constructor,sn=G(cn.test),an=/^0o[0-7]+$/i,ln=new fn("[
]","g"),pn=/^[-+]0x[0-9a-f]+$/i,yn=function(t,n){return rn(un(t,2),n)},bn=function(t,n){return function(t){return sn(cn,t)}(n)?t(yn(n,2)):function(t){return sn(an,t)}(n)?t(yn(n,8)):null},dn=function(t,n){var e=bn(t,n);if(null!==e)return e;if(function(t){return sn(ln,t)}(n)||function(t){return sn(pn,t)}(n))return NaN;var r=st(n);return r!==n?t(r):null},gn=function t(n){var e=function(t){if(R()(t))throw new TypeError("Cannot convert a Symbol value to a number");return t}(Lt(n,on));if("string"==typeof e){var r=dn(t,e);if(null!==r)return r}return on(e)},vn=function(t){return t!=t},mn=function(t){return"number"==typeof t&&!1===vn(t)&&t!==1/0&&t!==-1/0},hn=function(t){var n=gn(t);return 0===n||vn(n)?n:n>0?1:-1},wn=Math.abs,Sn=Math.floor,jn=function(t){var n=gn(t);return vn(n)?0:0===n||!1===mn(n)?n:hn(n)*Sn(wn(n))},On=function(t){var n=gn(t[1]),e=t.length<3?{max:n,min:0}:{max:gn(t[2]),min:n};if(e.min>e.max)throw new RangeError('"min" must be less than "max"');return e},_n=function(t){var n=gn(t);if(arguments.length<2)return n;var e=On(arguments),r=e.max,o=e.min;return n<o?o:n>r?r:n},xn=/^(?:0|[1-9]\d*)$/,Tn=xn.test,$n=function(t,n){var e=Wt(t);if(!1===Tn.call(xn,e))return!1;var r=gn(e);return arguments.length>1?r<_n(jn(n),9007199254740991):r<9007199254740991},En=G({}.propertyIsEnumerable),Pn=function(t,n){return En(Tt(t),Ht(n))},Fn=G("".charAt),Mn={}.constructor,An=Mn.getOwnPropertyDescriptor,Nn="function"==typeof An&&An,kn=function(t,n){t[Ht(n)]=0;var e=B(Nn,t,n);return!1===e.threw&&0===e.value.value},Cn=Mn.prototype,Bn=Vt(Cn,"__defineGetter__"),Dn=Bn&&G(Cn.__lookupGetter__),In=Bn&&G(Cn.__lookupSetter__);if(Nn){var Gn="undefined"!=typeof document&&document;if(!Gn||kn(Gn.createElement("div"),"sentinel")){var Ln=B(Nn,Tt("abc"),1);if(!1===Ln.threw&&Ln.value&&"b"===Ln.value.value)if(kn({},"sentinel")){var Xn=!1===B(Nn,42,"name").threw;zt=H&&kn({},Tt(Symbol("")))?Xn?Nn:function(t,n){return Nn(Tt(t),n)}:Xn?function(t,n){return Nn(t,Ht(n))}:function(t,n){return Nn(Tt(t),Ht(n))}}else qt=Nn;else Rt=Nn}}(!1===D(zt)||qt||Rt)&&(zt=function(t,n){var e,r=Tt(t),u=Ht(n);if(qt&&!1===(e=B(function(){return qt(Tt(r),u)})).threw)return e.value;var c=i()(r)&&$n(u,r.length);if(Rt&&!1===c&&!1===(e=B(function(){return Rt(Tt(r),u)})).threw)return e.value;var f=void 0;if(!1===c&&!1===Vt(r,u))return f;if(f={configurable:!1===o(t)&&!1===c,enumerable:Pn(r,u)},Bn){var s=r.__proto__,a=r!==Cn;a&&(r.__proto__=Cn);var l=Dn(r,u),p=In(r,u);if(a&&(r.__proto__=s),l||p)return l&&(f.get=l),p&&(f.set=p),f}return c?(f.value=Fn(r,u),f.writable=!1):(f.value=r[u],f.writable=!0),f});var qn=zt,Rn=function(){return!0},zn=function(t){return"function"==typeof t?B(t):{threw:!1,value:t}},Hn=function(t,n){var e="function"==typeof arguments[2]?arguments[2]:Rn,r=B(function(){return C(t.get,n)});return!1===r.threw&&e(r.value)?t.get:null},Un="function"==typeof ArrayBuffer,Vn=function(t){return"number"==typeof t},Jn=Un&&U?function(t,n){var e=zn(t);if(!1===e.threw&&_t(e.value)){var r=qn(e.value.constructor.prototype,n);if(r&&"function"==typeof r.get)return Hn(r,e.value,arguments[2])}return null}(function(){return new ArrayBuffer(4)},"byteLength",Vn):null;n.default=function(t){if(!1===Un||!1===_t(t))return!1;if(!1===D(Jn))return"[object ArrayBuffer]"===X(t);var n=B(function(){return C(Jn,t)});return!1===n.threw&&Vn(n.value)}}])});
//# sourceMappingURL=is-array-buffer-x.min.js.map