Comparing version 3.3.1 to 3.3.2
@@ -58,3 +58,10 @@ /* jshint node: true */ | ||
opts = opts || {}; | ||
opts.reader = opts.reader || createReader(); | ||
// TODO: Remove this legacy hook name in next major release. (It also wasn't | ||
// as flexible since it didn't expose the import kind.) | ||
/* istanbul ignore next */ | ||
if (opts.reader) { | ||
opts.importHook = wrapReader(opts.reader); | ||
} else { | ||
opts.importHook = opts.importHook || createImportHook(); | ||
} | ||
@@ -66,3 +73,3 @@ var attrs = {types: [], messages: {}}; // Final result. | ||
opts.reader(path.resolve(fpath), function (err, str) { | ||
opts.importHook(path.resolve(fpath), 'idl', function (err, str) { | ||
if (err) { | ||
@@ -108,4 +115,4 @@ cb(err); | ||
// attributes for named type declarations, they are all top level). | ||
if (importAttrs.namespace) { | ||
typeAttrs.namespace = typeAttrs.namespace || importAttrs.namespace; | ||
if (importAttrs.namespace && typeAttrs.namespace === undefined) { | ||
typeAttrs.namespace = importAttrs.namespace; | ||
} | ||
@@ -137,3 +144,3 @@ importedTypes.push(typeAttrs); | ||
// We are importing a protocol or schema file. | ||
opts.reader(info.path, function (err, str) { | ||
opts.importHook(info.path, info.kind, function (err, str) { | ||
if (err) { | ||
@@ -385,5 +392,5 @@ cb(err); | ||
*/ | ||
function createReader() { | ||
function createImportHook() { | ||
var imports = {}; | ||
return function (fpath, cb) { | ||
return function (fpath, kind, cb) { | ||
if (imports[fpath]) { | ||
@@ -400,2 +407,10 @@ // Already imported, return nothing to avoid duplicating attributes. | ||
/** | ||
* Legacy import hook. | ||
* | ||
*/ | ||
/* istanbul ignore next */ var wrapReader = util.deprecate(function (reader) { | ||
return function (fpath, kind, cb) { reader(fpath, cb); }; | ||
}, '`reader` option is deprecated please use `importHook` instead'); | ||
/** | ||
* Simple class to split an input string into tokens. | ||
@@ -402,0 +417,0 @@ * |
{ | ||
"name": "avsc", | ||
"version": "3.3.1", | ||
"version": "3.3.2", | ||
"description": "Avro for JavaScript", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/mtth/avsc", |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
161361
5251