@nethesis/phone-island
Version:
NethVoice CTI Phone Island
3 lines (2 loc) • 1.05 kB
JavaScript
;Object.defineProperty(exports,"__esModule",{value:!0});var t=require("./is-binary.js");function e(r,n){if(!r)return r;if(t.isBinary(r)){const t={_placeholder:!0,num:n.length};return n.push(r),t}if(Array.isArray(r)){const t=new Array(r.length);for(let o=0;o<r.length;o++)t[o]=e(r[o],n);return t}if("object"==typeof r&&!(r instanceof Date)){const t={};for(const o in r)Object.prototype.hasOwnProperty.call(r,o)&&(t[o]=e(r[o],n));return t}return r}function r(t,e){if(!t)return t;if(t&&!0===t._placeholder){if("number"==typeof t.num&&t.num>=0&&t.num<e.length)return e[t.num];throw new Error("illegal attachments")}if(Array.isArray(t))for(let n=0;n<t.length;n++)t[n]=r(t[n],e);else if("object"==typeof t)for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(t[n]=r(t[n],e));return t}exports.deconstructPacket=function(t){const r=[],n=t.data,o=t;return o.data=e(n,r),o.attachments=r.length,{packet:o,buffers:r}},exports.reconstructPacket=function(t,e){return t.data=r(t.data,e),delete t.attachments,t};
//# sourceMappingURL=binary.js.map