Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
c.render = (h, params) => {
// 使用当前作用域
let _this = this;
let originKey = c.key;
// 获取原始值
if (c.key.endsWith('_format')) {
originKey = c.key.substr(0, c.key.length - 7);
}
let value = this.tableFieldFormat(c, h, params);
let originValue = params['row'][originKey] || '';
let tmp = [...originValue];
if (c.renderType === 'tooltip') {
// 如果存在内容格式化回调,则允许自定义格式内容
if (util.isFunction(c.contentFormat)) {
let a = c.contentFormat(originValue, params['row']);
tmp = [...a];
}
let i = 0;
let str = [];
let tmpStr = [];
for (let t of tmp) {
tmpStr.push(t);
if (i > 15) {
i = 0;
str.push(h('p', tmpStr.join('')));
tmpStr = [];
}
i++;
}
str.push(h('p', tmpStr.join('')));
if (state.decoder)
chunk = state.decoder.write(chunk);
if (!chunk || !state.objectMode && !chunk.length)
return;
var ret = self.push(chunk);
if (!ret) {
paused = true;
stream.pause();
}
});
// proxy all the other methods.
// important when wrapping filters and duplexes.
for (var i in stream) {
if (util.isFunction(stream[i]) && util.isUndefined(this[i])) {
this[i] = function(method) { return function() {
return stream[method].apply(stream, arguments);
}}(i);
}
}
// proxy certain important events.
var events = ['error', 'close', 'destroy', 'pause', 'resume'];
forEach(events, function(ev) {
stream.on(ev, self.emit.bind(self, ev));
});
// when we try to consume some more bytes, simply unpause the
// underlying stream.
self._read = function(n) {
debug('wrapped _read', n);
function stringify (key, holder, gap) {
let value = holder[key]
// If the value has a toJSON method, call it to obtain a replacement value.
if (isObject(value) && isFunction(value.toJSON)) {
value = value.toJSON(key)
}
// If we were called with a replacer function, then call the replacer to
// obtain a replacement value.
if (isFunction(replacer)) {
value = replacer.call(holder, key, value)
}
switch (typeof value) {
case 'string':
return quote(value)
case 'number':
// JSON numbers must be finite. Encode non-finite numbers as null.
return Number.isFinite(value) ? String(value) : STR_NULL
case 'boolean':
case 'null':
// If the value is a boolean or null, convert it to a string. Note:
// typeof null does not produce 'null'. The case is included here in
this.once('prefinish', function() {
if (util.isFunction(this._flush))
this._flush(function(er) {
done(stream, er);
});
else
done(stream);
});
}
function resolve(basedir, pathname, method) {
var handler;
try {
//If the pathname is already a resolved function, return it.
//In the case of x-handler and x-authorize, users can define
//external handler/authorize modules and functions OR override
//existing x-authorize functions.
if (thing.isFunction(pathname)) {
return pathname;
}
pathname = path.resolve(basedir, pathname);
handler = require(pathname);
if (thing.isFunction(handler)) {
return handler;
}
return method && handler[method];
}
catch (error) {
utils.debuglog('Could not find %s.', pathname);
return;
}
Writable.prototype.write = function(chunk, encoding, cb) {
var state = this._writableState;
var ret = false;
if (util.isFunction(encoding)) {
cb = encoding;
encoding = null;
}
if (util.isBuffer(chunk))
encoding = 'buffer';
else if (!encoding)
encoding = state.defaultEncoding;
if (!util.isFunction(cb))
cb = function() {};
if (state.ended)
writeAfterEnd(this, state, cb);
else if (validChunk(this, state, chunk, cb)) {
state.pendingcb++;
ret = writeOrBuffer(this, state, chunk, encoding, cb);
}
return ret;
};
Writable.prototype.write = function(chunk, encoding, cb) {
var state = this._writableState;
var ret = false;
if (util.isFunction(encoding)) {
cb = encoding;
encoding = null;
}
if (util.isBuffer(chunk))
encoding = 'buffer';
else if (!encoding)
encoding = state.defaultEncoding;
if (!util.isFunction(cb))
cb = function() {};
if (state.ended)
writeAfterEnd(this, state, cb);
else if (validChunk(this, state, chunk, cb)) {
state.pendingcb++;