Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smalls fixes around getListType and getMapType #632

Merged
merged 5 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/exp_lists.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ const _rtype = _valueExp(exp.ops.VAL_RTYPE, 'intVal')
*********************************************************************************/

function getListType (type, returnType, isMulti) {
if (!Object.values(exp.type).includes(type)) {
throw new TypeError('invalid value for valueType parameter')
}

let expected = type

switch (returnType & ~lists.returnType.INVERTED) {
Expand All @@ -45,7 +49,7 @@ function getListType (type, returnType, isMulti) {
break
case lists.returnType.NONE:
default:
throw new TypeError('either set the value type as auto or match with return object data type')
throw new TypeError('either set the return type as auto or match with return object data type')
}

if (type === exp.type.AUTO || type === expected) {
Expand Down
8 changes: 7 additions & 1 deletion lib/exp_maps.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ const _rtype = _valueExp(exp.ops.VAL_RTYPE, 'intVal')
*********************************************************************************/

function getMapType (type, returnType, isMulti) {
if (!Object.values(exp.type).includes(type)) {
throw new TypeError('invalid value for valueType parameter')
}

let expected = type

switch (returnType & ~maps.returnType.INVERTED) {
Expand All @@ -30,11 +34,13 @@ function getMapType (type, returnType, isMulti) {
}
break
case maps.returnType.KEY_VALUE:
case maps.returnType.ORDERED_MAP:
case maps.returnType.UNORDERED_MAP:
expected = exp.type.MAP
break
case maps.returnType.NONE:
default:
throw new TypeError('either set the value type as auto or match with return object data type')
throw new TypeError('either set the return type as auto or match with return object data type')
}

if (type === exp.type.AUTO || type === expected) {
Expand Down
Loading