"use strict"; const bytesCoder = require("./bytes"); module.exports = { encode: function (value, asIndexKey) { if (asIndexKey) { throw new Error(`Not implemented yet`); } else { let binaryValue = Buffer.from(value, "utf8"); return bytesCoder.encode(binaryValue); } }, decode: function (buffer, offset) { let result = bytesCoder.decode(buffer, offset); if (result.auxiliaryBlob === undefined) { // Internal blob return { bytesRead: result.bytesRead, value: result.value.toString("utf8"), auxiliaryBlob: undefined }; } else { // External blob return { bytesRead: result.bytesRead, value: undefined, auxiliaryBlob: { key: result.auxiliaryBlob.key, transform: (blob) => result.auxiliaryBlob.transform(blob).toString("utf8") } }; } } };