当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript underscore.keys函数代码示例

本文整理汇总了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);
            }
        });
    }
开发者ID:JohanBaskovec,项目名称:libraryBackEnd,代码行数:33,代码来源:GoodORM.ts

示例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]);
   }
 },
开发者ID:Volicon,项目名称:NestedTypes,代码行数:8,代码来源:backbone.ts

示例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);
 }
开发者ID:do5,项目名称:mcgen,代码行数:8,代码来源:code-builder.ts

示例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);
        }
    });
};
开发者ID:shnud94,项目名称:livelang,代码行数:8,代码来源:index.ts

示例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 };
 }
开发者ID:bhollis,项目名称:DIM,代码行数:10,代码来源:loadout-builder.component.ts

示例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];
    }
  });
}
开发者ID:coveo,项目名称:search-ui,代码行数:10,代码来源:GlobalExports.ts

示例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)
 }
开发者ID:Kalmac,项目名称:duniter,代码行数:10,代码来源:StatDAL.ts

示例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]}`);
        });
      });
开发者ID:coveo,项目名称:search-ui,代码行数:10,代码来源:InlineRankingInfoTest.ts

示例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;
}
开发者ID:Kalmac,项目名称:duniter,代码行数:12,代码来源:network.ts

示例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));
       }
   }
};
开发者ID:shnud94,项目名称:livelang,代码行数:14,代码来源:index.ts


注:本文中的underscore.keys函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。