lix-website/themes/lix/assets/bootstrap/node_modules/zwitch/index.js

29 lines
586 B
JavaScript
Raw Normal View History

2024-04-27 03:39:10 +00:00
'use strict'
module.exports = factory
var noop = Function.prototype
var own = {}.hasOwnProperty
// Handle values based on a property.
function factory(key, options) {
var settings = options || {}
function one(value) {
var fn = one.invalid
var handlers = one.handlers
if (value && own.call(value, key)) {
fn = own.call(handlers, value[key]) ? handlers[value[key]] : one.unknown
}
return (fn || noop).apply(this, arguments)
}
one.handlers = settings.handlers || {}
one.invalid = settings.invalid
one.unknown = settings.unknown
return one
}