Skip to content

Commit

Permalink
Omit util imports (#486)
Browse files Browse the repository at this point in the history
This allows the package to be used in the browser without
a bundler.
  • Loading branch information
bill-min authored Oct 9, 2024
1 parent aeada8c commit 5db1165
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 18 deletions.
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
};
7 changes: 1 addition & 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,8 @@ 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);
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 +445,6 @@ class Type {
}

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

Expand Down

0 comments on commit 5db1165

Please sign in to comment.