better handling of compress function

This commit is contained in:
zefie
2025-07-23 22:59:48 -04:00
parent 6c8c840ab5
commit f786b75ab8

View File

@@ -426,7 +426,9 @@ class LZPF {
compress(uncompressed_data) {
this.clear();
if (typeof uncompressed_data === 'string') {
uncompressed_data = Buffer.from(uncompressed_data, 'utf8');
uncompressed_data = Buffer.from(uncompressed_data, 'utf-8');
} else if (!Buffer.isBuffer(uncompressed_data)) {
throw new TypeError('Input data for compress must be a Buffer or a string.');
}
const uncompressed_len = uncompressed_data.length;