Skip to content

Commit 975832c

Browse files
committed
Test for array or object
1 parent 587b2b1 commit 975832c

File tree

3 files changed

+61
-12
lines changed

3 files changed

+61
-12
lines changed

dist/easycoder-min.js

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/easycoder.js

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3003,8 +3003,7 @@ const EasyCoder_Core = {
30033003
value1
30043004
};
30053005
case `greater`:
3006-
compiler.next();
3007-
if (compiler.tokenIs(`than`)) {
3006+
if (compiler.nextTokenIs(`than`)) {
30083007
compiler.next();
30093008
const value2 = compiler.getValue();
30103009
return {
@@ -3017,8 +3016,7 @@ const EasyCoder_Core = {
30173016
}
30183017
return null;
30193018
case `less`:
3020-
compiler.next();
3021-
if (compiler.tokenIs(`than`)) {
3019+
if (compiler.nextTokenIs(`than`)) {
30223020
compiler.next();
30233021
const value2 = compiler.getValue();
30243022
return {
@@ -3030,6 +3028,26 @@ const EasyCoder_Core = {
30303028
};
30313029
}
30323030
return null;
3031+
case `an`:
3032+
switch (compiler.nextToken()) {
3033+
case `array`:
3034+
compiler.next();
3035+
return {
3036+
domain: `core`,
3037+
type: `array`,
3038+
value1
3039+
};
3040+
break;
3041+
case `object`:
3042+
compiler.next();
3043+
return {
3044+
domain: `core`,
3045+
type: `object`,
3046+
value1
3047+
};
3048+
break;
3049+
}
3050+
return null;
30333051
default:
30343052
const value2 = compiler.getValue();
30353053
return {
@@ -3077,6 +3095,12 @@ const EasyCoder_Core = {
30773095
case `less`:
30783096
comparison = program.compare(program, condition.value1, condition.value2);
30793097
return condition.negate ? comparison >= 0 : comparison < 0;
3098+
case `array`:
3099+
test = Array.isArray(condition.value1);
3100+
return condition.negate ? !test : test;
3101+
case `object`:
3102+
test = typeof condition.value1 === `object`;
3103+
return condition.negate ? !test : test;
30803104
case `not`:
30813105
return !program.getValue(condition.value);
30823106
case `moduleRunning`:

js/easycoder/Core.js

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3003,8 +3003,7 @@ const EasyCoder_Core = {
30033003
value1
30043004
};
30053005
case `greater`:
3006-
compiler.next();
3007-
if (compiler.tokenIs(`than`)) {
3006+
if (compiler.nextTokenIs(`than`)) {
30083007
compiler.next();
30093008
const value2 = compiler.getValue();
30103009
return {
@@ -3017,8 +3016,7 @@ const EasyCoder_Core = {
30173016
}
30183017
return null;
30193018
case `less`:
3020-
compiler.next();
3021-
if (compiler.tokenIs(`than`)) {
3019+
if (compiler.nextTokenIs(`than`)) {
30223020
compiler.next();
30233021
const value2 = compiler.getValue();
30243022
return {
@@ -3030,6 +3028,26 @@ const EasyCoder_Core = {
30303028
};
30313029
}
30323030
return null;
3031+
case `an`:
3032+
switch (compiler.nextToken()) {
3033+
case `array`:
3034+
compiler.next();
3035+
return {
3036+
domain: `core`,
3037+
type: `array`,
3038+
value1
3039+
};
3040+
break;
3041+
case `object`:
3042+
compiler.next();
3043+
return {
3044+
domain: `core`,
3045+
type: `object`,
3046+
value1
3047+
};
3048+
break;
3049+
}
3050+
return null;
30333051
default:
30343052
const value2 = compiler.getValue();
30353053
return {
@@ -3077,6 +3095,12 @@ const EasyCoder_Core = {
30773095
case `less`:
30783096
comparison = program.compare(program, condition.value1, condition.value2);
30793097
return condition.negate ? comparison >= 0 : comparison < 0;
3098+
case `array`:
3099+
test = Array.isArray(condition.value1);
3100+
return condition.negate ? !test : test;
3101+
case `object`:
3102+
test = typeof condition.value1 === `object`;
3103+
return condition.negate ? !test : test;
30803104
case `not`:
30813105
return !program.getValue(condition.value);
30823106
case `moduleRunning`:

0 commit comments

Comments
 (0)