1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

change internal type to hask

This commit is contained in:
Dave Conway-Jones 2019-07-09 21:04:53 +01:00
parent 238bcb8698
commit a2dedba0ef
No known key found for this signature in database
GPG Key ID: 9E7F9C73F5168CD4
4 changed files with 11 additions and 11 deletions

View File

@ -1,4 +1,4 @@
<!-- has<!--
Copyright JS Foundation and other contributors, http://js.foundation Copyright JS Foundation and other contributors, http://js.foundation
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
@ -48,7 +48,7 @@
{v:"lte",t:"<=",kind:'V'}, {v:"lte",t:"<=",kind:'V'},
{v:"gt",t:">",kind:'V'}, {v:"gt",t:">",kind:'V'},
{v:"gte",t:">=",kind:'V'}, {v:"gte",t:">=",kind:'V'},
{v:"exists",t:"switch.rules.exists",kind:'V'}, {v:"hask",t:"switch.rules.hask",kind:'V'},
{v:"btwn",t:"switch.rules.btwn",kind:'V'}, {v:"btwn",t:"switch.rules.btwn",kind:'V'},
{v:"cont",t:"switch.rules.cont",kind:'V'}, {v:"cont",t:"switch.rules.cont",kind:'V'},
{v:"regex",t:"switch.rules.regex",kind:'V'}, {v:"regex",t:"switch.rules.regex",kind:'V'},
@ -162,7 +162,7 @@
numField.typedInput("width",(newWidth-selectWidth-70)); numField.typedInput("width",(newWidth-selectWidth-70));
} else if (type === "jsonata_exp") { } else if (type === "jsonata_exp") {
expField.typedInput("width",(newWidth-selectWidth-70)); expField.typedInput("width",(newWidth-selectWidth-70));
} else if (type === "exists") { } else if (type === "hask") {
keyField.typedInput("width",(newWidth-selectWidth-70)); keyField.typedInput("width",(newWidth-selectWidth-70));
} else if (type === "istype") { } else if (type === "istype") {
typeField.typedInput("width",(newWidth-selectWidth-70)); typeField.typedInput("width",(newWidth-selectWidth-70));
@ -253,7 +253,7 @@
numValueField.typedInput('show'); numValueField.typedInput('show');
typeValueField.typedInput('hide'); typeValueField.typedInput('hide');
valueField.typedInput('hide'); valueField.typedInput('hide');
} else if (type === "exists") { } else if (type === "hask") {
btwnValueField.typedInput('hide'); btwnValueField.typedInput('hide');
btwnValue2Field.typedInput('hide'); btwnValue2Field.typedInput('hide');
expValueField.typedInput('hide'); expValueField.typedInput('hide');
@ -314,7 +314,7 @@
} else if (rule.t === "istype") { } else if (rule.t === "istype") {
typeValueField.typedInput('value',rule.vt); typeValueField.typedInput('value',rule.vt);
typeValueField.typedInput('type',rule.vt); typeValueField.typedInput('type',rule.vt);
} else if (rule.t === "exists") { } else if (rule.t === "hask") {
keyValueField.typedInput('value',rule.v); keyValueField.typedInput('value',rule.v);
keyValueField.typedInput('type',rule.vt); keyValueField.typedInput('type',rule.vt);
}else if (rule.t === "jsonata_exp") { }else if (rule.t === "jsonata_exp") {
@ -392,7 +392,7 @@
} else if (type === "istype") { } else if (type === "istype") {
r.v = rule.find(".node-input-rule-type-value").typedInput('type'); r.v = rule.find(".node-input-rule-type-value").typedInput('type');
r.vt = rule.find(".node-input-rule-type-value").typedInput('type'); r.vt = rule.find(".node-input-rule-type-value").typedInput('type');
} else if (type === "exists") { } else if (type === "hask") {
r.v = rule.find(".node-input-rule-key-value").typedInput('value'); r.v = rule.find(".node-input-rule-key-value").typedInput('value');
r.vt = rule.find(".node-input-rule-key-value").typedInput('type'); r.vt = rule.find(".node-input-rule-key-value").typedInput('type');
} else if (type === "jsonata_exp") { } else if (type === "jsonata_exp") {

View File

@ -71,7 +71,7 @@ module.exports = function(RED) {
var index = parts.index; var index = parts.index;
return ((min <= index) && (index <= max)); return ((min <= index) && (index <= max));
}, },
'exists': function(a, b) { 'hask': function(a, b) {
if (typeof b !== "object" ) { return a.hasOwnProperty(b+""); } if (typeof b !== "object" ) { return a.hasOwnProperty(b+""); }
}, },
'jsonata_exp': function(a, b) { return (b === true); }, 'jsonata_exp': function(a, b) { return (b === true); },

View File

@ -622,7 +622,7 @@
"index":"index between", "index":"index between",
"exp":"JSONata exp", "exp":"JSONata exp",
"else":"otherwise", "else":"otherwise",
"exists":"has key" "hask":"has key"
}, },
"errors": { "errors": {
"invalid-expr": "Invalid JSONata expression: __error__", "invalid-expr": "Invalid JSONata expression: __error__",

View File

@ -255,13 +255,13 @@ describe('switch Node', function() {
}); });
it('should match if a payload has a required property', function(done) { it('should match if a payload has a required property', function(done) {
genericSwitchTest("exists", "a", true, true, {a:1}, done); genericSwitchTest("hask", "a", true, true, {a:1}, done);
}); });
it('should not match if a payload does not have a required property', function(done) { it('should not match if a payload does not have a required property', function(done) {
genericSwitchTest("exists", "a", true, false, {b:1}, done); genericSwitchTest("hask", "a", true, false, {b:1}, done);
}); });
it('should not match if the key is not a string', function(done) { it('should not match if the key is not a string', function(done) {
genericSwitchTest("exists", 1, true, false, {a:1}, done); genericSwitchTest("hask", 1, true, false, {a:1}, done);
}); });
it('should check if payload is between given values', function(done) { it('should check if payload is between given values', function(done) {