From f112879e6bb3e052456751571375316808fcffed Mon Sep 17 00:00:00 2001 From: Jussi Laasonen Date: Thu, 6 Sep 2018 10:18:35 +0200 Subject: [PATCH] Extract method --- lib/aslGrammar.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/aslGrammar.js b/lib/aslGrammar.js index b517db0..7c6cd80 100644 --- a/lib/aslGrammar.js +++ b/lib/aslGrammar.js @@ -7,6 +7,12 @@ function mapFields (evaluetedFields, properties) { return _(properties).zip(fieldValues).fromPairs().value() } +function isIgnorable (value) { + const ignore = /Attinger|\.\.\.|^\?$|\/.+\/|[A-Z]|^[0-9]/ + const ignoreMark = /⁻|⁺/ + return ignore.test(value.value) || ignoreMark.test(value.mark) +} + const aslOhm = fs.readFileSync('lib/asl.ohm') const aslGrammar = ohm.grammar(aslOhm) const aslSemantics = aslGrammar.createSemantics().addOperation('eval', { @@ -50,18 +56,17 @@ const aslSemantics = aslGrammar.createSemantics().addOperation('eval', { return {fake: true} }, Value: function (tag, language, key, proofExample, fields) { - const ignore = /Attinger|\.\.\.|^\?$|\/.+\/|[A-Z]|^[0-9]/ - const ignoreMark = /⁻|⁺/ const evaluatedLanguage = _.head(language.eval()) const evaluatedProofExample = _.head(proofExample.eval()) const evaluetedFields = fields.eval() const properties = ['notes', 'internalNotes'] const value = key.eval() - return ignore.test(value.value) || ignoreMark.test(value.mark) + + return isIgnorable(value) ? {} : { values: { - ...(_.omit(key.eval(), 'mark')), + ...(_.omit(value, 'mark')), questionable: tag.sourceString.endsWith('?'), deprecated: tag.sourceString.endsWith('-'), ...(evaluatedLanguage ? {languageRestriction: evaluatedLanguage} : {}),