mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
parent
62fc554d25
commit
0f1ca1c7cf
33
packages/node_modules/@node-red/util/lib/util.js
vendored
33
packages/node_modules/@node-red/util/lib/util.js
vendored
@ -81,22 +81,25 @@ function ensureBuffer(o) {
|
|||||||
* @memberof @node-red/util_util
|
* @memberof @node-red/util_util
|
||||||
*/
|
*/
|
||||||
function cloneMessage(msg) {
|
function cloneMessage(msg) {
|
||||||
// Temporary fix for #97
|
if (typeof msg !== "undefined") {
|
||||||
// TODO: remove this http-node-specific fix somehow
|
// Temporary fix for #97
|
||||||
var req = msg.req;
|
// TODO: remove this http-node-specific fix somehow
|
||||||
var res = msg.res;
|
var req = msg.req;
|
||||||
delete msg.req;
|
var res = msg.res;
|
||||||
delete msg.res;
|
delete msg.req;
|
||||||
var m = clone(msg);
|
delete msg.res;
|
||||||
if (req) {
|
var m = clone(msg);
|
||||||
m.req = req;
|
if (req) {
|
||||||
msg.req = req;
|
m.req = req;
|
||||||
|
msg.req = req;
|
||||||
|
}
|
||||||
|
if (res) {
|
||||||
|
m.res = res;
|
||||||
|
msg.res = res;
|
||||||
|
}
|
||||||
|
return m;
|
||||||
}
|
}
|
||||||
if (res) {
|
return msg;
|
||||||
m.res = res;
|
|
||||||
msg.res = res;
|
|
||||||
}
|
|
||||||
return m;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -143,6 +143,10 @@ describe("@node-red/util/util", function() {
|
|||||||
cloned.req.should.equal(msg.req);
|
cloned.req.should.equal(msg.req);
|
||||||
cloned.res.should.equal(msg.res);
|
cloned.res.should.equal(msg.res);
|
||||||
});
|
});
|
||||||
|
it('handles undefined values without throwing an error', function() {
|
||||||
|
var result = util.cloneMessage(undefined);
|
||||||
|
should.not.exist(result);
|
||||||
|
})
|
||||||
});
|
});
|
||||||
describe('getObjectProperty', function() {
|
describe('getObjectProperty', function() {
|
||||||
it('gets a property beginning with "msg."', function() {
|
it('gets a property beginning with "msg."', function() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user