UNPKG

xiot-core-spec-ts

Version:
45 lines (44 loc) 1.32 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ArgumentImageCodec = void 0; const Spec_1 = require("../../typedef/constant/Spec"); const ArgumentImage_1 = require("../../typedef/image/ArgumentImage"); class ArgumentImageCodec { static decodeArray(list) { const array = []; if (list != null) { list.forEach(o => { const a = ArgumentImageCodec.decode(o); if (a != null) { array.push(a); } }); } return array; } static decode(o) { if (typeof o === 'number') { return new ArgumentImage_1.ArgumentImage(o); } const piid = o[Spec_1.Spec.PIID]; const def = new ArgumentImage_1.ArgumentImage(piid); const repeat = o[Spec_1.Spec.REPEAT]; if (repeat != null) { def.minRepeat = repeat[0]; def.maxRepeat = repeat[1]; } return def; } static encode(def) { return { piid: def.piid, repeat: [def.minRepeat, def.maxRepeat] }; } static encodeArray(list) { return list.map(x => { return ArgumentImageCodec.encode(x); }); } } exports.ArgumentImageCodec = ArgumentImageCodec;