'use strict'; const iconvLite = require("iconv-lite"); let encodingMap = { "ascii": "ascii", /* The following are strictly not the same thing, but there's backwards compatibility. */ "ucs2-level1": "utf16-be", "ucs2-level2": "utf16-be", "ucs2-level3": "utf16-be" } module.exports = function decode(buffer, encoding) { if (encodingMap[encoding] == null) { throw new Error(`No such encoding: ${encoding}`); } return iconvLite.decode(buffer, encodingMap[encoding]); };