本文整理汇总了TypeScript中underscore.keys函数的典型用法代码示例。如果您正苦于以下问题:TypeScript keys函数的具体用法?TypeScript keys怎么用?TypeScript keys使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了keys函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: remove
// delete is a reserved word :(
remove(opts: SelectOptions,
callback: (err: IError, results: any) => void) {
let tablename = this.tablename;
let conn = DbConnection.getConnection();
let query = "DELETE FROM " + tablename + " ";
let values: any[] = [];
if (!_.isEmpty(opts.where)) {
query += "WHERE ";
let whereKeys = _.keys(opts.where);
let i = 0;
while (i < whereKeys.length - 1) {
let columnName = this.columnsMapping[whereKeys[i]];
query += columnName + " = ? AND ";
values.push(opts.where[whereKeys[i]]);
i++;
}
let columnName = this.columnsMapping[whereKeys[i]];
query += columnName + " = ? ";
values.push(opts.where[whereKeys[i]]);
}
console.log("Delete query : " + query);
conn.query(query, values, (err, results) => {
if (err) {
callback(err, null);
} else {
callback(null, results);
}
});
}
示例2: function
_bindRoutes: function () {
if (!this.routes) return;
this.routes = _.result(this, 'routes');
var route, routes = _.keys(this.routes);
while ((route = routes.pop()) != null) {
this.route(route, this.routes[route]);
}
},
示例3: regFromFile
public static regFromFile(file: string): string[] {
if (!fs.existsSync(file)) return [];
let fns = fs.readFileSync(file, 'utf8');
var func = new Function('require', fns);
var helpers = func.call(this, require);
CodeBuider.regs(helpers);
return _.keys(helpers);
}
示例4: reviveNode
export const reviveChildren = (object: Nodes, storeById: any = {}) => {
_.keys(object).filter(k => !k.startsWith('_')).forEach(key => {
const val = object[key];
if (val && typeof(val) === 'object') {
reviveNode(val, object, storeById);
}
});
};
示例5:
function mergeBuckets<T>(
bucket1: { [armorType in ArmorTypes]: T },
bucket2: { [armorType in ArmorTypes]: T }
): { [armorType in ArmorTypes]: T } {
const merged = {};
_.each(_.keys(bucket1), (type) => {
merged[type] = bucket1[type].concat(bucket2[type]);
});
return merged as { [armorType in ArmorTypes]: T };
}
示例6: exportGlobally
export function exportGlobally(toExportGlobally: IExportedGlobally) {
if (window['Coveo'] == undefined) {
window['Coveo'] = {};
}
_.each(_.keys(toExportGlobally), (key: string) => {
if (window['Coveo'][key] == null) {
window['Coveo'][key] = toExportGlobally[key];
}
});
}
示例7: pushStats
async pushStats(statsToPush:any) {
const stats = (await this.loadStats()) || {};
_.keys(statsToPush).forEach(function(statName:string){
if (!stats[statName]) {
stats[statName] = { blocks: [] };
}
stats[statName].blocks = stats[statName].blocks.concat(statsToPush[statName].blocks);
});
return this.coreFS.writeJSON('stats.json', stats)
}
示例8: it
it('should output a section for each relevant parsed document weights', () => {
const built = inlineRankingInfo.build();
const sections = built.findAll('div.coveo-relevance-inspector-inline-ranking-section');
expect(sections.length).toEqual(10);
const documentWeights = keys(parsed.documentWeights);
each(documentWeights, (documentWeight, i) => {
expect(sections[i].textContent).toContain(`${documentWeight}: ${parsed.documentWeights[documentWeight]}`);
});
});
示例9: listInterfaces
function listInterfaces() {
const netInterfaces = os.networkInterfaces();
const keys = _.keys(netInterfaces);
const res = [];
for (const name of keys) {
res.push({
name: name,
addresses: netInterfaces[name]
});
}
return res;
}
示例10: doer
export const eachChild = (val: any, doer: (node: Nodes) => void) => {
if (val != null && typeof(val) === 'object') {
if (val.type) {
doer(val);
_.keys(val).forEach(key => {
if (key === '_parent') return; // stop infinite recursion
eachChild(val[key], doer);
})
}
else if (Array.isArray(val)) {
val.forEach(c => eachChild(c, doer));
}
}
};