-
Notifications
You must be signed in to change notification settings - Fork 6
Conversation
AndyOGo
commented
Feb 21, 2019
•
edited
Loading
edited
- Rewrite to ES6
- add Babel 7
- add rollup
- update QUnit
- add prettier, eslint, commit hook
d2dadc1
to
ee9fa49
Compare
ee9fa49
to
e6e627f
Compare
bbe1d8a
to
e68d842
Compare
c5b26ed
to
859945b
Compare
04edfe0
to
f68c165
Compare
@@ -1,25 +1,61 @@ | |||
{ | |||
"name": "json-logic-js", | |||
"name": "@axa-ch/json-logic-js", | |||
"version": "1.2.2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would bump the version to 2.0.0
🤔
@mjenny |
return are_missing; | ||
} | ||
|
||
missing.withApply = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lina-salih
@mjenny
I don't like this hacks of meta data like withApply
and code
...
The reason I have them is, that some operations need to call apply
recursively, and others have names within the API like ==
which is not a valid JavaScript function or variable name., so:
withApply
: adds theapply
function as a callback as the first argumentcode
: overrides the functions key within theoperations
object, e.g.equal()
function gets overridden by it'scode
property being==
This is too complex and error prone 💣
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you plan on changing this at some point?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it sit's on my nerves^^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Go for it. 💯
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh.... do you want to change this in the current PR or open an issue? 😖
} | ||
|
||
missingSome.code = 'missing_some'; | ||
missingSome.withApply = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lina-salih @mjenny
Same here code
, withApply
as described in https://github.com/axa-ch/json-logic-js/pull/1/files#r259730014
return data; | ||
} | ||
|
||
variable.code = 'var'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lina-salih @mjenny
Same here code
as described in https://github.com/axa-ch/json-logic-js/pull/1/files#r259730014
var
is a reserved keyword and can't be used as function name
}, 0); | ||
} | ||
|
||
add.code = '+'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lina-salih @mjenny
Same here code
as described in https://github.com/axa-ch/json-logic-js/pull/1/files#r259730014
+
is an existing operator
return a / b; | ||
} | ||
|
||
divide.code = '/'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here code
as described in https://github.com/axa-ch/json-logic-js/pull/1/files#r259730014
/
is an existing operator
return a % b; | ||
} | ||
|
||
modulo.code = '%'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here code
as described in https://github.com/axa-ch/json-logic-js/pull/1/files#r259730014
%
is an existing operator
return a - b; | ||
} | ||
|
||
substract.code = '-'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here code
as described in https://github.com/axa-ch/json-logic-js/pull/1/files#r259730014
-
is an existing operator
return a == b; | ||
} | ||
|
||
equal.code = '=='; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here code
as described in https://github.com/axa-ch/json-logic-js/pull/1/files#r259730014
==
is an existing operator
return !truthy(a); | ||
} | ||
|
||
falsy.code = '!'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here code
as described in https://github.com/axa-ch/json-logic-js/pull/1/files#r259730014
!
is an existing operator
return a != b; | ||
} | ||
|
||
notEqual.code = '!='; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here code
as described in https://github.com/axa-ch/json-logic-js/pull/1/files#r259730014
!=
is an existing operator
return a === b; | ||
} | ||
|
||
strictEqual.code = '==='; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here code
as described in https://github.com/axa-ch/json-logic-js/pull/1/files#r259730014
===
is an existing operator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes 👍
return a !== b; | ||
} | ||
|
||
strictNotEqual.code = '!=='; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here code
as described in https://github.com/axa-ch/json-logic-js/pull/1/files#r259730014
!==
is an existing operator
@@ -0,0 +1,3 @@ | |||
import truthy from '../../helpers/truthy'; | |||
truthy.code = '!!'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here code
as described in https://github.com/axa-ch/json-logic-js/pull/1/files#r259730014
!
is an existing operator
return b.indexOf(a) !== -1; | ||
} | ||
|
||
indexOf.code = 'in'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here code
as described in https://github.com/axa-ch/json-logic-js/pull/1/files#r259730014
in
is an existing operator
return a > b; | ||
} | ||
|
||
greater.code = '>'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here code
as described in https://github.com/axa-ch/json-logic-js/pull/1/files#r259730014
>
is an existing operator
return a >= b; | ||
} | ||
|
||
greaterEqual.code = '>='; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here code
as described in https://github.com/axa-ch/json-logic-js/pull/1/files#r259730014
>=
is an existing operator
return c === undefined ? a < b : a < b && b < c; | ||
} | ||
|
||
lower.code = '<'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here code
as described in https://github.com/axa-ch/json-logic-js/pull/1/files#r259730014
<
is an existing operator
return c === undefined ? a <= b : a <= b && b <= c; | ||
} | ||
|
||
lowerEqual.code = '<='; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here code
as described in https://github.com/axa-ch/json-logic-js/pull/1/files#r259730014
<=
is an existing operator
return null; | ||
} | ||
|
||
condition.code = ['if', '?:']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here code
as described in https://github.com/axa-ch/json-logic-js/pull/1/files#r259730014
/if
is an existing operator and ?:
not a valid variable name and it's and array...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than https://github.com/axa-ch/json-logic-js/pull/1/files#r259730014 this LGTM
return are_missing; | ||
} | ||
|
||
missing.withApply = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you plan on changing this at some point?
Awesome PR, using once again up-to-date components 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job! thank you @AndyOGo 😄
@@ -0,0 +1,12 @@ | |||
function add() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need arithmetic operations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would kick them
return a === b; | ||
} | ||
|
||
strictEqual.code = '==='; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes 👍
}; | ||
} | ||
|
||
export default createJsonLogic; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
awesome
const not_found = b === undefined ? null : b; | ||
let data = this; | ||
|
||
if (typeof a === 'undefined' || a === '' || a === null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we export this as a function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure as a helper