Skip to content

Commit

Permalink
Fix functions export.
Browse files Browse the repository at this point in the history
  • Loading branch information
HP Dietz committed Oct 22, 2019
1 parent bd2bb79 commit 995ed7f
Showing 1 changed file with 44 additions and 11 deletions.
55 changes: 44 additions & 11 deletions lib/profiles/comparison-statements/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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:
Expand All @@ -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
};

Expand All @@ -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])
Expand Down

0 comments on commit 995ed7f

Please sign in to comment.