Lines Matching refs:Uint8Array
13 以Uint8Array为例,变更前,map函数的callbackFn声明无返回值,导致转换后的数据丢失,引起开发者使用上的困惑。
14 - map方法的回调函数声明为`map(callbackFn: TypedArrayForEachCallback<number, Uint8Array>): Uint8Array;`
30 // 创建一个Uint8Array
31 let uint8: collections.Uint8Array = new collections.Uint8Array(arr);
33 // 情况一:不能完成map功能:callbackFn无返回值,map函数返回新的collections.Uint8Array
34 let zeroMappedArray: collections.Uint8Array = uint8.map((value: number) => {}); // 能通过编译
35 console.info('' + zeroMappedArray); // 输出: collections.Uint8Array [0, 0, 0, 0, 0]
37 // 情况二:能完成map功能:callbackFn返回map后的元素值,但类型为string,map函数返回新的collections.Uint8Array
38 let wrongTypeMapped: collections.Uint8Array = uint8.map((value: number) => value + "1"); // 能通过编译
39 console.info('' + wrongTypeMapped); // 输出: collections.Uint8Array [11, 21, 31, 41, 51]
41 // 情况三:能完成map功能:callbackFn返回map后的元素值,map函数返回新的collections.Uint8Array
42 let normalMapped: collections.Uint8Array = uint8.map((value: number) => value * 2); // 能通过编译
43 console.info('' + normalMapped); // 输出: collections.Uint8Array [2, 4, 6, 8, 10]
56 // 创建一个Uint8Array
57 let uint8: collections.Uint8Array = new collections.Uint8Array(arr);
59 // 情况一:不能完成map功能:callbackFn无返回值,map函数返回新的collections.Uint8Array
60 let zeroMappedArray: collections.Uint8Array = uint8.map((value: number) => {}); // 不兼容变更:不能通过编译
62 // 情况二:能完成map功能:callbackFn返回map后的元素值,但类型为string,map函数返回新的collections.Uint8Array
63 let wrongTypeMapped: collections.Uint8Array = uint8.map((value: number) => value + "1"); // 不兼容变更:不…
65 // 情况三:能完成map功能:callbackFn返回map后的元素值,map函数返回新的collections.Uint8Array
66 let normalMapped: collections.Uint8Array = uint8.map((value: number) => value * 2); // 能通过编译
67 console.info('' + normalMapped); // 输出: collections.Uint8Array [2, 4, 6, 8, 10]
80 /interface/sdk-js/arkts/@arkts.collections.d.ets中TypedArray(包括Int8Array/Uint8Array/Int16Array/Uint1…
86 let wrongTypeMapped: collections.Uint8Array = uint8.map((value: number) => parseInt(value + "1")); …