Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function CardTypes (types) {
var map = types.reduce(function (acc, type) {
acc[type.name] = type
return acc
}, {})
return {
find: find.bind(null, types),
some: types.some.bind(types),
get: get
}
function get (name) {
var type = map[name]
if (!type) {
throw new Error('No type found for name: ' + name)
}
return type
}
}