Skip to content

Conversation

@msroot
Copy link

@msroot msroot commented Jan 27, 2021

String Alias support methods.
I am using Graphql and it supports only string keys in objects inputs so i am using an alias

example: equal == ==

var alias = {
	equal: "==",
	strictEqual: "===",
	notEqual: "!=",
	strictNotEqual: "!==",
	greater: ">",
	greaterOrEqual: ">=",
	less: "<",
	lessOrEqual: "<=",
	booleanCasting: "!!",
	not: "!",
	modulo: "%",
	add: "+",
	multiply: "*",
	substract: "-",
	divide: "/",
}


//Specs:		

[ {"equal":[1,1]}, {}, true ],
[ {"strictEqual":[1,1]}, {}, true ],
[ {"notEqual":[1,2]}, {}, true ],
[ {"strictNotEqual":[1,2]}, {}, true ],
[ {"greater":[2,1]}, {}, true ],
[ {"greaterOrEqual":[2,1]}, {}, true ],
[ {"less":[2,1]}, {}, false ],
[ {"lessOrEqual":[2,1]}, {}, false ],
[ {"booleanCasting" : [ "0" ]}, {}, true],
[ {"not":[false]}, {}, true ],   
[ {"modulo":[1,2]}, {}, 1 ],
[ {"add":[1,1]}, {}, 2 ],
[ {"multiply":[3,2]}, {}, 6 ],
[ {"substract":[2,3]}, {}, -1 ],   
[ {"divide":[1,1]}, {}, 1 ],

Also there is a fix for specs; https://jsonlogic.com/tests.json redirect to htttps

@josephdpurcell
Copy link

I like the idea of compatibility / support for GraphQL.

An alternative approach might be to put this as a different package? The idea would be to have some new package called something like json-logic-js-graphql, and all that lib does is do add_operation for all the aliases?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants