This repository has been archived on 2024-01-19. You can view files and clone it, but cannot push or open issues or pull requests.
epubreader/js/lib/typedarray.min.js

2 lines
8.8 KiB
JavaScript
Raw Normal View History

2020-04-21 20:37:42 +00:00
var ArrayBuffer,ArrayBufferView,Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,DataView;(function(){"use strict";function t(){if(document){document.createTextNode("").splitText(1)}throw new RangeError("INDEX_SIZE_ERR")}function n(e){if(Object.getOwnPropertyNames&&Object.defineProperty){var t=Object.getOwnPropertyNames(e),n;for(n=0;n<t.length;n+=1){Object.defineProperty(e,t[n],{value:e[t[n]],writable:false,enumerable:false,configurable:false})}}}function r(e){function t(t){Object.defineProperty(e,t,{get:function(){return e._getter(t)},set:function(n){e._setter(t,n)},enumerable:true,configurable:false})}if(!Object.defineProperty){return}var n;for(n=0;n<e.length;n+=1){t(n)}}function i(e,t){var n=32-t;return e<<n>>n}function s(e,t){var n=32-t;return e<<n>>>n}function o(e){return[e&255]}function u(e){return i(e[0],8)}function a(e){return[e&255]}function f(e){return s(e[0],8)}function l(e){return[e>>8&255,e&255]}function c(e){return i(e[0]<<8|e[1],16)}function h(e){return[e>>8&255,e&255]}function p(e){return s(e[0]<<8|e[1],16)}function d(e){return[e>>24&255,e>>16&255,e>>8&255,e&255]}function v(e){return i(e[0]<<24|e[1]<<16|e[2]<<8|e[3],32)}function m(e){return[e>>24&255,e>>16&255,e>>8&255,e&255]}function g(e){return s(e[0]<<24|e[1]<<16|e[2]<<8|e[3],32)}function y(e,t,n){var r=(1<<t-1)-1,i,s,o,u,a,f,l,c;if(isNaN(e)){s=(1<<r)-1;o=Math.pow(2,n-1);i=0}else if(e===Infinity||e===-Infinity){s=(1<<r)-1;o=0;i=e<0?1:0}else if(e===0){s=0;o=0;i=1/e===-Infinity?1:0}else{i=e<0;e=Math.abs(e);if(e>=Math.pow(2,1-r)){u=Math.min(Math.floor(Math.log(e)/Math.LN2),r);s=u+r;o=Math.round(e*Math.pow(2,n-u)-Math.pow(2,n))}else{s=0;o=Math.round(e/Math.pow(2,1-r-n))}}f=[];for(a=n;a;a-=1){f.push(o%2?1:0);o=Math.floor(o/2)}for(a=t;a;a-=1){f.push(s%2?1:0);s=Math.floor(s/2)}f.push(i?1:0);f.reverse();l=f.join("");c=[];while(l.length){c.push(parseInt(l.substring(0,8),2));l=l.substring(8)}return c}function b(e,t,n){var r=[],i,s,o,u,a,f,l,c;for(i=e.length;i;i-=1){o=e[i-1];for(s=8;s;s-=1){r.push(o%2?1:0);o=o>>1}}r.reverse();u=r.join("");a=(1<<t-1)-1;f=parseInt(u.substring(0,1),2)?-1:1;l=parseInt(u.substring(1,1+t),2);c=parseInt(u.substring(1+t),2);if(l===(1<<t)-1){return c!==0?NaN:f*Infinity}else if(l>0){return f*Math.pow(2,l-a)*(1+c/Math.pow(2,n))}else if(c!==0){return f*Math.pow(2,-(a-1))*(c/Math.pow(2,n))}else{return f<0?-0:0}}function w(e){return b(e,11,52)}function E(e){return y(e,11,52)}function S(e){return b(e,8,23)}function x(e){return y(e,8,23)}var e={ToInt32:function(e){return e>>0},ToUint32:function(e){return e>>>0}};if(Object.prototype.__defineGetter__&&!Object.defineProperty){Object.defineProperty=function(e,t,n){if(n.hasOwnProperty("get")){e.__defineGetter__(t,n.get)}if(n.hasOwnProperty("set")){e.__defineSetter__(t,n.set)}}}if(!ArrayBuffer){(function(){function i(i,s,o){var u;u=function(i,s,o){var a,f,l,c;if(!arguments.length||typeof arguments[0]==="number"){this.length=e.ToInt32(arguments[0]);if(o<0){throw new RangeError("ArrayBufferView size is not a small enough positive integer.")}this.byteLength=this.length*this.BYTES_PER_ELEMENT;this.buffer=new ArrayBuffer(this.byteLength);this.byteOffset=0}else if(typeof arguments[0]==="object"&&arguments[0].constructor===u){a=arguments[0];this.length=a.length;this.byteLength=this.length*this.BYTES_PER_ELEMENT;this.buffer=new ArrayBuffer(this.byteLength);this.byteOffset=0;for(l=0;l<this.length;l+=1){this._setter(l,a._getter(l))}}else if(typeof arguments[0]==="object"&&!(arguments[0]instanceof ArrayBuffer)){f=arguments[0];this.length=e.ToUint32(f.length);this.byteLength=this.length*this.BYTES_PER_ELEMENT;this.buffer=new ArrayBuffer(this.byteLength);this.byteOffset=0;for(l=0;l<this.length;l+=1){c=f[l];this._setter(l,Number(c))}}else if(typeof arguments[0]==="object"&&arguments[0]instanceof ArrayBuffer){this.buffer=i;this.byteOffset=e.ToUint32(s);if(this.byteOffset>this.buffer.byteLength){t()}if(this.byteOffset%this.BYTES_PER_ELEMENT){throw new RangeError("ArrayBuffer length minus the byteOffset is not a multiple of the element size.")}if(arguments.length<3){this.by