當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript lodash.pairs函數代碼示例

本文整理匯總了TypeScript中lodash.pairs函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript pairs函數的具體用法?TypeScript pairs怎麽用?TypeScript pairs使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了pairs函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: function

 this.getOriginalMetricName = function(labelData) {
   var metricName = labelData.__name__ || '';
   delete labelData.__name__;
   var labelPart = _.map(_.pairs(labelData), function(label) {
     return label[0] + '="' + label[1] + '"';
   }).join(',');
   return metricName + '{' + labelPart + '}';
 };
開發者ID:AutogrowSystems,項目名稱:grafana,代碼行數:8,代碼來源:datasource.ts

示例2: _dictToComponent

/**
 * Convert dictionary of strings into a URI Component.
 * All key value entries get added as key value pairs in the component,
 * with the exception of a key with the TAB value, which if present
 * gets prepended to the URI Component string for backwards comptability
 * reasons.
 */
function _dictToComponent(items: StringDict): string {
  let component = '';

  // Add the tab name e.g. 'events', 'images', 'histograms' as a prefix
  // for backwards compatbility.
  if (items[TAB] !== undefined) {
    component += items[TAB];
  }

  // Join other strings with &key=value notation
  const nonTab = _.pairs(items)
                   .filter((pair) =>  pair[0] !== TAB)
                   .map((pair) => {
                     return encodeURIComponent(pair[0]) + '=' +
                         encodeURIComponent(pair[1]);
                   })
                   .join('&');

  return nonTab.length > 0 ? (component + '&' + nonTab) : component;
}
開發者ID:AlbertXiebnu,項目名稱:tensorflow,代碼行數:27,代碼來源:storage.ts

示例3: function

    .controller("KieliCtrl", function(
        $scope,
        $stateParams,
        YleinenData,
        $state,
        Kieli,
        Profiili,
        $q,
        KielipreferenssiUpdater
    ) {
        KielipreferenssiUpdater.noop();
        $scope.isModal = $scope.modal === "true";
        $scope.sisaltokielet = [];
        $scope.sisaltokieli = Kieli.getSisaltokieli();
        $scope.kieliOrder = Kieli.kieliOrder;
        $scope.uiLangChangeAllowed = true;
        var stateInit = $q.defer();
        var casFetched = $q.defer();

        var info = Profiili.profiili();
        if (info.$casFetched) {
            casFetched.resolve();
        }

        $scope.$on("$stateChangeSuccess", function() {
            stateInit.resolve();
        });

        $scope.$on("fetched:casTiedot", function() {
            casFetched.resolve();
        });

        $q.all([stateInit.promise, casFetched.promise]).then(function() {
            var lang = Profiili.lang();
            // Disable ui language change if language preference found in CAS
            if (Kieli.isValidKielikoodi(lang)) {
                $scope.uiLangChangeAllowed = false;
                Kieli.setUiKieli(lang);
            }
            var profiili = Profiili.profiili();
            if (profiili.preferenssit.sisaltokieli) {
                Kieli.setSisaltokieli(profiili.preferenssit.sisaltokieli);
            }
        });

        const updateSisaltokielet = value => {
            $scope.sisaltokielet = _.map(Kieli.SISALTOKIELET, kieli => {
                return {
                    kieli,
                    inUse: _.includes(value, kieli)
                };
            });
        };

        $scope.$on("update:sisaltokielet", function(event, value) {
            updateSisaltokielet(value);
        });

        $scope.$on("changed:sisaltokieli", function(event, value) {
            $scope.sisaltokieli = value;
        });

        $scope.setSisaltokieli = function(kieli) {
            Kieli.setSisaltokieli(kieli.kieli);
        };

        $scope.koodit = _.map(_.pairs(YleinenData.kielet), function(item) {
            return { koodi: item[1], nimi: item[0] };
        });
        $scope.kieli = YleinenData.kieli;

        $scope.$on("notifyCKEditor", function() {
            $scope.kieli = YleinenData.kieli;
        });

        $scope.vaihdaKieli = function(kielikoodi) {
            Kieli.setUiKieli(kielikoodi);
        };

        updateSisaltokielet(Kieli.SISALTOKIELET);
    });
開發者ID:Opetushallitus,項目名稱:eperusteet,代碼行數:81,代碼來源:kieli.ts


注:本文中的lodash.pairs函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。