Skip to content

Commit d705c4c

Browse files
committed
refactor: guard against null and undefined
--- 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 27f1ef7 commit d705c4c

File tree

1 file changed

+5
-3
lines changed
  • lib/node_modules/@stdlib/ndarray/base/bytes-per-element/lib

1 file changed

+5
-3
lines changed

lib/node_modules/@stdlib/ndarray/base/bytes-per-element/lib/main.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,11 @@ function bytesPerElement( dtype ) {
6060
if ( isString( dtype ) ) {
6161
return BYTES_PER_ELEMENT[ dtype ] || null;
6262
}
63-
v = dtype.byteLength;
64-
if ( isPositiveInteger( v ) ) {
65-
return v;
63+
if ( dtype ) {
64+
v = dtype.byteLength;
65+
if ( isPositiveInteger( v ) ) {
66+
return v;
67+
}
6668
}
6769
return null;
6870
}

0 commit comments

Comments
 (0)