* Replaces every Buffer | ArrayBuffer | Blob | File in packet with a numbered placeholder. * * @param {Object} packet - socket.io event packet * @return {Object} with deconstructed packet and list of buffers * @public
(packet)
| 3101 | * @public |
| 3102 | */ |
| 3103 | function deconstructPacket(packet) { |
| 3104 | var buffers = []; |
| 3105 | var packetData = packet.data; |
| 3106 | var pack = packet; |
| 3107 | pack.data = _deconstructPacket(packetData, buffers); |
| 3108 | pack.attachments = buffers.length; // number of binary 'attachments' |
| 3109 | return { |
| 3110 | packet: pack, |
| 3111 | buffers: buffers |
| 3112 | }; |
| 3113 | } |
| 3114 | function _deconstructPacket(data, buffers) { |
| 3115 | if (!data) return data; |
| 3116 | if (isBinary(data)) { |
no test coverage detected