UNPKG

837 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.getMappingValue = void 0;
4var tslib_1 = require("tslib");
5/**
6 * @ignore
7 * get the mapping value by attribute, if mapping value is nil, return def
8 * @param attr
9 * @param value
10 * @param def
11 * @returns get mapping value
12 */
13function getMappingValue(attr, value, def) {
14 if (!attr) {
15 return def;
16 }
17 var r;
18 // 多参数映射,阻止程序报错
19 if (attr.callback && attr.callback.length > 1) {
20 var restArgs = Array(attr.callback.length - 1).fill('');
21 r = attr.mapping.apply(attr, (0, tslib_1.__spreadArray)([value], restArgs, false)).join('');
22 }
23 else {
24 r = attr.mapping(value).join('');
25 }
26 return r || def;
27}
28exports.getMappingValue = getMappingValue;
29//# sourceMappingURL=attr.js.map
\No newline at end of file