本文整理匯總了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));
}
}
};