Skip to content

Commit d2e9abe

Browse files
committed
chore: Apply suggestion from code review
1 parent 2d5b3b7 commit d2e9abe

2 files changed

Lines changed: 4 additions & 5 deletions

File tree

src/js/binaryen.js-post.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2776,12 +2776,11 @@ function wrapModule(module, self = {}) {
27762776
* Gets the memory segment with the given name.
27772777
*
27782778
* @param {string} name - The name of the memory segment to get.
2779-
* @returns {number} A MemorySegmentRef referring to the memory segment with the given name, or `null` if no such segment exists.
2779+
* @returns {number} A MemorySegmentRef referring to the memory segment with the given name, or `0` if no such segment exists.
27802780
*/
27812781
self['getMemorySegment'] = function(name) {
27822782
return preserveStack(() => {
2783-
const segment = Module['_BinaryenGetMemorySegment'](module, strToStack(name));
2784-
return segment === 0 ? null : segment;
2783+
return Module['_BinaryenGetMemorySegment'](module, strToStack(name));
27852784
});
27862785
};
27872786
/**

test/binaryen.js/kitchen-sink.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,8 +1144,8 @@ function test_for_each() {
11441144
data: expected_data[2].split('').map(function(x) { return x.charCodeAt(0) })
11451145
}
11461146
], false);
1147-
assert(module.getMemorySegment(expected_names[0]) !== null);
1148-
assert(module.getMemorySegment("NonExistantSegment") === null);
1147+
assert(module.getMemorySegment(expected_names[0]) !== 0);
1148+
assert(module.getMemorySegment("NonExistantSegment") === 0);
11491149
for (i = 0; i < module.getNumMemorySegments(); i++) {
11501150
var segment = module.getMemorySegmentByIndex(i);
11511151
var info = module.getMemorySegmentInfo(segment);

0 commit comments

Comments
 (0)