Skip to content

TypedArray improvements and tests#39

Merged
jasongin merged 1 commit intonodejs:masterfrom
jasongin:typedarray
May 23, 2017
Merged

TypedArray improvements and tests#39
jasongin merged 1 commit intonodejs:masterfrom
jasongin:typedarray

Conversation

@jasongin
Copy link
Copy Markdown
Member

  • Rename TypedArray_<> to TypedArrayOf<>.
  • Remove the second template parameter from TypedArrayOf<>, because it can be (usually) inferred from the first parameter and is only needed at object construction time.
  • Remove the TypedArray::As*Array() methods, which were redundant because they did the same thing as Value::As().
  • Add doc-comments to ArrayBuffer, TypedArray, and TypedArrayOf<> classes.
  • Add tests for typed arrays.

@jasongin jasongin requested review from addaleax and boingoing May 17, 2017 16:36
Comment thread napi-inl.h Outdated
if (!(type == TypedArrayTypeForPrimitiveType<T>() ||
(type == napi_uint8_clamped_array && std::is_same<T, uint8_t>::value))) {
throw TypeError::New(env, "Array type must match the template parameter. "
" (Uint8 arrays may optionally have the \"clamped\" array type.)");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will result in a double space when the strings are concatenated across lines, I’m not sure that’s intended? (Also, I think I’d just spell it as Uint8Arrays)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll remove the extra space.

I didn't refer to Uint8Array specifically because that's just a typedef; Some people may prefer to just use TypedArrayOf<uint8_t> instead.

 - Rename TypedArray_<> to TypedArrayOf<>
 - Remove the second template parameter from TypedArrayOf<>, because
   it can be (usually) inferred from the first parameter and is only
   needed at object construction time.
 - Remove the TypedArray::As*Array() methods, which were redundant
   because they did the same thing as Value::As().
 - Add doc-comments to ArrayBuffer, TypedArray, and TypedArrayOf<>
   classes
 - Add tests for typed arrays
@jasongin jasongin merged commit bc683eb into nodejs:master May 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants