>
> "A Buffer object can also be used with typed arrays. The buffer object is 
> cloned to an ArrayBuffer that is used as the backing store for the typed 
> array. 
>

Not sure if 'cloned' is the most appropriate term here.

var ab = new Uint32Array(new Buffer(16));
>
> and get
> ab.length == 4;
>
> but this is not so 
> ab.length is 16 
>
> is it a bug? or I get that paragraph wrong?
>

This is not a bug. ab will have the same length as the parameter. You can, 
for example, do 

ab = new Uint32Array({ length: 100 });

and ab will have a length of 100.

https://www.khronos.org/registry/typedarray/specs/latest/

I think this is the section that you should look for:

TypedArray(type[] array)
Create a new ArrayBuffer with enough bytes to hold array.length elements of 
this typed array, then creates a typed array view referring to the full 
buffer. The contents of the new view are initialized to the contents of the 
given array or typed array, with each element converted to the appropriate 
typed array type.

Note that the buffer is not an ArrayBuffer so I think this is the way the 
constructor is called. Also note that the elements from the buffer are 
converted to the appropriate typed array type. So that's why I think the 
array buffer is not really cloned, but rather it is 'transformed' into 
another one. ab.buffer clearly gives you a different buffer than the 
original array buffer.

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/8ddba24d-47bc-40bf-aac3-2b5e49a2b00a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to