本文整理汇总了TypeScript中lodash.constant函数的典型用法代码示例。如果您正苦于以下问题:TypeScript constant函数的具体用法?TypeScript constant怎么用?TypeScript constant使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了constant函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('undefined nested values in new settings should be ignored', () => {
const newSettings: SettingsPartial<any> = {
filterOptions: _.mapValues(allSettings.filterOptions, _.constant(undefined)),
dataOptions: _.mapValues(allSettings.dataOptions, _.constant(undefined)),
groupOptions: _.mapValues(allSettings.groupOptions, _.constant(undefined))
};
const actual = Settings.merge(allSettings, newSettings);
expect(actual).toEqualPlainObject(allSettings);
});
示例2: function
$scope.openDialog = function() {
$uibModal
.open({
template: require("views/modals/tagcloudmodal.html"),
controller: "TagCloudModalController",
resolve: {
model: _.constant($scope.model),
addLabel: _.constant($scope.addLabel),
lisaaUusiVaihtoehto: _.constant($scope.lisaaUusiVaihtoehto)
}
})
.result.then(angular.noop);
};
示例3: function
$scope.openKoodisto = function(osaAlue) {
if (!osaAlue.koodi) {
osaAlue.koodi = {};
}
var openDialog = Koodisto.modaali(
function(koodisto) {
osaAlue.koodi = {
uri: koodisto.koodiUri,
arvo: koodisto.koodiArvo,
versio: koodisto.versio,
koodisto: koodisto.koodisto.koodistoUri
};
MuokkausUtils.nestedSet(osaAlue.koodi, "koodiUri", ",", koodisto.koodiUri);
MuokkausUtils.nestedSet(osaAlue.koodi, "koodiArvo", ",", koodisto.koodiArvo);
},
{
tyyppi: function() {
return "ammatillisenoppiaineet";
},
ylarelaatioTyyppi: function() {
return "";
},
tarkista: _.constant(true)
}
);
openDialog();
};
示例4: function
registerCallback: function(callback) {
if (
!callback ||
!_.isFunction(callback.edit) ||
(!_.isFunction(callback.save) && !_.isFunction(callback.asyncSave)) ||
!_.isFunction(callback.cancel)
) {
console.error("callback-function invalid");
throw "editCallback-function invalid";
}
callback.validate = callback.validate || _.constant(true);
if (callback.asyncSave) {
callback.save = _.noop;
}
if (!_.isFunction(callback.notify)) {
callback.notify = _.noop;
}
editmodeListener = null;
scope.editingCallback = callback;
scope.editModeDefer.resolve(scope.editMode);
cbListener();
},
示例5: it
it('undefined values in new settings should be ignored', () => {
const newSettings = _.mapValues(allSettings, _.constant(undefined));
// when
ngTableFilterConfigProvider.setConfig(newSettings);
// then
ngTableFilterConfig = ngTableFilterConfigProvider.$get();
expect(ngTableFilterConfig.config).toEqualPlainObject(allSettings);
});
示例6: function
return function(suoritustapa, ryhma, vanhempi, leikelauta) {
$uibModal
.open({
template: require("views/modals/ryhmaModal.html"),
controller: "MuodostumisryhmaModalCtrl",
resolve: {
ryhma: _.constant(ryhma),
vanhempi: _.constant(vanhempi),
suoritustapa: _.constant(suoritustapa),
leikelauta: _.constant(leikelauta),
peruste: _.constant(peruste)
}
})
.result.then(function(res) {
thenCb(ryhma, vanhempi, res);
});
};
示例7: getOsaamisalakuvaukset
export async function getOsaamisalakuvaukset(perusteId: number) {
const res = await axios.get(`${PerusteEndpoint}/${perusteId}/osaamisalakuvaukset`);
return _(_.values(res.data))
.map(_.keys)
.flatten()
.groupBy(_.identity)
.mapValues(_.constant(true))
.value();
}
示例8: run
function run(provider) {
// Sane defaults
provider.sortableClass = provider.sortableClass || _.constant("");
provider.acceptDrop = provider.acceptDrop || _.constant(true);
$scope.tprovider = provider;
provider
.root()
.then(function(root) {
$scope.root = root;
return provider.children(root);
})
.then(function(children) {
$scope.children = children;
})
.catch(function(err) {
$log.error(err);
});
}
示例9: lisaaTiedote
function lisaaTiedote(tiedote, perusteprojektiId, saveCb, deleteCb) {
saveCb = saveCb || _.noop;
deleteCb = deleteCb || _.noop;
$uibModal
.open({
template: require("views/modals/tiedotteenmuokkaus.html"),
controller: "TiedotteenMuokkausController",
size: "lg",
resolve: {
model: _.constant(tiedote),
perusteprojektiId: _.constant(perusteprojektiId)
}
})
.result.then(function(data) {
if (data.$dodelete) {
doDelete(data, deleteCb);
} else {
doSave(data, saveCb);
}
});
}
示例10: valueToUrl
export function valueToUrl(
value,
{
host,
type,
thumbnail,
}: {
host?: string;
type?: 'image' | 'video' | 'attache' | 'file';
thumbnail?: { width?: number; height?: number };
},
) {
if (value) {
const hostPrefix =
host ||
_.cond([
[_.matches('image'), _.constant(Config.get('IMAGE_HOST'))],
[_.matches('video'), _.constant(Config.get('VIDEO_HOST'))],
[_.matches('attache'), _.constant(Config.get('ATTACHE_HOST'))],
[_.matches('file'), _.constant(Config.get('FILE_HOST'))],
])(type) ||
'';
let url = hostPrefix + `/${value}`.replace('//', '/').slice(1);
if (thumbnail) {
const template = _.get(AppContext.serverSettings['settings.url-resolver'], 'value.uploads');
try {
url = template.replace('{{ url }}', url);
} catch (e) {
logger.warn('using template error', { template, url });
}
// url += `?imageView2/2/w/${thumbnail.width || 1280}/h/${thumbnail.height ||
// 1280}/format/jpg/interlace/1/ignore-error/1`;
}
logger.debug('[valueToUrl]', { value, url, host });
return url;
}
return '';
}