晴明的博客园 GitHub      CodePen      CodeWars     

[js] ArrayBuffer

ArrayBuffer

ArrayBuffer对象是用来表示一个通用的,固定长度的二进制数据缓冲区。
不能直接操纵ArrayBuffer的内容,
而是应该创建一个表示特定格式的buffer的类型化数组对象(typed array objects)或
数据视图对象DataView 来对buffer的内容进行读取和写入操作.

ArrayBuffer ArrayBuffer(unsigned long length);

DataView

DataView视图提供了一个与平台中字节在内存中的排列顺序(字节序)无关的
从ArrayBuffer读写多数字类型的底层接口.

new DataView(buffer [, byteOffset [, byteLength]])

TypedArray

TypedArray 对象描述表示底层的二进制数据缓存区的类数组(array-like)视图.
没有名为 TypedArray 的全局属性,也不存在直接可见的 TypedArray 构造器。


new TypedArray(length); 
new TypedArray(typedArray); 
new TypedArray(object); 
new TypedArray(buffer [, byteOffset [, length]]); 


//常见的
Int8Array(); 
Uint8Array(); 
Uint8ClampedArray();
Int16Array(); 
Uint16Array();
Int32Array(); 
Uint32Array(); 
Float32Array(); 
Float64Array();

Uint8ClampedArray

The Uint8ClampedArray typed array represents an array of 8-bit unsigned integers clamped to 0-255;
if you specified a value that is out of the range of [0,255],
0 or 255 will be set instead.
The contents are initialized to 0.
Once established, you can reference elements in the array using the object's methods,
or using standard array index syntax .

new Uint8ClampedArray(length);
new Uint8ClampedArray(typedArray);
new Uint8ClampedArray(object);
new Uint8ClampedArray(buffer [, byteOffset [, length]]);

Uint32Array

Uint32Array表示一个由基于平台字节序的32位无符号字节组成的数组.
如果需要对字节顺序进行控制,使用DataView代替.
数组中每个元素的初始值都是0.
一旦创建,可以用对象的方法引用数组里的元素,
或者使用标准的数组索引语法(即,使用中括号)。

Uint32Array(length);
Uint32Array(typedArray);
Uint32Array(object);
Uint32Array(buffer [, byteOffset [, length]]);

posted @ 2016-12-21 16:58  晴明桑  阅读(741)  评论(0编辑  收藏  举报