refactor: HeliumService

This commit is contained in:
1ambda 2017-02-16 13:38:11 +09:00
parent f31bf3c7c3
commit 33a2bd8f8b

View file

@ -70,9 +70,7 @@ export default function heliumService($http, $sce, baseUrlSrv) {
this.executeSpell = function(magic, textWithoutMagic) {
const promisedConf = this.getSinglePackageConfigUsingMagic(magic)
.then(confs => {
return createPersistableConfig(confs);
});
.then(confs => createPersistableConfig(confs));
return promisedConf.then(conf => {
const spell = this.getSpellByMagic(magic);
@ -84,16 +82,13 @@ export default function heliumService($http, $sce, baseUrlSrv) {
});
};
this.executeSpellAsDisplaySystem = function(type, data) {
const promisedConf = this.getSinglePackageConfigUsingMagic(type)
.then(confs => {
return createPersistableConfig(confs);
});
this.executeSpellAsDisplaySystem = function(magic, textWithoutMagic) {
const promisedConf = this.getSinglePackageConfigUsingMagic(magic)
.then(confs => createPersistableConfig(confs));
return promisedConf.then(conf => {
const spell = this.getSpellByMagic(type);
const spellResult = spell.interpret(data.trim(), conf);
const spell = this.getSpellByMagic(magic);
const spellResult = spell.interpret(textWithoutMagic.trim(), conf);
const parsed = spellResult.getAllParsedDataWithTypes(spellPerMagic);
return parsed;