當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。