本文整理汇总了TypeScript中underscore.chain函数的典型用法代码示例。如果您正苦于以下问题:TypeScript chain函数的具体用法?TypeScript chain怎么用?TypeScript chain使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了chain函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: encodeURIComponent
_.each(result.Results, (v, k) => {
if (_.filter(v.Values, x => x.Hits > 0).length < 2) {
delete result.Results[k];
return;
}
v.Values = _.chain(v.Values)
.map((x) => {
var val = JSON.stringify(x.Range)
.replace(/^\"|\"$/gi, "")
.replace(/\:/gi, "\\:")
.replace(/\(/gi, "\\(")
.replace(/\)/gi, "\\)")
;
if (x.Range.indexOf(" TO ") <= 0 || x.Range.indexOf("[") !== 0) {
val = val.replace(/\ /gi, "\\ ");
}
val = encodeURIComponent(val);
x.q = k + ":" + val;
x.Range = x.Range.replace(/^\[Dx/, "").replace(/ Dx/, " ").replace(/\]$/, "").replace(/ TO /, "-")
return x;
})
.filter((x) => x.Hits > 0)
.sortBy((x) => x.Range)
.value();
});
示例2: save
save() {
_.chain(this.tnxs)
.forEach((t:Transaction) => {
this._tnxService.saveItem(t);
this._pTnxService.deleteItem(t);
});
}
示例3: function
static respondToResourceGET<T>(requestBody, res, dao: DAO<T>, whereArray: string[], likeArray: string[]) {
let whereQuery = _.omit(_.pick(requestBody, whereArray),
function (value, key, object) {
return value === "";
});
let likeQuery_ = _.chain(requestBody)
.pick(requestBody, likeArray)
.omit(function (value, key, object) {
return value === "";
}).value();
let likeQuery = _.mapObject(likeQuery_, function (value, key) {
return "%" + value + "%";
});
dao.find({
where: whereQuery, like: likeQuery, orderBy: requestBody.orderBy
}, function (err, results) {
if (err) {
APIHelper.sendDatabaseErrorResponse(res, err);
} else {
if (results.length === 0) {
APIHelper.sendNotFoundResponse(res, "Not found.");
} else {
APIHelper.sendResponse(res, results);
}
}
});
}
示例4: async
checkMembershipUnicity: async (block:BlockDTO, conf:ConfDTO, index:IndexEntry[]) => {
const mindex = Indexer.mindex(index);
const pubkeys = _.chain(mindex).pluck('pub').uniq().value();
if (pubkeys.length !== mindex.length) {
throw Error('Unicity constraint PUBLIC_KEY on MINDEX is not respected');
}
return true;
},
示例5: isEmpty
public static isEmpty(queryBuilderExpression: QueryBuilderExpression) {
const allNonEmptyValues = _.chain(queryBuilderExpression)
.values()
.compact()
.value();
return _.isEmpty(allNonEmptyValues);
}
示例6: update
update() {
_.chain(this.tnxs)
.filter(t=> t.accountId == this.selectedFrom)
.forEach((t:Transaction) => {
t.accountId = this.selectedTo;
this._pTnxService.updateItem(t);
});
}
示例7: cb
return through2.obj(function (chunk, enc, cb) {
const pushGerritEventForward = (gerritEvent: GerritEvent) => this.push(gerritEvent);
_.chain(getGerritEventsStringByChunk(chunk))
.compact()
.map(parseToGerritEvent)
.compact()
.map(pushGerritEventForward);
cb();
});
示例8: instantiateToString
public instantiateToString(object: IQueryResult, instantiateOptions: IInstantiateTemplateOptions = {}): string {
Assert.exists(object);
let mergedOptions = new DefaultInstantiateTemplateOptions().merge(instantiateOptions);
object = _.extend({}, object, UnderscoreTemplate.templateHelpers);
const templates = _.chain(TemplateCache.getDefaultTemplates())
.map(name => TemplateCache.getTemplate(name))
.value();
// Put templates with conditions first
const sortedTemplates = _.chain(templates)
.sortBy(template => template.condition == null)
.sortBy(template => template.fieldsToMatch == null)
.value();
for (let i = 0; i < sortedTemplates.length; i++) {
const result = sortedTemplates[i].instantiateToString(object, mergedOptions);
if (result != null) {
return result;
}
}
return this.getFallbackTemplate();
}