本文整理匯總了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);
});