本文整理汇总了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 + '}';
};
示例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;
}
示例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);
});