From 5db11655adf06b24b70d304840480962996f1b3a Mon Sep 17 00:00:00 2001 From: Bill Min Date: Tue, 8 Oct 2024 23:00:04 -0400 Subject: [PATCH] Omit util imports (#486) This allows the package to be used in the browser without a bundler. --- etc/browser/lib/platform.js | 10 ---------- lib/platform.js | 2 -- lib/types.js | 7 +------ 3 files changed, 1 insertion(+), 18 deletions(-) diff --git a/etc/browser/lib/platform.js b/etc/browser/lib/platform.js index 64c9d388..12c7dacf 100644 --- a/etc/browser/lib/platform.js +++ b/etc/browser/lib/platform.js @@ -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 }; diff --git a/lib/platform.js b/lib/platform.js index d94ec18c..b9294f86 100644 --- a/lib/platform.js +++ b/lib/platform.js @@ -1,5 +1,4 @@ let crypto = require('crypto'); -let util = require('util'); /** * Compute a string's hash. @@ -17,5 +16,4 @@ function getHash(str, algorithm) { module.exports = { getHash, - debuglog: util.debuglog }; diff --git a/lib/types.js b/lib/types.js index 1e15acfc..ee17b5ef 100644 --- a/lib/types.js +++ b/lib/types.js @@ -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. @@ -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 @@ -449,7 +445,6 @@ class Type { } static __reset (size) { - debug('resetting type buffer to %d', size); TAP.reinitialize(size); }