提交 6a51990c 编写于 作者: 杜庆泉's avatar 杜庆泉

Merge branch 'dev' of gitcode.net:dcloud/hello-uts into dev

...@@ -45,8 +45,9 @@ export class TDataView { ...@@ -45,8 +45,9 @@ export class TDataView {
// Create an ArrayBuffer with a size in bytes // Create an ArrayBuffer with a size in bytes
let buffer = new ArrayBuffer(16); let buffer = new ArrayBuffer(16);
let view = new DataView(buffer); let view = new DataView(buffer);
view.setFloat32(1,3.1415927); view.setFloat32(1,3);
expect(this.numberEquals(3.1415927, view.getFloat32(1).toFloat())).toEqual(true); console.log('setFloat32',view.getFloat32(1))
expect(this.numberEquals(3, view.getFloat32(1))).toEqual(true);
} }
setFloat64() { setFloat64() {
......
...@@ -85,7 +85,7 @@ export class TFloat32Array { ...@@ -85,7 +85,7 @@ export class TFloat32Array {
testEvery() { testEvery() {
// const isBelowThreshold = (currentValue: number, index: number, array:Float32Array): boolean => currentValue < 40; // const isBelowThreshold = (currentValue: number, index: number, array:Float32Array): boolean => currentValue < 40;
let result = new Float32Array([12, 5, 8, 130, 44]).every((value: number, _: number, _: Float32Array): let result = new Float32Array([12, 5, 8, 130, 44]).every((value: number, _: number, _a: Float32Array):
boolean => value < 40); // boolean => value < 40); //
expect(result).toEqual(false); expect(result).toEqual(false);
} }
...@@ -110,24 +110,24 @@ export class TFloat32Array { ...@@ -110,24 +110,24 @@ export class TFloat32Array {
testFilter() { testFilter() {
// const isBelowThreshold = (currentValue: number, index: number, _): boolean => currentValue >= 10; // const isBelowThreshold = (currentValue: number, index: number, _): boolean => currentValue >= 10;
let float32 = new Float32Array([12, 5, 8, 44]).filter((value: number, _: number, _: Float32Array): let float32 = new Float32Array([12, 5, 8, 44]).filter((value: number, _: number, _a: Float32Array):
boolean => value >= 10); boolean => value >= 10);
expect(float32.toString()).toEqual("12,44"); expect(float32.toString()).toEqual("12,44");
} }
find() { find() {
let float32 = new Float32Array([4, 5, 8, 12]); let float32 = new Float32Array([4, 5, 8, 12]);
let res = float32.find((value: number, _: number, _: Float32Array): boolean => value > 5); let res = float32.find((value: number, _: number, _a: Float32Array): boolean => value > 5);
expect(res).toEqual(8); expect(res).toEqual(8);
} }
findIndex() { findIndex() {
let float32 = new Float32Array([4, 6, 8, 12]); let float32 = new Float32Array([4, 6, 8, 12]);
let res = float32.findIndex((value: number, _: number, _: Float32Array): boolean => value > 100); let res = float32.findIndex((value: number, _: number, _a: Float32Array): boolean => value > 100);
expect(res).toEqual(-1); expect(res).toEqual(-1);
let ufloat32 = new Float32Array([4, 6, 7, 120]); let ufloat32 = new Float32Array([4, 6, 7, 120]);
res = ufloat32.findIndex((value: number, _: number, _: Float32Array): boolean => value > 100); res = ufloat32.findIndex((value: number, _: number, _a: Float32Array): boolean => value > 100);
expect(res).toEqual(3); expect(res).toEqual(3);
} }
...@@ -198,31 +198,31 @@ export class TFloat32Array { ...@@ -198,31 +198,31 @@ export class TFloat32Array {
map() { map() {
let numbers = new Float32Array([1, 4, 9]); let numbers = new Float32Array([1, 4, 9]);
let doubles = numbers.map((value: number, _: number, _: Float32Array): number => value * 2); let doubles = numbers.map((value: number, _: number, _a: Float32Array): number => value * 2);
expect(numbers.toString()).toEqual("1,4,9"); expect(numbers.toString()).toEqual("1,4,9");
expect(doubles.toString()).toEqual("2,8,18"); expect(doubles.toString()).toEqual("2,8,18");
} }
reduce() { reduce() {
let total = new Float32Array([0, 1, 2, 3]); let total = new Float32Array([0, 1, 2, 3]);
let res = total.reduce((accumulator: number, currentValue: number, _: number, _: Float32Array): let res = total.reduce((accumulator: number, currentValue: number, _: number, _a: Float32Array):
number => accumulator + currentValue); number => accumulator + currentValue);
expect(res).toEqual(6); expect(res).toEqual(6);
total = new Float32Array([0, 1, 2, 3]); total = new Float32Array([0, 1, 2, 3]);
res = total.reduce((accumulator: number, currentValue: number, _: number, _: Float32Array): res = total.reduce((accumulator: number, currentValue: number, _: number, _a: Float32Array):
number => accumulator + currentValue, 8); number => accumulator + currentValue, 8);
expect(res).toEqual(14); expect(res).toEqual(14);
} }
reduceRight() { reduceRight() {
let total = new Float32Array([0, 1, 2, 3]); let total = new Float32Array([0, 1, 2, 3]);
let res = total.reduceRight((accumulator: number, currentValue: number, _: number, _: let res = total.reduceRight((accumulator: number, currentValue: number, _: number, _a:
Float32Array): number => accumulator + currentValue); Float32Array): number => accumulator + currentValue);
expect(res).toEqual(6); expect(res).toEqual(6);
total = new Float32Array([0, 1, 2, 3]); total = new Float32Array([0, 1, 2, 3]);
res = total.reduceRight((accumulator: number, currentValue: number, _: number, _: Float32Array): res = total.reduceRight((accumulator: number, currentValue: number, _: number, _a: Float32Array):
number => accumulator + currentValue, 8); number => accumulator + currentValue, 8);
expect(res).toEqual(14); expect(res).toEqual(14);
} }
......
...@@ -75,7 +75,7 @@ export class TFloat64Array { ...@@ -75,7 +75,7 @@ export class TFloat64Array {
testEvery() { testEvery() {
// const isBelowThreshold = (currentValue: number, index: number, array:Float64Array): boolean => currentValue < 40; // const isBelowThreshold = (currentValue: number, index: number, array:Float64Array): boolean => currentValue < 40;
let result = new Float64Array([-10, -20, -30, -40, -50]).every((value: number, _: number, _: let result = new Float64Array([-10, -20, -30, -40, -50]).every((value: number, _: number, _a:
Float64Array): boolean => value < 0); // Float64Array): boolean => value < 0); //
expect(result).toEqual(true); expect(result).toEqual(true);
} }
...@@ -100,24 +100,24 @@ export class TFloat64Array { ...@@ -100,24 +100,24 @@ export class TFloat64Array {
testFilter() { testFilter() {
// const isBelowThreshold = (currentValue: number, index: number, _): boolean => currentValue >= 10; // const isBelowThreshold = (currentValue: number, index: number, _): boolean => currentValue >= 10;
let float32 = new Float64Array([12, 5, 8, 44]).filter((value: number, _: number, _: Float64Array): let float32 = new Float64Array([12, 5, 8, 44]).filter((value: number, _: number, _a: Float64Array):
boolean => value >= 10); boolean => value >= 10);
expect(float32.toString()).toEqual("12,44"); expect(float32.toString()).toEqual("12,44");
} }
find() { find() {
let float32 = new Float64Array([4, 5, 8, 12]); let float32 = new Float64Array([4, 5, 8, 12]);
let res = float32.find((value: number, _: number, _: Float64Array): boolean => value > 5); let res = float32.find((value: number, _: number, _a: Float64Array): boolean => value > 5);
expect(res).toEqual(8); expect(res).toEqual(8);
} }
findIndex() { findIndex() {
let float32 = new Float64Array([4, 6, 8, 12]); let float32 = new Float64Array([4, 6, 8, 12]);
let res = float32.findIndex((value: number, _: number, _: Float64Array): boolean => value > 100); let res = float32.findIndex((value: number, _: number, _a: Float64Array): boolean => value > 100);
expect(res).toEqual(-1); expect(res).toEqual(-1);
let ufloat32 = new Float64Array([4, 6, 7, 120]); let ufloat32 = new Float64Array([4, 6, 7, 120]);
res = ufloat32.findIndex((value: number, _: number, _: Float64Array): boolean => value > 100); res = ufloat32.findIndex((value: number, _: number, _a: Float64Array): boolean => value > 100);
expect(res).toEqual(3); expect(res).toEqual(3);
} }
...@@ -189,31 +189,31 @@ export class TFloat64Array { ...@@ -189,31 +189,31 @@ export class TFloat64Array {
map() { map() {
let numbers = new Float64Array([1, 4, 9]); let numbers = new Float64Array([1, 4, 9]);
let doubles = numbers.map((value: number, _: number, _: Float64Array): number => value * 2); let doubles = numbers.map((value: number, _: number, _a: Float64Array): number => value * 2);
expect(numbers.toString()).toEqual("1,4,9"); expect(numbers.toString()).toEqual("1,4,9");
expect(doubles.toString()).toEqual("2,8,18"); expect(doubles.toString()).toEqual("2,8,18");
} }
reduce() { reduce() {
let total = new Float64Array([0, 1, 2, 3]); let total = new Float64Array([0, 1, 2, 3]);
let res = total.reduce((accumulator: number, currentValue: number, _: number, _: Float64Array): let res = total.reduce((accumulator: number, currentValue: number, _: number, _a: Float64Array):
number => accumulator + currentValue); number => accumulator + currentValue);
expect(res).toEqual(6); expect(res).toEqual(6);
total = new Float64Array([0, 1, 2, 3]); total = new Float64Array([0, 1, 2, 3]);
res = total.reduce((accumulator: number, currentValue: number, _: number, _: Float64Array): res = total.reduce((accumulator: number, currentValue: number, _: number, _a: Float64Array):
number => accumulator + currentValue, 8); number => accumulator + currentValue, 8);
expect(res).toEqual(14); expect(res).toEqual(14);
} }
reduceRight() { reduceRight() {
let total = new Float64Array([0, 1, 2, 3]); let total = new Float64Array([0, 1, 2, 3]);
let res = total.reduceRight((accumulator: number, currentValue: number, _: number, _: let res = total.reduceRight((accumulator: number, currentValue: number, _: number, _a:
Float64Array): number => accumulator + currentValue); Float64Array): number => accumulator + currentValue);
expect(res).toEqual(6); expect(res).toEqual(6);
total = new Float64Array([0, 1, 2, 3]); total = new Float64Array([0, 1, 2, 3]);
res = total.reduceRight((accumulator: number, currentValue: number, _: number, _: Float64Array): res = total.reduceRight((accumulator: number, currentValue: number, _: number, _a: Float64Array):
number => accumulator + currentValue, 8); number => accumulator + currentValue, 8);
expect(res).toEqual(14); expect(res).toEqual(14);
} }
......
...@@ -42,7 +42,7 @@ export class TInt16Array { ...@@ -42,7 +42,7 @@ export class TInt16Array {
testSet() { testSet() {
let float32 = new Int16Array(8); let float32 = new Int16Array(8);
var array =[1, 2, 3] var array = [1, 2, 3]
float32.set(array, 1); float32.set(array, 1);
expect(float32.toString()).toEqual("0,1,2,3,0,0,0,0"); expect(float32.toString()).toEqual("0,1,2,3,0,0,0,0");
} }
...@@ -51,15 +51,15 @@ export class TInt16Array { ...@@ -51,15 +51,15 @@ export class TInt16Array {
console.log("testCopyWith 1") console.log("testCopyWith 1")
let float32 = new Int16Array(8); let float32 = new Int16Array(8);
float32.set([1, 2, 3], 1); float32.set([1, 2, 3], 1);
console.log("testCopyWith 1") console.log("testCopyWith 1")
float32.copyWithin(3, 0, 3); float32.copyWithin(3, 0, 3);
console.log("testCopyWith 1") console.log("testCopyWith 1")
expect(float32.toString()).toEqual("0,1,2,0,1,2,0,0"); expect(float32.toString()).toEqual("0,1,2,0,1,2,0,0");
} }
testEvery() { testEvery() {
// const isBelowThreshold = (currentValue: number, index: number, array:Int16Array): boolean => currentValue < 40; // const isBelowThreshold = (currentValue: number, index: number, array:Int16Array): boolean => currentValue < 40;
let result = new Int16Array([12, 5, 8, 130, 44]).every((value:number,_ : number, _ : Int16Array): boolean => value< 40); // let result = new Int16Array([12, 5, 8, 130, 44]).every((value : number, _ : number, _a : Int16Array) : boolean => value < 40); //
expect(result).toEqual(false); expect(result).toEqual(false);
} }
...@@ -82,24 +82,24 @@ export class TInt16Array { ...@@ -82,24 +82,24 @@ export class TInt16Array {
testFilter() { testFilter() {
// const isBelowThreshold = (currentValue: number, index: number, _): boolean => currentValue >= 10; // const isBelowThreshold = (currentValue: number, index: number, _): boolean => currentValue >= 10;
let float32 = new Int16Array([12, 5, 8, 44]).filter((value : number, _ : number, _ : Int16Array): boolean => value>= 10); let float32 = new Int16Array([12, 5, 8, 44]).filter((value : number, _ : number, _a : Int16Array) : boolean => value >= 10);
expect(float32.toString()).toEqual("12,44"); expect(float32.toString()).toEqual("12,44");
} }
find() { find() {
let float32 = new Int16Array([4, 5, 8, 12]); let float32 = new Int16Array([4, 5, 8, 12]);
let res = float32.find((value : number, _ : number, _ : Int16Array): boolean => value > 5); let res = float32.find((value : number, _ : number, _a : Int16Array) : boolean => value > 5);
expect(res).toEqual(8); expect(res).toEqual(8);
} }
findIndex() { findIndex() {
let float32 = new Int16Array([4, 6, 8, 12]); let float32 = new Int16Array([4, 6, 8, 12]);
let res = float32.findIndex((value : number, _ : number, _ : Int16Array): boolean => value > 100); let res = float32.findIndex((value : number, _ : number, _a : Int16Array) : boolean => value > 100);
expect(res).toEqual(-1); expect(res).toEqual(-1);
let ufloat32 = new Int16Array([4, 6, 7, 120]); let ufloat32 = new Int16Array([4, 6, 7, 120]);
res = ufloat32.findIndex((value : number, _ : number, _ : Int16Array): boolean => value > 100); res = ufloat32.findIndex((value : number, _ : number, _a : Int16Array) : boolean => value > 100);
expect(res).toEqual(3); expect(res).toEqual(3);
} }
...@@ -169,28 +169,28 @@ export class TInt16Array { ...@@ -169,28 +169,28 @@ export class TInt16Array {
map() { map() {
let numbers = new Int16Array([1, 4, 9]); let numbers = new Int16Array([1, 4, 9]);
let doubles = numbers.map((value : number, _ : number, _ : Int16Array): number => value * 2); let doubles = numbers.map((value : number, _ : number, _a : Int16Array) : number => value * 2);
expect(numbers.toString()).toEqual("1,4,9"); expect(numbers.toString()).toEqual("1,4,9");
expect(doubles.toString()).toEqual("2,8,18"); expect(doubles.toString()).toEqual("2,8,18");
} }
reduce() { reduce() {
let total = new Int16Array([0, 1, 2, 3]); let total = new Int16Array([0, 1, 2, 3]);
let res = total.reduce((accumulator : number, currentValue : number, _ : number, _ : Int16Array): number => accumulator + currentValue); let res = total.reduce((accumulator : number, currentValue : number, _ : number, _a : Int16Array) : number => accumulator + currentValue);
expect(res).toEqual(6); expect(res).toEqual(6);
total = new Int16Array([0, 1, 2, 3]); total = new Int16Array([0, 1, 2, 3]);
res = total.reduce((accumulator : number, currentValue : number, _ : number, _ : Int16Array): number => accumulator + currentValue, 8); res = total.reduce((accumulator : number, currentValue : number, _ : number, _a : Int16Array) : number => accumulator + currentValue, 8);
expect(res).toEqual(14); expect(res).toEqual(14);
} }
reduceRight() { reduceRight() {
let total = new Int16Array([0, 1, 2, 3]); let total = new Int16Array([0, 1, 2, 3]);
let res = total.reduceRight((accumulator: number, currentValue : number, _ : number, _ : Int16Array): number => accumulator + currentValue); let res = total.reduceRight((accumulator : number, currentValue : number, _ : number, _a : Int16Array) : number => accumulator + currentValue);
expect(res).toEqual(6); expect(res).toEqual(6);
total = new Int16Array([0, 1, 2, 3]); total = new Int16Array([0, 1, 2, 3]);
res = total.reduceRight((accumulator: number, currentValue : number, _ : number, _ : Int16Array): number => accumulator + currentValue, 8); res = total.reduceRight((accumulator : number, currentValue : number, _ : number, _a : Int16Array) : number => accumulator + currentValue, 8);
expect(res).toEqual(14); expect(res).toEqual(14);
} }
...@@ -220,7 +220,7 @@ export class TInt16Array { ...@@ -220,7 +220,7 @@ export class TInt16Array {
numbers.sort(); numbers.sort();
expect(numbers.toString()).toEqual("1,5,40"); expect(numbers.toString()).toEqual("1,5,40");
numbers.sort((a, b):number => a - b); numbers.sort((a, b) : number => a - b);
expect(numbers.toString()).toEqual("1,5,40"); expect(numbers.toString()).toEqual("1,5,40");
} }
...@@ -246,8 +246,8 @@ export class TInt16Array { ...@@ -246,8 +246,8 @@ export class TInt16Array {
float32[4] = 42; float32[4] = 42;
expect(float32.toString()).toEqual("0,0,0,0,42,0,0,0"); expect(float32.toString()).toEqual("0,0,0,0,42,0,0,0");
let res = buffer.slice(8,12); let res = buffer.slice(8, 12);
let sliced = new Int16Array(res); let sliced = new Int16Array(res);
expect(sliced[0]).toEqual(42); expect(sliced[0]).toEqual(42);
} }
} }
\ No newline at end of file
...@@ -78,7 +78,7 @@ export class TInt32Array { ...@@ -78,7 +78,7 @@ export class TInt32Array {
testEvery() { testEvery() {
// const isBelowThreshold = (currentValue: number, index: number, array:Int32Array): boolean => currentValue < 40; // const isBelowThreshold = (currentValue: number, index: number, array:Int32Array): boolean => currentValue < 40;
let result = new Int32Array([12, 5, 8, 130, 44]).every((value:number,_ : number, _ : Int32Array): boolean => value< 40); // let result = new Int32Array([12, 5, 8, 130, 44]).every((value:number,_ : number, _a : Int32Array): boolean => value< 40); //
expect(result).toEqual(false); expect(result).toEqual(false);
} }
...@@ -102,23 +102,23 @@ export class TInt32Array { ...@@ -102,23 +102,23 @@ export class TInt32Array {
testFilter() { testFilter() {
// const isBelowThreshold = (currentValue: number, index: number, _): boolean => currentValue >= 10; // const isBelowThreshold = (currentValue: number, index: number, _): boolean => currentValue >= 10;
let float32 = new Int32Array([12, 5, 8, 44]).filter((value : number, _ : number, _ : Int32Array): boolean => value>= 10); let float32 = new Int32Array([12, 5, 8, 44]).filter((value : number, _ : number, _a : Int32Array): boolean => value>= 10);
expect(float32.toString()).toEqual("12,44"); expect(float32.toString()).toEqual("12,44");
} }
find() { find() {
let float32 = new Int32Array([4, 5, 8, 12]); let float32 = new Int32Array([4, 5, 8, 12]);
let res = float32.find((value : number, _ : number, _ : Int32Array): boolean => value > 5); let res = float32.find((value : number, _ : number, _a : Int32Array): boolean => value > 5);
expect(res).toEqual(8); expect(res).toEqual(8);
} }
findIndex() { findIndex() {
let float32 = new Int32Array([4, 6, 8, 12]); let float32 = new Int32Array([4, 6, 8, 12]);
let res = float32.findIndex((value : number, _ : number, _ : Int32Array): boolean => value > 100); let res = float32.findIndex((value : number, _ : number, _a : Int32Array): boolean => value > 100);
expect(res).toEqual(-1); expect(res).toEqual(-1);
let ufloat32 = new Int32Array([4, 6, 7, 120]); let ufloat32 = new Int32Array([4, 6, 7, 120]);
res = ufloat32.findIndex((value : number, _ : number, _ : Int32Array): boolean => value > 100); res = ufloat32.findIndex((value : number, _ : number, _a : Int32Array): boolean => value > 100);
expect(res).toEqual(3); expect(res).toEqual(3);
} }
...@@ -185,28 +185,28 @@ export class TInt32Array { ...@@ -185,28 +185,28 @@ export class TInt32Array {
map() { map() {
let numbers = new Int32Array([1, 4, 9]); let numbers = new Int32Array([1, 4, 9]);
let doubles = numbers.map((value : number, _ : number, _ : Int32Array): number => value * 2); let doubles = numbers.map((value : number, _ : number, _a : Int32Array): number => value * 2);
expect(numbers.toString()).toEqual("1,4,9"); expect(numbers.toString()).toEqual("1,4,9");
expect(doubles.toString()).toEqual("2,8,18"); expect(doubles.toString()).toEqual("2,8,18");
} }
reduce() { reduce() {
let total = new Int32Array([0, 1, 2, 3]); let total = new Int32Array([0, 1, 2, 3]);
let res = total.reduce((accumulator : number, currentValue : number, _ : number, _ : Int32Array): number => accumulator + currentValue); let res = total.reduce((accumulator : number, currentValue : number, _ : number, _a : Int32Array): number => accumulator + currentValue);
expect(res).toEqual(6); expect(res).toEqual(6);
total = new Int32Array([0, 1, 2, 3]); total = new Int32Array([0, 1, 2, 3]);
res = total.reduce((accumulator : number, currentValue : number, _ : number, _ : Int32Array): number => accumulator + currentValue, 8); res = total.reduce((accumulator : number, currentValue : number, _ : number, _a : Int32Array): number => accumulator + currentValue, 8);
expect(res).toEqual(14); expect(res).toEqual(14);
} }
reduceRight() { reduceRight() {
let total = new Int32Array([0, 1, 2, 3]); let total = new Int32Array([0, 1, 2, 3]);
let res = total.reduceRight((accumulator: number, currentValue : number, _ : number, _ : Int32Array): number => accumulator + currentValue); let res = total.reduceRight((accumulator: number, currentValue : number, _ : number, _a : Int32Array): number => accumulator + currentValue);
expect(res).toEqual(6); expect(res).toEqual(6);
total = new Int32Array([0, 1, 2, 3]); total = new Int32Array([0, 1, 2, 3]);
res = total.reduceRight((accumulator: number, currentValue : number, _ : number, _ : Int32Array): number => accumulator + currentValue, 8); res = total.reduceRight((accumulator: number, currentValue : number, _ : number, _a : Int32Array): number => accumulator + currentValue, 8);
expect(res).toEqual(14); expect(res).toEqual(14);
} }
......
...@@ -60,7 +60,7 @@ export class TInt8Array { ...@@ -60,7 +60,7 @@ export class TInt8Array {
testEvery() { testEvery() {
// const isBelowThreshold = (currentValue: number, index: number, array:Int8Array): boolean => currentValue < 40; // const isBelowThreshold = (currentValue: number, index: number, array:Int8Array): boolean => currentValue < 40;
let result = new Int8Array([12, 5, 8, 130, 44]).every((value: number, _: number, _: Int8Array): boolean => let result = new Int8Array([12, 5, 8, 130, 44]).every((value: number, _: number, _a: Int8Array): boolean =>
value < 40); // value < 40); //
expect(result).toEqual(false); expect(result).toEqual(false);
} }
...@@ -85,24 +85,24 @@ export class TInt8Array { ...@@ -85,24 +85,24 @@ export class TInt8Array {
testFilter() { testFilter() {
// const isBelowThreshold = (currentValue: number, index: number, _): boolean => currentValue >= 10; // const isBelowThreshold = (currentValue: number, index: number, _): boolean => currentValue >= 10;
let float32 = new Int8Array([12, 5, 8, 44]).filter((value: number, _: number, _: Int8Array): boolean => let float32 = new Int8Array([12, 5, 8, 44]).filter((value: number, _: number, _a: Int8Array): boolean =>
value >= 10); value >= 10);
expect(float32.toString()).toEqual("12,44"); expect(float32.toString()).toEqual("12,44");
} }
find() { find() {
let float32 = new Int8Array([4, 5, 8, 12]); let float32 = new Int8Array([4, 5, 8, 12]);
let res = float32.find((value: number, _: number, _: Int8Array): boolean => value > 5); let res = float32.find((value: number, _: number, _a: Int8Array): boolean => value > 5);
expect(res).toEqual(8); expect(res).toEqual(8);
} }
findIndex() { findIndex() {
let float32 = new Int8Array([4, 6, 8, 12]); let float32 = new Int8Array([4, 6, 8, 12]);
let res = float32.findIndex((value: number, _: number, _: Int8Array): boolean => value > 100); let res = float32.findIndex((value: number, _: number, _a: Int8Array): boolean => value > 100);
expect(res).toEqual(-1); expect(res).toEqual(-1);
let ufloat32 = new Int8Array([4, 6, 7, 120]); let ufloat32 = new Int8Array([4, 6, 7, 120]);
res = ufloat32.findIndex((value: number, _: number, _: Int8Array): boolean => value > 100); res = ufloat32.findIndex((value: number, _: number, _a: Int8Array): boolean => value > 100);
expect(res).toEqual(3); expect(res).toEqual(3);
} }
...@@ -173,31 +173,31 @@ export class TInt8Array { ...@@ -173,31 +173,31 @@ export class TInt8Array {
map() { map() {
let numbers = new Int8Array([1, 4, 9]); let numbers = new Int8Array([1, 4, 9]);
let doubles = numbers.map((value: number, _: number, _: Int8Array): number => value * 2); let doubles = numbers.map((value: number, _: number, _a: Int8Array): number => value * 2);
expect(numbers.toString()).toEqual("1,4,9"); expect(numbers.toString()).toEqual("1,4,9");
expect(doubles.toString()).toEqual("2,8,18"); expect(doubles.toString()).toEqual("2,8,18");
} }
reduce() { reduce() {
let total = new Int8Array([0, 1, 2, 3]); let total = new Int8Array([0, 1, 2, 3]);
let res = total.reduce((accumulator: number, currentValue: number, _: number, _: Int8Array): let res = total.reduce((accumulator: number, currentValue: number, _: number, _a: Int8Array):
number => accumulator + currentValue); number => accumulator + currentValue);
expect(res).toEqual(6); expect(res).toEqual(6);
total = new Int8Array([0, 1, 2, 3]); total = new Int8Array([0, 1, 2, 3]);
res = total.reduce((accumulator: number, currentValue: number, _: number, _: Int8Array): number => res = total.reduce((accumulator: number, currentValue: number, _: number, _a: Int8Array): number =>
accumulator + currentValue, 8); accumulator + currentValue, 8);
expect(res).toEqual(14); expect(res).toEqual(14);
} }
reduceRight() { reduceRight() {
let total = new Int8Array([0, 1, 2, 3]); let total = new Int8Array([0, 1, 2, 3]);
let res = total.reduceRight((accumulator: number, currentValue: number, _: number, _: Int8Array): let res = total.reduceRight((accumulator: number, currentValue: number, _: number, _a: Int8Array):
number => accumulator + currentValue); number => accumulator + currentValue);
expect(res).toEqual(6); expect(res).toEqual(6);
total = new Int8Array([0, 1, 2, 3]); total = new Int8Array([0, 1, 2, 3]);
res = total.reduceRight((accumulator: number, currentValue: number, _: number, _: Int8Array): res = total.reduceRight((accumulator: number, currentValue: number, _: number, _a: Int8Array):
number => accumulator + currentValue, 8); number => accumulator + currentValue, 8);
expect(res).toEqual(14); expect(res).toEqual(14);
......
...@@ -69,7 +69,7 @@ export class TUint8Array { ...@@ -69,7 +69,7 @@ export class TUint8Array {
testEvery() { testEvery() {
// const isBelowThreshold = (currentValue: number, index: number, array:Uint8Array): boolean => currentValue < 40; // const isBelowThreshold = (currentValue: number, index: number, array:Uint8Array): boolean => currentValue < 40;
let result = new Uint8Array([12, 5, 8, 130, 44]).every((value: number, _: number, _: Uint8Array): boolean => let result = new Uint8Array([12, 5, 8, 130, 44]).every((value: number, _: number, _a: Uint8Array): boolean =>
value < 40); // value < 40); //
expect(result).toEqual(false); expect(result).toEqual(false);
} }
...@@ -94,24 +94,24 @@ export class TUint8Array { ...@@ -94,24 +94,24 @@ export class TUint8Array {
testFilter() { testFilter() {
// const isBelowThreshold = (currentValue: number, index: number, _): boolean => currentValue >= 10; // const isBelowThreshold = (currentValue: number, index: number, _): boolean => currentValue >= 10;
let float32 = new Uint8Array([12, 5, 8, 44]).filter((value: number, _: number, _: Uint8Array): boolean => value >= let float32 = new Uint8Array([12, 5, 8, 44]).filter((value: number, _: number, _a: Uint8Array): boolean => value >=
10); 10);
expect(float32.toString()).toEqual("12,44"); expect(float32.toString()).toEqual("12,44");
} }
find() { find() {
let float32 = new Uint8Array([4, 5, 8, 12]); let float32 = new Uint8Array([4, 5, 8, 12]);
let res = float32.find((value: number, _: number, _: Uint8Array): boolean => value > 5); let res = float32.find((value: number, _: number, _a: Uint8Array): boolean => value > 5);
expect(res).toEqual(8); expect(res).toEqual(8);
} }
findIndex() { findIndex() {
let float32 = new Uint8Array([4, 6, 8, 12]); let float32 = new Uint8Array([4, 6, 8, 12]);
let res = float32.findIndex((value: number, _: number, _: Uint8Array): boolean => value > 100); let res = float32.findIndex((value: number, _: number, _a: Uint8Array): boolean => value > 100);
expect(res).toEqual(-1); expect(res).toEqual(-1);
let ufloat32 = new Uint8Array([4, 6, 7, 120]); let ufloat32 = new Uint8Array([4, 6, 7, 120]);
res = ufloat32.findIndex((value: number, _: number, _: Uint8Array): boolean => value > 100); res = ufloat32.findIndex((value: number, _: number, _a: Uint8Array): boolean => value > 100);
expect(res).toEqual(3); expect(res).toEqual(3);
} }
...@@ -178,31 +178,31 @@ export class TUint8Array { ...@@ -178,31 +178,31 @@ export class TUint8Array {
map() { map() {
let numbers = new Uint8Array([1, 4, 9]); let numbers = new Uint8Array([1, 4, 9]);
let doubles = numbers.map((value: number, _: number, _: Uint8Array): number => value * 2); let doubles = numbers.map((value: number, _: number, _a: Uint8Array): number => value * 2);
expect(numbers.toString()).toEqual("1,4,9"); expect(numbers.toString()).toEqual("1,4,9");
expect(doubles.toString()).toEqual("2,8,18"); expect(doubles.toString()).toEqual("2,8,18");
} }
reduce() { reduce() {
let total = new Uint8Array([0, 1, 2, 3]); let total = new Uint8Array([0, 1, 2, 3]);
let res = total.reduce((accumulator: number, currentValue: number, _: number, _: Uint8Array): number => let res = total.reduce((accumulator: number, currentValue: number, _: number, _a: Uint8Array): number =>
accumulator + currentValue); accumulator + currentValue);
expect(res).toEqual(6); expect(res).toEqual(6);
total = new Uint8Array([0, 1, 2, 3]); total = new Uint8Array([0, 1, 2, 3]);
res = total.reduce((accumulator: number, currentValue: number, _: number, _: Uint8Array): number => accumulator + res = total.reduce((accumulator: number, currentValue: number, _: number, _a: Uint8Array): number => accumulator +
currentValue, 8); currentValue, 8);
expect(res).toEqual(14); expect(res).toEqual(14);
} }
reduceRight() { reduceRight() {
let total = new Uint8Array([0, 1, 2, 3]); let total = new Uint8Array([0, 1, 2, 3]);
let res = total.reduceRight((accumulator: number, currentValue: number, _: number, _: Uint8Array): number => let res = total.reduceRight((accumulator: number, currentValue: number, _: number, _a: Uint8Array): number =>
accumulator + currentValue); accumulator + currentValue);
expect(res).toEqual(6); expect(res).toEqual(6);
total = new Uint8Array([0, 1, 2, 3]); total = new Uint8Array([0, 1, 2, 3]);
res = total.reduceRight((accumulator: number, currentValue: number, _: number, _: Uint8Array): number => res = total.reduceRight((accumulator: number, currentValue: number, _: number, _a: Uint8Array): number =>
accumulator + currentValue, 8); accumulator + currentValue, 8);
expect(res).toEqual(14); expect(res).toEqual(14);
} }
......
...@@ -64,7 +64,7 @@ export class TUint8ClampedArray { ...@@ -64,7 +64,7 @@ export class TUint8ClampedArray {
testEvery() { testEvery() {
// const isBelowThreshold = (currentValue: number, index: number, array:Uint8ClampedArray): boolean => currentValue < 40; // const isBelowThreshold = (currentValue: number, index: number, array:Uint8ClampedArray): boolean => currentValue < 40;
let result = new Uint8ClampedArray([12, 5, 8, 130, 44]).every((value: number, _: number, _: let result = new Uint8ClampedArray([12, 5, 8, 130, 44]).every((value: number, _: number, _a:
Uint8ClampedArray): boolean => value < 40); // Uint8ClampedArray): boolean => value < 40); //
expect(result).toEqual(false); expect(result).toEqual(false);
} }
...@@ -89,24 +89,24 @@ export class TUint8ClampedArray { ...@@ -89,24 +89,24 @@ export class TUint8ClampedArray {
testFilter() { testFilter() {
// const isBelowThreshold = (currentValue: number, index: number, _): boolean => currentValue >= 10; // const isBelowThreshold = (currentValue: number, index: number, _): boolean => currentValue >= 10;
let float32 = new Uint8ClampedArray([12, 5, 8, 44]).filter((value: number, _: number, _: let float32 = new Uint8ClampedArray([12, 5, 8, 44]).filter((value: number, _: number, _a:
Uint8ClampedArray): boolean => value >= 10); Uint8ClampedArray): boolean => value >= 10);
expect(float32.toString()).toEqual("12,44"); expect(float32.toString()).toEqual("12,44");
} }
find() { find() {
let float32 = new Uint8ClampedArray([4, 5, 8, 12]); let float32 = new Uint8ClampedArray([4, 5, 8, 12]);
let res = float32.find((value: number, _: number, _: Uint8ClampedArray): boolean => value > 5); let res = float32.find((value: number, _: number, _a: Uint8ClampedArray): boolean => value > 5);
expect(res).toEqual(8); expect(res).toEqual(8);
} }
findIndex() { findIndex() {
let float32 = new Uint8ClampedArray([4, 6, 8, 12]); let float32 = new Uint8ClampedArray([4, 6, 8, 12]);
let res = float32.findIndex((value: number, _: number, _: Uint8ClampedArray): boolean => value > 100); let res = float32.findIndex((value: number, _: number, _a: Uint8ClampedArray): boolean => value > 100);
expect(res).toEqual(-1); expect(res).toEqual(-1);
let ufloat32 = new Uint8ClampedArray([4, 6, 7, 120]); let ufloat32 = new Uint8ClampedArray([4, 6, 7, 120]);
res = ufloat32.findIndex((value: number, _: number, _: Uint8ClampedArray): boolean => value > 100); res = ufloat32.findIndex((value: number, _: number, _a: Uint8ClampedArray): boolean => value > 100);
expect(res).toEqual(3); expect(res).toEqual(3);
} }
...@@ -173,31 +173,31 @@ export class TUint8ClampedArray { ...@@ -173,31 +173,31 @@ export class TUint8ClampedArray {
map() { map() {
let numbers = new Uint8ClampedArray([1, 4, 9]); let numbers = new Uint8ClampedArray([1, 4, 9]);
let doubles = numbers.map((value: number, _: number, _: Uint8ClampedArray): number => value * 2); let doubles = numbers.map((value: number, _: number, _a: Uint8ClampedArray): number => value * 2);
expect(numbers.toString()).toEqual("1,4,9"); expect(numbers.toString()).toEqual("1,4,9");
expect(doubles.toString()).toEqual("2,8,18"); expect(doubles.toString()).toEqual("2,8,18");
} }
reduce() { reduce() {
let total = new Uint8ClampedArray([0, 1, 2, 3]); let total = new Uint8ClampedArray([0, 1, 2, 3]);
let res = total.reduce((accumulator: number, currentValue: number, _: number, _: let res = total.reduce((accumulator: number, currentValue: number, _: number, _a:
Uint8ClampedArray): number => accumulator + currentValue); Uint8ClampedArray): number => accumulator + currentValue);
expect(res).toEqual(6); expect(res).toEqual(6);
total = new Uint8ClampedArray([0, 1, 2, 3]); total = new Uint8ClampedArray([0, 1, 2, 3]);
res = total.reduce((accumulator: number, currentValue: number, _: number, _: Uint8ClampedArray): res = total.reduce((accumulator: number, currentValue: number, _: number, _a: Uint8ClampedArray):
number => accumulator + currentValue, 8); number => accumulator + currentValue, 8);
expect(res).toEqual(14); expect(res).toEqual(14);
} }
reduceRight() { reduceRight() {
let total = new Uint8ClampedArray([0, 1, 2, 3]); let total = new Uint8ClampedArray([0, 1, 2, 3]);
let res = total.reduceRight((accumulator: number, currentValue: number, _: number, _: let res = total.reduceRight((accumulator: number, currentValue: number, _: number, _a:
Uint8ClampedArray): number => accumulator + currentValue); Uint8ClampedArray): number => accumulator + currentValue);
expect(res).toEqual(6); expect(res).toEqual(6);
total = new Uint8ClampedArray([0, 1, 2, 3]); total = new Uint8ClampedArray([0, 1, 2, 3]);
res = total.reduceRight((accumulator: number, currentValue: number, _: number, _: res = total.reduceRight((accumulator: number, currentValue: number, _: number, _a:
Uint8ClampedArray): number => accumulator + currentValue, 8); Uint8ClampedArray): number => accumulator + currentValue, 8);
expect(res).toEqual(14); expect(res).toEqual(14);
} }
......
...@@ -78,7 +78,7 @@ export class TUint16Array { ...@@ -78,7 +78,7 @@ export class TUint16Array {
testEvery() { testEvery() {
// const isBelowThreshold = (currentValue: number, index: number, array:Uint16Array): boolean => currentValue < 40; // const isBelowThreshold = (currentValue: number, index: number, array:Uint16Array): boolean => currentValue < 40;
let result = new Uint16Array([12, 5, 8, 130, 44]).every((value: number, _: number, _: Uint16Array): let result = new Uint16Array([12, 5, 8, 130, 44]).every((value: number, _: number, _a: Uint16Array):
boolean => value < 40); // boolean => value < 40); //
expect(result).toEqual(false); expect(result).toEqual(false);
} }
...@@ -103,29 +103,29 @@ export class TUint16Array { ...@@ -103,29 +103,29 @@ export class TUint16Array {
testFilter() { testFilter() {
// const isBelowThreshold = (currentValue: number, index: number, _): boolean => currentValue >= 10; // const isBelowThreshold = (currentValue: number, index: number, _): boolean => currentValue >= 10;
let float32 = new Uint16Array([12, 5, 8, 44]).filter((value: number, _: number, _: Uint16Array): let float32 = new Uint16Array([12, 5, 8, 44]).filter((value: number, _: number, _a: Uint16Array):
boolean => value >= 10); boolean => value >= 10);
expect(float32.toString()).toEqual("12,44"); expect(float32.toString()).toEqual("12,44");
} }
find() { find() {
let float32 = new Uint16Array([4, 5, 8, 12]); let float32 = new Uint16Array([4, 5, 8, 12]);
let res = float32.find((value: number, _: number, _: Uint16Array): boolean => value > 5); let res = float32.find((value: number, _: number, _a: Uint16Array): boolean => value > 5);
expect(res).toEqual(8); expect(res).toEqual(8);
} }
findIndex() { findIndex() {
let float32 = new Uint16Array([4, 6, 8, 12]); let float32 = new Uint16Array([4, 6, 8, 12]);
let res = float32.findIndex((value: number, _: number, _: Uint16Array): boolean => value > 100); let res = float32.findIndex((value: number, _: number, _a: Uint16Array): boolean => value > 100);
expect(res).toEqual(-1); expect(res).toEqual(-1);
let ufloat32 = new Uint16Array([4, 6, 7, 120]); let ufloat32 = new Uint16Array([4, 6, 7, 120]);
res = ufloat32.findIndex((value: number, _: number, _: Uint16Array): boolean => value > 100); res = ufloat32.findIndex((value: number, _: number, _a: Uint16Array): boolean => value > 100);
expect(res).toEqual(3); expect(res).toEqual(3);
} }
foreach() { foreach() {
new Uint16Array([0, 1, 2, 3]).forEach((value: number, index: number, _: Uint16Array) => { new Uint16Array([0, 1, 2, 3]).forEach((value: number, index: number, _a: Uint16Array) => {
console.log(`a[${index}] = ${value}`); console.log(`a[${index}] = ${value}`);
}); });
} }
...@@ -187,31 +187,31 @@ export class TUint16Array { ...@@ -187,31 +187,31 @@ export class TUint16Array {
map() { map() {
let numbers = new Uint16Array([1, 4, 9]); let numbers = new Uint16Array([1, 4, 9]);
let doubles = numbers.map((value: number, _: number, _: Uint16Array): number => value * 2); let doubles = numbers.map((value: number, _: number, _a: Uint16Array): number => value * 2);
expect(numbers.toString()).toEqual("1,4,9"); expect(numbers.toString()).toEqual("1,4,9");
expect(doubles.toString()).toEqual("2,8,18"); expect(doubles.toString()).toEqual("2,8,18");
} }
reduce() { reduce() {
let total = new Uint16Array([0, 1, 2, 3]); let total = new Uint16Array([0, 1, 2, 3]);
let res = total.reduce((accumulator: number, currentValue: number, _: number, _: Uint16Array): let res = total.reduce((accumulator: number, currentValue: number, _: number, _a: Uint16Array):
number => accumulator + currentValue); number => accumulator + currentValue);
expect(res).toEqual(6); expect(res).toEqual(6);
total = new Uint16Array([0, 1, 2, 3]); total = new Uint16Array([0, 1, 2, 3]);
res = total.reduce((accumulator: number, currentValue: number, _: number, _: Uint16Array): res = total.reduce((accumulator: number, currentValue: number, _: number, _a: Uint16Array):
number => accumulator + currentValue, 8); number => accumulator + currentValue, 8);
expect(res).toEqual(14); expect(res).toEqual(14);
} }
reduceRight() { reduceRight() {
let total = new Uint16Array([0, 1, 2, 3]); let total = new Uint16Array([0, 1, 2, 3]);
let res = total.reduceRight((accumulator: number, currentValue: number, _: number, _: Uint16Array): let res = total.reduceRight((accumulator: number, currentValue: number, _: number, _a: Uint16Array):
number => accumulator + currentValue); number => accumulator + currentValue);
expect(res).toEqual(6); expect(res).toEqual(6);
total = new Uint16Array([0, 1, 2, 3]); total = new Uint16Array([0, 1, 2, 3]);
res = total.reduceRight((accumulator: number, currentValue: number, _: number, _: Uint16Array): res = total.reduceRight((accumulator: number, currentValue: number, _: number, _a: Uint16Array):
number => accumulator + currentValue, 8); number => accumulator + currentValue, 8);
expect(res).toEqual(14); expect(res).toEqual(14);
} }
......
...@@ -78,7 +78,7 @@ export class TUint32Array { ...@@ -78,7 +78,7 @@ export class TUint32Array {
testEvery() { testEvery() {
// const isBelowThreshold = (currentValue: number, index: number, array:Uint32Array): boolean => currentValue < 40; // const isBelowThreshold = (currentValue: number, index: number, array:Uint32Array): boolean => currentValue < 40;
let result = new Uint32Array([12, 5, 8, 130, 44]).every((value: number, _: number, _: Uint32Array): let result = new Uint32Array([12, 5, 8, 130, 44]).every((value: number, _: number, _a: Uint32Array):
boolean => value < 40); // boolean => value < 40); //
expect(result).toEqual(false); expect(result).toEqual(false);
} }
...@@ -103,29 +103,29 @@ export class TUint32Array { ...@@ -103,29 +103,29 @@ export class TUint32Array {
testFilter() { testFilter() {
// const isBelowThreshold = (currentValue: number, index: number, _): boolean => currentValue >= 10; // const isBelowThreshold = (currentValue: number, index: number, _): boolean => currentValue >= 10;
let float32 = new Uint32Array([12, 5, 8, 44]).filter((value: number, _: number, _: Uint32Array): let float32 = new Uint32Array([12, 5, 8, 44]).filter((value: number, _: number, _a: Uint32Array):
boolean => value >= 10); boolean => value >= 10);
expect(float32.toString()).toEqual("12,44"); expect(float32.toString()).toEqual("12,44");
} }
find() { find() {
let float32 = new Uint32Array([4, 5, 8, 12]); let float32 = new Uint32Array([4, 5, 8, 12]);
let res = float32.find((value: number, _: number, _: Uint32Array): boolean => value > 5); let res = float32.find((value: number, _: number, _a: Uint32Array): boolean => value > 5);
expect(res).toEqual(8); expect(res).toEqual(8);
} }
findIndex() { findIndex() {
let float32 = new Uint32Array([4, 6, 8, 12]); let float32 = new Uint32Array([4, 6, 8, 12]);
let res = float32.findIndex((value: number, _: number, _: Uint32Array): boolean => value > 100); let res = float32.findIndex((value: number, _: number, _a: Uint32Array): boolean => value > 100);
expect(res).toEqual(-1); expect(res).toEqual(-1);
let ufloat32 = new Uint32Array([4, 6, 7, 120]); let ufloat32 = new Uint32Array([4, 6, 7, 120]);
res = ufloat32.findIndex((value: number, _: number, _: Uint32Array): boolean => value > 100); res = ufloat32.findIndex((value: number, _: number, _a: Uint32Array): boolean => value > 100);
expect(res).toEqual(3); expect(res).toEqual(3);
} }
foreach() { foreach() {
new Uint32Array([0, 1, 2, 3]).forEach((value: number, index: number, _: Uint32Array) => { new Uint32Array([0, 1, 2, 3]).forEach((value: number, index: number, _a: Uint32Array) => {
console.log(`a[${index}] = ${value}`); console.log(`a[${index}] = ${value}`);
}); });
} }
...@@ -187,31 +187,31 @@ export class TUint32Array { ...@@ -187,31 +187,31 @@ export class TUint32Array {
map() { map() {
let numbers = new Uint32Array([1, 4, 9]); let numbers = new Uint32Array([1, 4, 9]);
let doubles = numbers.map((value: number, _: number, _: Uint32Array): number => value * 2); let doubles = numbers.map((value: number, _: number, _a: Uint32Array): number => value * 2);
expect(numbers.toString()).toEqual("1,4,9"); expect(numbers.toString()).toEqual("1,4,9");
expect(doubles.toString()).toEqual("2,8,18"); expect(doubles.toString()).toEqual("2,8,18");
} }
reduce() { reduce() {
let total = new Uint32Array([0, 1, 2, 3]); let total = new Uint32Array([0, 1, 2, 3]);
let res = total.reduce((accumulator: number, currentValue: number, _: number, _: Uint32Array): let res = total.reduce((accumulator: number, currentValue: number, _: number, _a: Uint32Array):
number => accumulator + currentValue); number => accumulator + currentValue);
expect(res).toEqual(6); expect(res).toEqual(6);
total = new Uint32Array([0, 1, 2, 3]); total = new Uint32Array([0, 1, 2, 3]);
res = total.reduce((accumulator: number, currentValue: number, _: number, _: Uint32Array): res = total.reduce((accumulator: number, currentValue: number, _: number, _a: Uint32Array):
number => accumulator + currentValue, 8); number => accumulator + currentValue, 8);
expect(res).toEqual(14); expect(res).toEqual(14);
} }
reduceRight() { reduceRight() {
let total = new Uint32Array([0, 1, 2, 3]); let total = new Uint32Array([0, 1, 2, 3]);
let res = total.reduceRight((accumulator: number, currentValue: number, _: number, _: Uint32Array): let res = total.reduceRight((accumulator: number, currentValue: number, _: number, _a: Uint32Array):
number => accumulator + currentValue); number => accumulator + currentValue);
expect(res).toEqual(6); expect(res).toEqual(6);
total = new Uint32Array([0, 1, 2, 3]); total = new Uint32Array([0, 1, 2, 3]);
res = total.reduceRight((accumulator: number, currentValue: number, _: number, _: Uint32Array): res = total.reduceRight((accumulator: number, currentValue: number, _: number, _a: Uint32Array):
number => accumulator + currentValue, 8); number => accumulator + currentValue, 8);
expect(res).toEqual(14); expect(res).toEqual(14);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册