dashboardjavacloudcoapiotiot-analyticsiot-platformiot-solutionskafkalwm2mmicroservicesmiddlewaremqttnettyplatformsnmpthingsboardvisualizationwebsocketswidgets
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
646 B
27 lines
646 B
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.default = toJSON;
|
|
|
|
function toJSON(value, arg, ctx) {
|
|
if (Array.isArray(value)) return value.map(function (v, i) {
|
|
return toJSON(v, String(i), ctx);
|
|
});
|
|
|
|
if (value && typeof value.toJSON === 'function') {
|
|
var anchor = ctx && ctx.anchors && ctx.anchors.find(function (a) {
|
|
return a.node === value;
|
|
});
|
|
if (anchor) ctx.onCreate = function (res) {
|
|
anchor.res = res;
|
|
delete ctx.onCreate;
|
|
};
|
|
var res = value.toJSON(arg, ctx);
|
|
if (anchor && ctx.onCreate) ctx.onCreate(res);
|
|
return res;
|
|
}
|
|
|
|
return value;
|
|
}
|