Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Monster
Manage
Activity
Members
Plan
Jira
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OSS
Libraries
Javascript
Monster
Commits
fcf49ded
Verified
Commit
fcf49ded
authored
2 years ago
by
Volker Schukai
Browse files
Options
Downloads
Patches
Plain Diff
feat: new equal command
parent
1d9171b4
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
application/source/data/transformer.mjs
+64
-26
64 additions, 26 deletions
application/source/data/transformer.mjs
development/test/cases/data/transformer.mjs
+20
-0
20 additions, 0 deletions
development/test/cases/data/transformer.mjs
with
84 additions
and
26 deletions
application/source/data/transformer.mjs
+
64
−
26
View file @
fcf49ded
...
@@ -576,6 +576,44 @@ function transform(value) {
...
@@ -576,6 +576,44 @@ function transform(value) {
return
map
.
get
(
value
);
return
map
.
get
(
value
);
case
"
equals
"
:
if
(
args
.
length
===
0
)
{
throw
new
Error
(
"
missing value parameter
"
);
}
validatePrimitive
(
value
);
const
equalsValue
=
args
.
shift
();
/**
* The history of “typeof null”
* https://2ality.com/2013/10/typeof-null.html
* In JavaScript, typeof null is 'object', which incorrectly suggests
* that null is an object.
*/
if
(
value
===
null
)
{
if
(
equalsValue
===
"
null
"
)
{
return
true
;
}
return
false
;
}
const
typeOfValue
=
typeof
value
;
switch
(
typeOfValue
)
{
case
"
string
"
:
return
value
===
equalsValue
;
case
"
number
"
:
return
value
===
parseFloat
(
equalsValue
);
case
"
boolean
"
:
return
value
===
(
equalsValue
===
"
true
"
||
equalsValue
===
"
on
"
);
case
"
undefined
"
:
return
equalsValue
===
"
undefined
"
;
default
:
throw
new
Error
(
"
type not supported
"
);
}
case
"
money
"
:
case
"
money
"
:
case
"
currency
"
:
case
"
currency
"
:
...
...
This diff is collapsed.
Click to expand it.
development/test/cases/data/transformer.mjs
+
20
−
0
View file @
fcf49ded
...
@@ -28,6 +28,26 @@ describe('Transformer', function () {
...
@@ -28,6 +28,26 @@ describe('Transformer', function () {
describe
(
'
Transformer.run()
'
,
function
()
{
describe
(
'
Transformer.run()
'
,
function
()
{
[
[
[
'
equals:a
'
,
"
a
"
,
true
],
[
'
equals:a
'
,
"
b
"
,
false
],
[
'
equals:3
'
,
3
,
true
],
[
'
equals:3
'
,
6
,
false
],
[
'
equals:on
'
,
true
,
true
],
[
'
equals:true
'
,
true
,
true
],
[
'
equals:on
'
,
false
,
false
],
[
'
equals:true
'
,
false
,
false
],
[
'
equals:off
'
,
false
,
true
],
[
'
equals:false
'
,
false
,
true
],
[
'
equals:off
'
,
false
,
true
],
[
'
equals:false
'
,
true
,
false
],
[
'
equals:3
'
,
3
,
true
],
[
'
equals:3
'
,
6
,
false
],
[
'
equals:undefined
'
,
undefined
,
true
],
[
'
equals:undefined
'
,
3
,
false
],
[
'
equals:null
'
,
null
,
true
],
[
'
equals:null
'
,
3
,
false
],
[
'
equals:3
'
,
6
,
false
],
[
'
currency
'
,
"
EUR0
"
,
"
0,00 €
"
],
[
'
currency:1:2
'
,
"
EUR14.25
"
,
"
14,2 €
"
],
[
'
currency:1:2
'
,
"
EUR14.25
"
,
"
14,2 €
"
],
[
'
currency
'
,
"
EUR14.25
"
,
"
14,25 €
"
],
[
'
currency
'
,
"
EUR14.25
"
,
"
14,25 €
"
],
[
'
datetime
'
,
"
2023-02-14 14:12:10
"
,
"
14.2.2023, 14:12:10
"
],
[
'
datetime
'
,
"
2023-02-14 14:12:10
"
,
"
14.2.2023, 14:12:10
"
],
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment