File tree Expand file tree Collapse file tree 4 files changed +121
-121
lines changed
4-binary/01-arraybuffer-binary-arrays Expand file tree Collapse file tree 4 files changed +121
-121
lines changed Original file line number Diff line number Diff line change 1
1
function concat ( arrays ) {
2
- // sum of individual array lengths
2
+ // 对每个数组长度求和
3
3
let totalLength = arrays . reduce ( ( acc , value ) => acc + value . length , 0 ) ;
4
4
5
5
if ( ! arrays . length ) return null ;
6
6
7
7
let result = new Uint8Array ( totalLength ) ;
8
8
9
- // for each array - copy it over result
10
- // next array is copied right after the previous one
9
+ // 对于每个数组 — 复制到 result
10
+ // 下一个数组在前一个后面复制
11
11
let length = 0 ;
12
12
for ( let array of arrays ) {
13
13
result . set ( array , length ) ;
Original file line number Diff line number Diff line change 1
1
function concat ( arrays ) {
2
- // ...your code...
2
+ // ……你的代码……
3
3
}
4
4
5
5
let chunks = [
Original file line number Diff line number Diff line change 1
1
2
- # Concatenate typed arrays
2
+ # 拼接类型化数组( Concatenate typed arrays)
3
3
4
- Given an array of ` Uint8Array ` , write a function ` concat(arrays) ` that returns a concatenation of them into a single array.
4
+ 给定一个 ` Uint8Array ` 数组,请写一个函数 ` concat(arrays) ` ,将数组拼接成一个单一数组并返回。
You can’t perform that action at this time.
0 commit comments