Browser doesn't have util

This commit is contained in:
Tony Garnock-Jones 2020-08-05 12:47:27 +02:00
parent 8d3146cf30
commit 3c059a573c
2 changed files with 7 additions and 5 deletions

View File

@ -1,6 +1,6 @@
{
"name": "preserves",
"version": "0.3.0",
"version": "0.3.1",
"description": "Experimental data serialization format",
"homepage": "https://gitlab.com/preserves/preserves",
"license": "Apache-2.0",

View File

@ -257,9 +257,11 @@ Bytes.prototype.toString = function () {
return '#"' + this.__asciify() + '"';
};
Bytes.prototype[util.inspect.custom] = function (depth, options) {
return this.toString();
};
if (util.inspect) {
Bytes.prototype[util.inspect.custom] = function (depth, options) {
return this.toString();
};
}
Bytes.prototype.__asciify = function () {
const pieces = [];
@ -356,7 +358,7 @@ Record.prototype.toString = function () {
try {
return "" + f;
} catch (e) {
return util.inspect(f);
return (util.inspect || ((f) => '<unprintable_preserves_field_value>'))(f);
}
}).join(', ') + ')';
};