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

Revert runtime/util

This commit is contained in:
HirokiUchikawa 2018-05-09 19:19:37 +09:00
parent 0be9c88106
commit e30f8628db
2 changed files with 6 additions and 4 deletions

View File

@ -240,7 +240,7 @@ function getMessageProperty(msg,expr) {
var msgPropParts = normalisePropertyExpression(expr);
var m;
msgPropParts.reduce(function(obj, key) {
result = ((typeof obj !== "undefined") && (typeof obj[key] !== "undefined") ? obj[key] : undefined);
result = (typeof obj[key] !== "undefined" ? obj[key] : undefined);
return result;
}, msg);
return result;

View File

@ -153,9 +153,11 @@ describe("red/util", function() {
var v = util.getMessageProperty({a:"foo"},"msg.b");
should.not.exist(v);
});
it('should return undefined if property parent does not exist', function() {
var v = util.getMessageProperty({a:"foo"},"msg.a.b.c");
should.not.exist(v);
it('should throw error if property parent does not exist', function() {
/*jshint immed: false */
(function() {
util.getMessageProperty({a:"foo"},"msg.a.b.c");
}).should.throw();
});
it('retrieves a property with array syntax', function() {
var v = util.getMessageProperty({a:["foo","bar"]},"msg.a[0]");