Files
coopgo/node_modules/rw/lib/rw/decode.js
sgauthier 6e64e138e2
All checks were successful
Publish To Prod / deploy_and_publish (push) Successful in 35s
planning
2024-10-14 09:15:30 +02:00

24 lines
576 B
JavaScript

module.exports = function(options) {
if (options) {
if (typeof options === "string") return encoding(options);
if (options.encoding !== null) return encoding(options.encoding);
}
return identity();
};
function identity() {
var chunks = [];
return {
push: function(chunk) { chunks.push(chunk); },
value: function() { return Buffer.concat(chunks); }
};
}
function encoding(encoding) {
var chunks = [];
return {
push: function(chunk) { chunks.push(chunk); },
value: function() { return Buffer.concat(chunks).toString(encoding); }
};
}