Skip to content

Commit 7053c83

Browse files
committed
fix: address byteOffset bugs
--- 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 66ff6f9 commit 7053c83

File tree

9 files changed

+25
-13
lines changed

9 files changed

+25
-13
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ function getBigInt( obj, method ) {
4646
* @returns {BigInt} result
4747
*/
4848
function getter() {
49-
return this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); // eslint-disable-line max-len
49+
var view = this[ PRIVATE_BUFFER ];
50+
return view[ method ]( view.byteOffset+obj.byteOffset, IS_LITTLE_ENDIAN ); // eslint-disable-line max-len
5051
}
5152
}
5253

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ function getBoolean( obj, method ) {
4747
* @returns {boolean} result
4848
*/
4949
function getter() {
50-
return Boolean( this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) ); // eslint-disable-line max-len
50+
var view = this[ PRIVATE_BUFFER ];
51+
return Boolean( view[ method ]( view.byteOffset+obj.byteOffset, IS_LITTLE_ENDIAN ) ); // eslint-disable-line max-len
5152
}
5253
}
5354

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,9 @@ function getComplex( obj, method ) {
5656
* @returns {Complex} result
5757
*/
5858
function getter() {
59-
var re = this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );
60-
var im = this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset+(obj.byteLength/2), IS_LITTLE_ENDIAN );
59+
var view = this[ PRIVATE_BUFFER ];
60+
var re = view[ method ]( view.byteOffset+obj.byteOffset, IS_LITTLE_ENDIAN );
61+
var im = view[ method ]( view.byteOffset+obj.byteOffset+(obj.byteLength/2), IS_LITTLE_ENDIAN );
6162
return complex( re, im, CMPLX_TO_REAL[ obj.type ] );
6263
}
6364
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ function getNumber( obj, method ) {
4646
* @returns {number} result
4747
*/
4848
function getter() {
49-
return this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); // eslint-disable-line max-len
49+
var view = this[ PRIVATE_BUFFER ];
50+
return view[ method ]( view.byteOffset+obj.byteOffset, IS_LITTLE_ENDIAN ); // eslint-disable-line max-len
5051
}
5152
}
5253

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ function setBigInt( obj, method ) {
6161
* @throws {TypeError} cannot cast provided values to field data type
6262
*/
6363
function setter( value ) {
64+
var view;
6465
var dt;
6566
var v;
66-
6767
if ( isBigInt( value ) ) {
6868
dt = 'int64'; // FIXME: support both int64 and uint64
6969
v = value;
@@ -88,7 +88,8 @@ function setBigInt( obj, method ) {
8888
if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {
8989
throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );
9090
}
91-
this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );
91+
view = this[ PRIVATE_BUFFER ];
92+
view[ method ]( view.byteOffset+obj.byteOffset, v, IS_LITTLE_ENDIAN );
9293
}
9394
}
9495

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ function setBoolean( obj, method ) {
6060
* @throws {TypeError} cannot cast provided values to field data type
6161
*/
6262
function setter( value ) {
63+
var view;
6364
var dt;
6465
var v;
6566
if ( isBoolean( value ) ) {
@@ -81,7 +82,8 @@ function setBoolean( obj, method ) {
8182
if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {
8283
throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );
8384
}
84-
this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );
85+
view = this[ PRIVATE_BUFFER ];
86+
view[ method ]( view.byteOffset+obj.byteOffset, v, IS_LITTLE_ENDIAN );
8587
}
8688
}
8789

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ function setComplex( obj, method ) {
5656
* @throws {TypeError} cannot cast provided values to field data type
5757
*/
5858
function setter( value ) {
59+
var view;
5960
var dt;
6061
var re;
6162
var im;
62-
6363
if ( isComplexLike( value ) ) {
6464
dt = complexDType( value ) || obj.type;
6565
re = value.re;
@@ -84,8 +84,9 @@ function setComplex( obj, method ) {
8484
if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {
8585
throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );
8686
}
87-
this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );
88-
this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );
87+
view = this[ PRIVATE_BUFFER ];
88+
view[ method ]( view.byteOffset+obj.byteOffset, re, IS_LITTLE_ENDIAN );
89+
view[ method ]( view.byteOffset+obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );
8990
}
9091
}
9192

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ function setNumber( obj, method ) {
6262
* @throws {TypeError} cannot cast provided values to field data type
6363
*/
6464
function setter( value ) {
65+
var view;
6566
var dt;
6667
var v;
6768
if ( isNumber( value ) ) {
@@ -91,7 +92,8 @@ function setNumber( obj, method ) {
9192
if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {
9293
throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );
9394
}
94-
this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );
95+
view = this[ PRIVATE_BUFFER ];
96+
view[ method ]( view.byteOffset+obj.byteOffset, v, IS_LITTLE_ENDIAN );
9597
}
9698
}
9799

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ function setTypedArray( obj ) {
6565
*/
6666
function setter( value ) {
6767
var view;
68+
var buf;
6869
var dt;
6970
if ( !isCollection( value ) || isStruct( value ) ) {
7071
throw new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );
@@ -76,7 +77,8 @@ function setTypedArray( obj ) {
7677
if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {
7778
throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );
7879
}
79-
view = typedarray( this[ PRIVATE_BUFFER ].buffer, obj.byteOffset, obj.length, obj.type );
80+
buf = this[ PRIVATE_BUFFER ];
81+
view = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type );
8082
if ( dt === obj.type ) {
8183
// Case: complex => complex
8284
if ( isComplexDataType( dt ) ) {

0 commit comments

Comments
 (0)