Skip to content

Commit 4f951f7

Browse files
committed
fix: handle Float16Array input in Float16Array constructor
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent f5df2eb commit 4f951f7

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

  • lib/node_modules/@stdlib/array/float16/lib

lib/node_modules/@stdlib/array/float16/lib/main.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,11 @@ function Float16Array() {
183183
if ( isNonNegativeInteger( arg ) ) {
184184
buf = new Uint16Array( arg );
185185
} else if ( isCollection( arg ) ) {
186-
buf = fromArray( new Uint16Array( arg.length ), arg );
186+
if ( isFloat16Array( arg ) ) {
187+
buf = new Uint16Array( arg.buffer );
188+
} else {
189+
buf = fromArray( new Uint16Array( arg.length ), arg );
190+
}
187191
} else if ( isArrayBuffer( arg ) ) {
188192
if ( !isInteger( arg.byteLength/BYTES_PER_ELEMENT ) ) {
189193
throw new RangeError( format( 'invalid argument. ArrayBuffer byte length must be a multiple of %u. Byte length: `%u`.', BYTES_PER_ELEMENT, arg.byteLength ) );

0 commit comments

Comments
 (0)