Skip to content

Commit

Permalink
Add other missing type options
Browse files Browse the repository at this point in the history
  • Loading branch information
mtth committed Apr 26, 2019
1 parent 538dd64 commit d4e62f3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/types.js
Expand Up @@ -398,7 +398,7 @@ Type.forTypes = function (types, opts) {
type: 'array',
items: Type.forTypes(bucketTypes.map(function (t) {
return t.itemsType;
}))
}), opts)
}, opts);
default:
return combineObjects(bucketTypes, opts);
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "avsc",
"version": "5.4.9",
"version": "5.4.10",
"description": "Avro for JavaScript",
"homepage": "https://github.com/mtth/avsc",
"keywords": [
Expand Down
15 changes: 15 additions & 0 deletions test/test_types.js
Expand Up @@ -3985,6 +3985,21 @@ suite('types', function () {
}
});

test('type hook nested array', function () {
var i = 1;
var outer = infer([[{foo: 2}], [{foo: 3}]], {typeHook: hook});
var inner = outer.itemsType.itemsType;
assert.equal(inner.name, 'Foo3');
assert.equal(inner.field('foo').type.typeName, 'int');

function hook(schema) {
if (schema.type !== 'record') {
return;
}
schema.name = 'Foo' + (i++);
}
});

});

});
Expand Down

0 comments on commit d4e62f3

Please sign in to comment.