Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: process is not defined in browser env #486

Merged
merged 3 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions etc/browser/lib/platform.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,7 @@ function deprecate (fn) {
return fn;
}

/**
* Browser stub for debuglog(). Never does any logging.
* @returns A function that can be called with log messages. Does nothing with
* those messages.
*/
function debuglog () {
return () => {};
}

module.exports = {
getHash,
deprecate,
debuglog
};
2 changes: 0 additions & 2 deletions lib/platform.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
let crypto = require('crypto');
let util = require('util');

/**
* Compute a string's hash.
Expand All @@ -17,5 +16,4 @@ function getHash(str, algorithm) {

module.exports = {
getHash,
debuglog: util.debuglog
};
8 changes: 2 additions & 6 deletions lib/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@
*
*/

let utils = require('./utils'),
platform = require('./platform');
let utils = require('./utils');

// Convenience imports.
let {Tap, isBufferLike} = utils;
let debug = platform.debuglog('avsc:types');
let j = utils.printJSON;

// All non-union concrete (i.e. non-logical) Avro types.
Expand Down Expand Up @@ -172,10 +170,9 @@ class Type {
registry[key] = opts.registry[key];
});
try {
debug('instantiating logical type for %s', schema.logicalType);
return new DerivedType(schema, opts);
} catch (err) {
debug('failed to instantiate logical type for %s', schema.logicalType);
console.error('failed to instantiate logical type for %s', schema.logicalType);
mtth marked this conversation as resolved.
Show resolved Hide resolved
if (opts.assertLogicalTypes) {
// The spec mandates that we fall through to the underlying type if
// the logical type is invalid. We provide this option to ease
Expand Down Expand Up @@ -449,7 +446,6 @@ class Type {
}

static __reset (size) {
debug('resetting type buffer to %d', size);
TAP.reinitialize(size);
}

Expand Down