Skip to content

Commit d858646

Browse files
Added getMapType and getListType fixes
Added type checking for valueType parameter Modified error messages Ran npm lint
1 parent e0e2392 commit d858646

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

lib/exp_lists.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ const _rtype = _valueExp(exp.ops.VAL_RTYPE, 'intVal')
2626
*********************************************************************************/
2727

2828
function getListType (type, returnType, isMulti) {
29+
if (!Object.values(exp.type).includes(type)) {
30+
throw new TypeError('invalid value for valueType parameter')
31+
}
32+
2933
let expected = type
3034

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

5155
if (type === exp.type.AUTO || type === expected) {

lib/exp_maps.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ const _rtype = _valueExp(exp.ops.VAL_RTYPE, 'intVal')
1111
*********************************************************************************/
1212

1313
function getMapType (type, returnType, isMulti) {
14+
if (!Object.values(exp.type).includes(type)) {
15+
throw new TypeError('invalid value for valueType parameter')
16+
}
17+
1418
let expected = type
1519

1620
switch (returnType & ~maps.returnType.INVERTED) {
@@ -32,11 +36,11 @@ function getMapType (type, returnType, isMulti) {
3236
case maps.returnType.KEY_VALUE:
3337
case maps.returnType.ORDERED_MAP:
3438
case maps.returnType.UNORDERED_MAP:
35-
expected = exp.type.MAP
39+
expected = exp.type.MAP
3640
break
3741
case maps.returnType.NONE:
3842
default:
39-
throw new TypeError('either set the value type as auto or match with return object data type')
43+
throw new TypeError('either set the return type as auto or match with return object data type')
4044
}
4145

4246
if (type === exp.type.AUTO || type === expected) {

0 commit comments

Comments
 (0)