Skip to content

Commit 4ecf9ad

Browse files
committed
refactor: create a minimal view
No need to create a DataView which extends beyond the length of the struct. --- 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 8fc1489 commit 4ecf9ad

File tree

1 file changed

+2
-1
lines changed
  • lib/node_modules/@stdlib/dstructs/struct/lib

1 file changed

+2
-1
lines changed

lib/node_modules/@stdlib/dstructs/struct/lib/main.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ var isCollection = require( '@stdlib/assert/is-collection' );
2929
var isArrayBuffer = require( '@stdlib/assert/is-arraybuffer' );
3030
var isObject = require( '@stdlib/assert/is-object' );
3131
var hasProp = require( '@stdlib/assert/has-property' );
32+
var min = require( '@stdlib/math/base/special/fast/min' );
3233
var join = require( '@stdlib/array/base/join' );
3334
var filled = require( '@stdlib/array/base/filled' );
3435
var indexOf = require( '@stdlib/array/base/index-of' );
@@ -197,7 +198,7 @@ function factory( fields ) {
197198
if ( !isNonNegativeInteger( byteLength ) ) {
198199
throw new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );
199200
}
200-
view = new DataView( arg, byteOffset, byteLength );
201+
view = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len
201202
}
202203
}
203204
if ( view.byteLength < BYTE_LENGTH ) {

0 commit comments

Comments
 (0)