Skip to content

Commit bf0c536

Browse files
committed
Use typeId map for handling arrays
1 parent 720bd1c commit bf0c536

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

lib/asbind-instance/bind-function.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ function normalizeArrayBufferViewTypeName(typeName) {
1717
return typeName;
1818
}
1919

20+
function getTypeId(asbindInstance, typeName) {
21+
if (typeName in asbindInstance.typeDescriptor.typeIds) {
22+
return asbindInstance.typeDescriptor.typeIds[typeName];
23+
}
24+
throw Error(`Unknown type ${JSON.stringifty(typeName)}`);
25+
}
26+
2027
function nop(asbindInstance, value, typeName) {
2128
return value;
2229
}
@@ -37,9 +44,7 @@ function getArrayBufferView(asbindInstance, value, typeName) {
3744

3845
function putArrayBuffer(asbindInstance, value, typeName) {
3946
return asbindInstance.exports.__newArray(
40-
asbindInstance.exports[
41-
`__asbind_${normalizeArrayBufferViewTypeName(typeName)}_ID`
42-
].value,
47+
getTypeId(asbindInstance, typeName),
4348
value
4449
);
4550
}

0 commit comments

Comments
 (0)