Acme.BookStore.HttpApi.Host/node_modules/value-or-function/index.js
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
'use strict';
// Built-in types
var types = [
'object',
'number',
'string',
'symbol',
'boolean',
'date',
'function', // Weird to expose this
];
function normalize(coercer, value) {
if (typeof value === 'function') {
if (coercer === 'function') {
return value;
}
value = value.apply(this, slice(arguments, 2));
}
return coerce(this, coercer, value);
}
function coerce(ctx, coercer, value) {
// Handle built-in types
if (typeof coercer === 'string') {
if (coerce[coercer]) {
return coerce[coercer].call(ctx, value);
}
return typeOf(coercer, value);
}
// Handle custom coercer
if (typeof coercer === 'function') {
return coercer.call(ctx, value);
}
// Array of coercers, try in order until one returns a non-null value
var result;
coercer.some(function(coercer) {
result = coerce(ctx, coercer, value);
return result != null;
});
return result;
}
coerce.string = function(value) {
if (value != null &&
typeof value === 'object' &&
typeof value.toString === 'function') {
value = value.toString();
}
return typeOf('string', primitive(value));
};
后面还有 53 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
