• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript lodash.keys函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中lodash.keys函数的典型用法代码示例。如果您正苦于以下问题:TypeScript keys函数的具体用法?TypeScript keys怎么用?TypeScript keys使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了keys函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: applyPromiseWithCallback

 function applyPromiseWithCallback(fnName, callback, args_) {
   try {
     let args = args_
     if (!_.isArray(args_)) {
       const fnParameters = jayson.Utils.getParameterNames(rippleAPI[fnName])
       args = fnParameters.map(name => args_[name])
       const defaultArgs = _.omit(args_, fnParameters)
       assert(_.size(defaultArgs) <= 1,
         'Function must have no more than one default argument')
       if (_.size(defaultArgs) > 0) {
         args.push(defaultArgs[_.keys(defaultArgs)[0]])
       }
     }
     Promise.resolve(rippleAPI[fnName](...args))
       .then(res => callback(null, res))
       .catch(err => {
         callback({code: 99, message: err.message, data: {name: err.name}})
       })
   } catch (err) {
     callback({code: 99, message: err.message, data: {name: err.name}})
   }
 }
开发者ID:ledgerd,项目名称:ledgerd-lib,代码行数:22,代码来源:http.ts


示例2: setTimeout

 p.then(() => {
   assert.lengthOf(fetchMock.calls("/_admin/v1/uidata"), 1);
   assert.lengthOf(_.keys(state), 2);
   assert.equal(state[uiKey1].state, uidata.UIDataState.SAVING);
   assert.equal(state[uiKey2].state, uidata.UIDataState.SAVING);
   assert.isUndefined(state[uiKey1].data);
   assert.isUndefined(state[uiKey2].data);
   assert.notProperty(state[uiKey1], "data");
   assert.notProperty(state[uiKey2], "data");
   assert.isUndefined(state[uiKey1].error);
   assert.isUndefined(state[uiKey2].error);
   setTimeout(
     () => {
       assert.equal(state[uiKey1].state, uidata.UIDataState.SAVE_ERROR);
       assert.equal(state[uiKey2].state, uidata.UIDataState.SAVE_ERROR);
       assert.instanceOf(state[uiKey1].error, Error);
       assert.instanceOf(state[uiKey2].error, Error);
       done();
     },
     1000,
   );
 });
开发者ID:TDAbboud,项目名称:cockroach,代码行数:22,代码来源:uiData.spec.ts


示例3: function

                function(res) {
                    var valittuOppiaine: any = {};
                    valittuOppiaine.oppiaine = res;
                    valittuOppiaine.vuosiluokkakokonaisuudet = _.zipBy(
                        res.vuosiluokkakokonaisuudet,
                        "_vuosiluokkaKokonaisuus"
                    );
                    $scope.valittuOppiaine = valittuOppiaine;

                    var valittavaVuosiluokka = $scope.valittuOppiaine.vuosiluokkakokonaisuudet[
                        $scope.filtterit.valittuKokonaisuus
                    ]
                        ? $scope.filtterit.valittuKokonaisuus
                        : _.first(_.keys($scope.valittuOppiaine.vuosiluokkakokonaisuudet));

                    if ($scope.currentSection === "vlk") {
                        valittavaVuosiluokka = $scope.valittuVuosiluokkakokonaisuus.id;
                    }

                    $scope.valitseOppiaineenVuosiluokka(valittavaVuosiluokka, true);
                    $scope.activeSection = "sisalto";
                },
开发者ID:Opetushallitus,项目名称:eperusteet,代码行数:22,代码来源:perusopetus.ts


示例4: Date

		fields.forEach(field => {
			let newVal: any;
			let oldVal: any;

			// for dates we want to compare the time stamp
			if (oldObj[field] instanceof Date) {
				newVal = newObj[field] ? new Date(newObj[field]).getTime() : undefined;
				oldVal = oldObj[field] ? new Date(oldObj[field]).getTime() : undefined;

			// for objects, serialize first.
			} else if (isObject(oldObj[field])) {
				newVal = newObj[field] ? JSON.stringify(newObj[field]) : undefined;
				oldVal = oldObj[field] ? JSON.stringify(pick(oldObj[field], keys(newObj[field] || {}))) : undefined;

			// otherwise, take raw values.
			} else {
				newVal = newObj[field];
				oldVal = oldObj[field];
			}
			if (newVal && newVal !== oldVal) {
				modifiedFields.push(field);
			}
		});
开发者ID:freezy,项目名称:node-vpdb,代码行数:23,代码来源:api.ts


示例5: slackFieldify

function slackFieldify(inputObj: Object, short?: boolean, prefix?: string) {
  var prefix = prefix ? prefix + '_' : ''
  var short = short ? true : false

  if (Array.isArray(inputObj) && inputObj.length === 1) {
    inputObj = inputObj[0]
  }

  var result = _.map(_.keys(inputObj), function(key){
    if (!_.isObject(inputObj[key])) {
      return {
        title: s(prefix + key).humanize().titleize().value(),
        value: inputObj[key],
        short: short
      }
    } else {
      return slackFieldify(inputObj[key], short, prefix + key)
    }
  })

  result = _.flatten(result)
  return result
}
开发者ID:brettneese,项目名称:slack-fieldify,代码行数:23,代码来源:index.ts


示例6: selectNewCertificateType

    public selectNewCertificateType(stack: Array<any>) {
        let self = this,
            objectType = Model.CryptoCertificate,
            columnIndex = 2,
            parentContext = stack[columnIndex - 1],
            context: any = {
                columnIndex: columnIndex,
                objectType: objectType,
                parentContext: parentContext,
                isCreatePrevented: true,
                path: parentContext.path + '/create'
            };
        return Promise.all([
            Promise.all(_.map(_.keys(CryptoCertificateType), (type) => this.cryptoCertificateRepository.getNewCryptoCertificate(type))),
            this.modelDescriptorService.getUiDescriptorForType(objectType)
        ]).spread(function(cryptoCertificates: Array<any>, uiDescriptor) {
            (cryptoCertificates as any)._objectType = objectType;
            context.object = _.compact(cryptoCertificates);
            context.userInterfaceDescriptor = uiDescriptor;

            return self.updateStackWithContext(stack, context);
        });
    }
开发者ID:mactanxin,项目名称:gui,代码行数:23,代码来源:system.ts


示例7: keys

    }).then((backingData: Partial<IEcsServerGroupCommandBackingData>) => {
      let loadBalancerReloader = this.$q.when(null);
      backingData.accounts = keys(backingData.credentialsKeyedByAccount);
      backingData.filtered = {} as IEcsServerGroupCommandBackingDataFiltered;
      command.backingData = backingData as IEcsServerGroupCommandBackingData;
      this.configureVpcId(command);
      this.configureAvailableIamRoles(command);
      this.configureAvailableMetricAlarms(command);
      this.configureAvailableEcsClusters(command);

      if (command.loadBalancers && command.loadBalancers.length) {
        // verify all load balancers are accounted for; otherwise, try refreshing load balancers cache
        const loadBalancerNames = this.getLoadBalancerNames(command);
        if (intersection(loadBalancerNames, command.loadBalancers).length < command.loadBalancers.length) {
          loadBalancerReloader = this.refreshLoadBalancers(command, true);
        }
      }

      return this.$q.all([loadBalancerReloader]).then(() => {
        this.applyOverrides('afterConfiguration', command);
        this.attachEventHandlers(command);
      });
    });
开发者ID:robfletcher,项目名称:deck,代码行数:23,代码来源:serverGroupConfiguration.service.ts


示例8: parseInt

    app.route('/api/threads/:id').post((req, res) => {

        const payload = req.body;



        const threadId = parseInt(req.params.id),
            participantId = parseInt(req.headers['userid']);

        const message: Message = {
            id: messageIdCounter++,
            threadId,
            timestamp: new Date().getTime(),
            text: payload.text,
            participantId
        };

        // save the new message, it's
        // already linked to a thread
        dbMessages[message.id] = message;

        const thread = findThreadById(threadId);
        thread.messageIds.push(message.id);

        const otherParticipantIds = _.keys(thread.participants).filter(id => parseInt(id) !== participantId);

        otherParticipantIds.forEach(participantId => {
            thread.participants[participantId] += 1;
            dbMessagesQueuePerUser[participantId].push(message.id);

        });

        thread.participants[participantId] = 0;

        res.status(200).send();

    });
开发者ID:MidoShahin,项目名称:Chat-App-using-ngrx-store,代码行数:37,代码来源:apiSaveNewMessage.ts


示例9: changePlugin

  changePlugin(newPlugin: PanelPlugin) {
    const pluginId = newPlugin.meta.id;
    const oldOptions: any = this.getOptionsToRemember();
    const oldPluginId = this.type;

    // for angular panels we must remove all events and let angular panels do some cleanup
    if (this.plugin.angularPanelCtrl) {
      this.destroy();
    }

    // remove panel type specific  options
    for (const key of _.keys(this)) {
      if (mustKeepProps[key]) {
        continue;
      }

      delete (this as any)[key];
    }

    this.cachedPluginOptions[oldPluginId] = oldOptions;
    this.restorePanelOptions(pluginId);

    // switch
    this.type = pluginId;
    this.plugin = newPlugin;

    // Let panel plugins inspect options from previous panel and keep any that it can use
    if (newPlugin.onPanelTypeChanged) {
      this.options = this.options || {};
      const old = oldOptions && oldOptions.options ? oldOptions.options : {};
      Object.assign(this.options, newPlugin.onPanelTypeChanged(this.options, oldPluginId, old));
    }

    if (newPlugin.onPanelMigration) {
      this.pluginVersion = getPluginVersion(newPlugin);
    }
  }
开发者ID:johntdyer,项目名称:grafana,代码行数:37,代码来源:PanelModel.ts


示例10: addAnnotations

      function addAnnotations(options) {
        if (!annotations || annotations.length === 0) {
          return;
        }

        var types = {};
        for (var i = 0; i < annotations.length; i++) {
          var item = annotations[i];

          if (!types[item.source.name]) {
            types[item.source.name] = {
              color: item.source.iconColor,
              position: 'BOTTOM',
              markerSize: 5,
            };
          }
        }

        options.events = {
          levels: _.keys(types).length + 1,
          data: annotations,
          types: types,
        };
      }
开发者ID:sis-labs,项目名称:grafana,代码行数:24,代码来源:graph.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript lodash.keysIn函数代码示例发布时间:2022-05-25
下一篇:
TypeScript lodash.keyBy函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap