1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
|
// @target: ES6
function CreateTypedArrayTypes() {
var typedArrays = [];
typedArrays[0] = Int8Array;
typedArrays[1] = Uint8Array;
typedArrays[2] = Int16Array;
typedArrays[3] = Uint16Array;
typedArrays[4] = Int32Array;
typedArrays[5] = Uint32Array;
typedArrays[6] = Float32Array;
typedArrays[7] = Float64Array;
typedArrays[8] = Uint8ClampedArray;
return typedArrays;
}
function CreateTypedArrayInstancesFromLength(obj: number) {
var typedArrays = [];
typedArrays[0] = new Int8Array(obj);
typedArrays[1] = new Uint8Array(obj);
typedArrays[2] = new Int16Array(obj);
typedArrays[3] = new Uint16Array(obj);
typedArrays[4] = new Int32Array(obj);
typedArrays[5] = new Uint32Array(obj);
typedArrays[6] = new Float32Array(obj);
typedArrays[7] = new Float64Array(obj);
typedArrays[8] = new Uint8ClampedArray(obj);
return typedArrays;
}
function CreateTypedArrayInstancesFromArray(obj: number[]) {
var typedArrays = [];
typedArrays[0] = new Int8Array(obj);
typedArrays[1] = new Uint8Array(obj);
typedArrays[2] = new Int16Array(obj);
typedArrays[3] = new Uint16Array(obj);
typedArrays[4] = new Int32Array(obj);
typedArrays[5] = new Uint32Array(obj);
typedArrays[6] = new Float32Array(obj);
typedArrays[7] = new Float64Array(obj);
typedArrays[8] = new Uint8ClampedArray(obj);
return typedArrays;
}
function CreateIntegerTypedArraysFromArray2(obj:number[]) {
var typedArrays = [];
typedArrays[0] = Int8Array.from(obj);
typedArrays[1] = Uint8Array.from(obj);
typedArrays[2] = Int16Array.from(obj);
typedArrays[3] = Uint16Array.from(obj);
typedArrays[4] = Int32Array.from(obj);
typedArrays[5] = Uint32Array.from(obj);
typedArrays[6] = Float32Array.from(obj);
typedArrays[7] = Float64Array.from(obj);
typedArrays[8] = Uint8ClampedArray.from(obj);
return typedArrays;
}
function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike<number>) {
var typedArrays = [];
typedArrays[0] = Int8Array.from(obj);
typedArrays[1] = Uint8Array.from(obj);
typedArrays[2] = Int16Array.from(obj);
typedArrays[3] = Uint16Array.from(obj);
typedArrays[4] = Int32Array.from(obj);
typedArrays[5] = Uint32Array.from(obj);
typedArrays[6] = Float32Array.from(obj);
typedArrays[7] = Float64Array.from(obj);
typedArrays[8] = Uint8ClampedArray.from(obj);
return typedArrays;
}
function CreateTypedArraysOf(obj) {
var typedArrays = [];
typedArrays[0] = Int8Array.of(...obj);
typedArrays[1] = Uint8Array.of(...obj);
typedArrays[2] = Int16Array.of(...obj);
typedArrays[3] = Uint16Array.of(...obj);
typedArrays[4] = Int32Array.of(...obj);
typedArrays[5] = Uint32Array.of(...obj);
typedArrays[6] = Float32Array.of(...obj);
typedArrays[7] = Float64Array.of(...obj);
typedArrays[8] = Uint8ClampedArray.of(...obj);
return typedArrays;
}
function CreateTypedArraysOf2() {
var typedArrays = [];
typedArrays[0] = Int8Array.of(1,2,3,4);
typedArrays[1] = Uint8Array.of(1,2,3,4);
typedArrays[2] = Int16Array.of(1,2,3,4);
typedArrays[3] = Uint16Array.of(1,2,3,4);
typedArrays[4] = Int32Array.of(1,2,3,4);
typedArrays[5] = Uint32Array.of(1,2,3,4);
typedArrays[6] = Float32Array.of(1,2,3,4);
typedArrays[7] = Float64Array.of(1,2,3,4);
typedArrays[8] = Uint8ClampedArray.of(1,2,3,4);
return typedArrays;
}
function CreateTypedArraysFromMapFn2<T>(obj:ArrayLike<T>, mapFn: (n:T, v:number)=> number) {
var typedArrays = [];
typedArrays[0] = Int8Array.from(obj, mapFn);
typedArrays[1] = Uint8Array.from(obj, mapFn);
typedArrays[2] = Int16Array.from(obj, mapFn);
typedArrays[3] = Uint16Array.from(obj, mapFn);
typedArrays[4] = Int32Array.from(obj, mapFn);
typedArrays[5] = Uint32Array.from(obj, mapFn);
typedArrays[6] = Float32Array.from(obj, mapFn);
typedArrays[7] = Float64Array.from(obj, mapFn);
typedArrays[8] = Uint8ClampedArray.from(obj, mapFn);
return typedArrays;
}
function CreateTypedArraysFromMapFn(obj:ArrayLike<number>, mapFn: (n:number, v:number)=> number) {
var typedArrays = [];
typedArrays[0] = Int8Array.from(obj, mapFn);
typedArrays[1] = Uint8Array.from(obj, mapFn);
typedArrays[2] = Int16Array.from(obj, mapFn);
typedArrays[3] = Uint16Array.from(obj, mapFn);
typedArrays[4] = Int32Array.from(obj, mapFn);
typedArrays[5] = Uint32Array.from(obj, mapFn);
typedArrays[6] = Float32Array.from(obj, mapFn);
typedArrays[7] = Float64Array.from(obj, mapFn);
typedArrays[8] = Uint8ClampedArray.from(obj, mapFn);
return typedArrays;
}
function CreateTypedArraysFromThisObj(obj:ArrayLike<number>, mapFn: (n:number, v:number)=> number, thisArg: {}) {
var typedArrays = [];
typedArrays[0] = Int8Array.from(obj, mapFn, thisArg);
typedArrays[1] = Uint8Array.from(obj, mapFn, thisArg);
typedArrays[2] = Int16Array.from(obj, mapFn, thisArg);
typedArrays[3] = Uint16Array.from(obj, mapFn, thisArg);
typedArrays[4] = Int32Array.from(obj, mapFn, thisArg);
typedArrays[5] = Uint32Array.from(obj, mapFn, thisArg);
typedArrays[6] = Float32Array.from(obj, mapFn, thisArg);
typedArrays[7] = Float64Array.from(obj, mapFn, thisArg);
typedArrays[8] = Uint8ClampedArray.from(obj, mapFn, thisArg);
return typedArrays;
}
function CreateTypedArraysFromThisObj2<T>(obj:ArrayLike<T>, mapFn: (n:T, v:number)=> number, thisArg: {}) {
var typedArrays = [];
typedArrays[0] = Int8Array.from(obj, mapFn, thisArg);
typedArrays[1] = Uint8Array.from(obj, mapFn, thisArg);
typedArrays[2] = Int16Array.from(obj, mapFn, thisArg);
typedArrays[3] = Uint16Array.from(obj, mapFn, thisArg);
typedArrays[4] = Int32Array.from(obj, mapFn, thisArg);
typedArrays[5] = Uint32Array.from(obj, mapFn, thisArg);
typedArrays[6] = Float32Array.from(obj, mapFn, thisArg);
typedArrays[7] = Float64Array.from(obj, mapFn, thisArg);
typedArrays[8] = Uint8ClampedArray.from(obj, mapFn, thisArg);
return typedArrays;
}
|