From 995ed7fa09aa3c2149647a3a047dd9bdfb0ed605 Mon Sep 17 00:00:00 2001 From: HP Dietz Date: Tue, 22 Oct 2019 17:58:16 +0200 Subject: [PATCH] Fix functions export. --- lib/profiles/comparison-statements/index.js | 55 ++++++++++++++++----- 1 file changed, 44 insertions(+), 11 deletions(-) diff --git a/lib/profiles/comparison-statements/index.js b/lib/profiles/comparison-statements/index.js index 9f321fa..d3da519 100644 --- a/lib/profiles/comparison-statements/index.js +++ b/lib/profiles/comparison-statements/index.js @@ -3,12 +3,16 @@ const unique = require('../../support/array').unique; const compIf = { description: 'if statement', codeSample: 'if (d > 0) { return d / 2; }', - keyowrds: [ + keywords: [ 'if', 'comparison', 'statement', 'else', - 'else if' + 'else if', + 'branching', + 'control structure', + 'control flow', + 'flow' ], f: (d) => { if (d === 0) { @@ -22,7 +26,18 @@ const compIf = { }; const compSwitch = { - description: 'switch (d) { case 0: return d; default: return d / 2; }', + description: 'switch statement', + codeSample: 'switch (d) { case 0: return d; default: return d / 2; }', + keywords: [ + 'switch', + 'comparison', + 'statement', + 'break', + 'branching', + 'control structure', + 'control flow', + 'flow' + ], f: (d) => { switch (d) { case 0: @@ -34,12 +49,35 @@ const compSwitch = { }; const compTernary = { - description: 'd > 0 ? d / 2 : d', + description: 'ternary expression', + keywords: [ + 'ternary', + 'expression', + 'comparison', + 'statement', + 'branching', + 'control structure', + 'control flow', + 'flow' + ], + codeSample: 'd > 0 ? d / 2 : d', f: (d) => d > 0 ? d / 2 : d }; const compAnd = { - description: '(d > 0 && d / 2) || d', + description: 'and-or, && ||', + keywords: [ + 'and', + 'or', + 'comparison', + 'statement', + 'expression', + 'branching', + 'control structure', + 'control flow', + 'flow' + ], + codeSample: '(d > 0 && d / 2) || d', f: (d) => (d > 0 && d / 2) || d }; @@ -56,12 +94,7 @@ module.exports = { long: 'Comparison statements: conditionally branching in a function based on simple comparisons.', short: 'Comparison statements: if vs. switch vs. ternary vs. logical.' }, - functions: [ - compIf, - compSwitch, - compTernary, - compAnd - ], + functions, keywords: unique( functions.map((fn) => fn.keywords) .reduce((keywords, fnKeywords) => [...keywords, ...fnKeywords])