From 49146475afd3ccbbfbfb8ed4cf17e3500456f007 Mon Sep 17 00:00:00 2001 From: HP Dietz Date: Tue, 22 Oct 2019 17:39:44 +0200 Subject: [PATCH 1/2] Add a profile for comparison statements. --- CHANGELOG.md | 3 + .../comparison-statements.profile.spec.js | 43 ++++++ lib/profiles/comparison-statements/index.js | 47 ++++++ lib/profiles/comparisons/index.js | 7 +- lib/profiles/loops/index.js | 2 +- package-lock.json | 144 ++++++++++-------- package.json | 6 +- 7 files changed, 178 insertions(+), 74 deletions(-) create mode 100644 lib/profiles/comparison-statements/comparison-statements.profile.spec.js create mode 100644 lib/profiles/comparison-statements/index.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 004a691..0c49c5c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +### 1.25.0 +* [#77: Add a profile for comparison statements.](https://github.com/haensl/js-profiler/issues/77) + ### 1.24.0 * [#83: Add Object.defineProperty to object creation profile.](https://github.com/haensl/js-profiler/issues/83) diff --git a/lib/profiles/comparison-statements/comparison-statements.profile.spec.js b/lib/profiles/comparison-statements/comparison-statements.profile.spec.js new file mode 100644 index 0000000..8e00864 --- /dev/null +++ b/lib/profiles/comparison-statements/comparison-statements.profile.spec.js @@ -0,0 +1,43 @@ +const expect = require('chai').expect; +const comparisonStatements = require('./'); + +describe('Comparison statements', () => { + let result; + let data; + + describe('data: 0', () => { + beforeEach(() => { + data = 0; + }); + + comparisonStatements.functions.forEach((fn) => { + describe(`${fn.description}`, () => { + beforeEach(() => { + result = fn.f(data); + }); + + it('returns 0', () => { + expect(result).to.equal(0); + }); + }); + }); + }); + + describe('data: 2', () => { + beforeEach(() => { + data = 2; + }); + + comparisonStatements.functions.forEach((fn) => { + describe(`${fn.description}`, () => { + beforeEach(() => { + result = fn.f(data); + }); + + it('returns 0', () => { + expect(result).to.equal(1); + }); + }); + }); + }); +}); diff --git a/lib/profiles/comparison-statements/index.js b/lib/profiles/comparison-statements/index.js new file mode 100644 index 0000000..746aa3f --- /dev/null +++ b/lib/profiles/comparison-statements/index.js @@ -0,0 +1,47 @@ +const compIf = { + description: 'if (d > 0) { return d / 2; }', + f: (d) => { + if (d === 0) { + return d; + } else if (d > 0) { + return d / 2; + } + } +}; + +const compSwitch = { + description: 'switch (d) { case 0: return d; default: return d / 2; }', + f: (d) => { + switch (d) { + case 0: + return d; + default: + return d / 2; + } + } +}; + +const compTernary = { + description: 'd > 0 ? d / 2 : d', + f: (d) => d > 0 ? d / 2 : d +}; + +const compAnd = { + description: '(d > 0 && d / 2) || d', + f: (d) => (d > 0 && d / 2) || d +}; + +module.exports = { + name: 'comparison statements', + description: { + 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 + ], + testDataType: 'number' +}; diff --git a/lib/profiles/comparisons/index.js b/lib/profiles/comparisons/index.js index 81dbac4..8e50451 100644 --- a/lib/profiles/comparisons/index.js +++ b/lib/profiles/comparisons/index.js @@ -1,4 +1,3 @@ - const compGreater = { description: 'a > b', f: (d) => d > 5 @@ -7,7 +6,7 @@ const compGreater = { const compGreaterEqual = { description: 'a >= b', f: (d) => d >= 5 -} +}; const compLess = { description: 'a < b', @@ -21,7 +20,7 @@ const compLessEqual = { const compEql = { description: 'a == b', - f: (d) => d == 5 + f: (d) => d == 5 // eslint-disable-line eqeqeq }; const compEqual = { @@ -31,7 +30,7 @@ const compEqual = { const compNotEql = { description: 'a != b', - f: (d) => d != 5 + f: (d) => d != 5 // eslint-disable-line eqeqeq }; const compNotEqual = { diff --git a/lib/profiles/loops/index.js b/lib/profiles/loops/index.js index ad74d77..22ee9f8 100644 --- a/lib/profiles/loops/index.js +++ b/lib/profiles/loops/index.js @@ -126,7 +126,7 @@ const loopForOf = { description: 'for (prop of []) => []', f: (d) => { const r = []; - for (let p of d) { + for (const p of d) { r.push(p < 5 && p > 3); } diff --git a/package-lock.json b/package-lock.json index ee8ed3b..2f5cd58 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "js-profiler", - "version": "1.22.0", + "version": "1.24.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -119,12 +119,6 @@ "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", "dev": true }, - "builtin-modules": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", - "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=", - "dev": true - }, "caller-callsite": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/caller-callsite/-/caller-callsite-2.0.0.tgz", @@ -187,9 +181,9 @@ "dev": true }, "ci-info": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-1.6.0.tgz", - "integrity": "sha512-vsGdkwSCDpWmP80ncATX7iea5DWQemg1UgCW5J8tqjU3lYw4FBYuj89J0CTVomA7BEfvSZd84GmHko+MxFQU2A==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-2.0.0.tgz", + "integrity": "sha512-5tK7EtrZ0N+OLFMthtqOj4fI2Jeb88C4CAZPu25LDVUgXJ0A3Js4PMGqrn0JU1W0Mh1/Z8wZzYPxqUrXeBboCQ==", "dev": true }, "circular-json": { @@ -264,15 +258,27 @@ "dev": true }, "cosmiconfig": { - "version": "5.0.7", - "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-5.0.7.tgz", - "integrity": "sha512-PcLqxTKiDmNT6pSpy4N6KtuPwb53W+2tzNvwOZw0WH9N6O0vLIBq0x8aj8Oj75ere4YcGi48bDFCL+3fRJdlNA==", + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-5.2.1.tgz", + "integrity": "sha512-H65gsXo1SKjf8zmrJ67eJk8aIRKV5ff2D4uKZIBZShbhGSpEmsQOPW/SKMKYhSTrqR7ufy6RP69rPogdaPh/kA==", "dev": true, "requires": { "import-fresh": "^2.0.0", "is-directory": "^0.3.1", - "js-yaml": "^3.9.0", + "js-yaml": "^3.13.1", "parse-json": "^4.0.0" + }, + "dependencies": { + "js-yaml": { + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", + "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", + "dev": true, + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + } } }, "cross-spawn": { @@ -344,9 +350,9 @@ } }, "end-of-stream": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.1.tgz", - "integrity": "sha512-1MkrZNvWTKCaigbn+W15elq2BB/L22nqrSY5DKlo3X6+vclJm8Bb5djXJBmEX6fS3+zCh/F4VBK5Z2KxJt4s2Q==", + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", + "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", "dev": true, "requires": { "once": "^1.4.0" @@ -651,9 +657,9 @@ } }, "glob": { - "version": "7.1.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", - "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", + "version": "7.1.5", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.5.tgz", + "integrity": "sha512-J9dlskqUXK1OeTOYBEn5s8aMukWMwWfs+rPTn/jn50Ux4MNXVhubL1wu/j2t+H4NVI+cXEcCaYellqaPVGXNqQ==", "requires": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", @@ -702,22 +708,22 @@ "dev": true }, "hosted-git-info": { - "version": "2.7.1", - "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.7.1.tgz", - "integrity": "sha512-7T/BxH19zbcCTa8XkMlbK5lTo1WtgkFi3GvdWEyNuc4Vex7/9Dqbnpsf4JMydcfj9HCg4zUWFTL3Za6lapg5/w==", + "version": "2.8.5", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.5.tgz", + "integrity": "sha512-kssjab8CvdXfcXMXVcvsXum4Hwdq9XGtRD3TteMEvEbq0LXyiNQr6AprqKqfeaDXze7SxWvRxdpwE6ku7ikLkg==", "dev": true }, "husky": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/husky/-/husky-1.2.0.tgz", - "integrity": "sha512-/ib3+iycykXC0tYIxsyqierikVa9DA2DrT32UEirqNEFVqOj1bFMTgP3jAz8HM7FgC/C8pc/BTUa9MV2GEkZaA==", + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/husky/-/husky-1.3.1.tgz", + "integrity": "sha512-86U6sVVVf4b5NYSZ0yvv88dRgBSSXXmHaiq5pP4KDj5JVzdwKgBjEtUPOm8hcoytezFwbU+7gotXNhpHdystlg==", "dev": true, "requires": { - "cosmiconfig": "^5.0.6", + "cosmiconfig": "^5.0.7", "execa": "^1.0.0", "find-up": "^3.0.0", "get-stdin": "^6.0.0", - "is-ci": "^1.2.1", + "is-ci": "^2.0.0", "pkg-dir": "^3.0.0", "please-upgrade-node": "^3.1.1", "read-pkg": "^4.0.1", @@ -861,22 +867,13 @@ "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=", "dev": true }, - "is-builtin-module": { - "version": "1.0.0", - "resolved": "http://registry.npmjs.org/is-builtin-module/-/is-builtin-module-1.0.0.tgz", - "integrity": "sha1-VAVy0096wxGfj3bDDLwbHgN6/74=", - "dev": true, - "requires": { - "builtin-modules": "^1.0.0" - } - }, "is-ci": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/is-ci/-/is-ci-1.2.1.tgz", - "integrity": "sha512-s6tfsaQaQi3JNciBH6shVqEDvhGut0SUXr31ag8Pd8BBbVVlcGfWhpPmEOoM6RJ5TFhbypvf5yyRw/VXW1IiWg==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-ci/-/is-ci-2.0.0.tgz", + "integrity": "sha512-YfJT7rkpQB0updsdHLGWrvhBJfcfzNNawYDNIyQXJz0IViGf75O8EBPKSdvw2rF+LGCsX4FZ8tcr3b19LcZq4w==", "dev": true, "requires": { - "ci-info": "^1.5.0" + "ci-info": "^2.0.0" } }, "is-directory": { @@ -928,9 +925,9 @@ "dev": true }, "js-yaml": { - "version": "3.12.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.12.0.tgz", - "integrity": "sha512-PIt2cnwmPfL4hKNwqeiuz4bKfnzHTBv6HyVgjahA6mPLwPDzjDWrplJBMjHUFxku/N3FlmrbyPclad+I+4mJ3A==", + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", + "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", "dev": true, "requires": { "argparse": "^1.0.7", @@ -976,9 +973,9 @@ } }, "lodash": { - "version": "4.17.11", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", - "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==", + "version": "4.17.15", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", + "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", "dev": true }, "lolex": { @@ -1109,13 +1106,13 @@ "integrity": "sha512-06LC4wHO+nyH0J07dUzFsZTVZMsMMKTkXo8BUTmuYbJhbsKX2cVDn2xADoFqjbnBYThVlGSlaM10CDyEi+48Iw==" }, "normalize-package-data": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", - "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", + "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==", "dev": true, "requires": { "hosted-git-info": "^2.1.4", - "is-builtin-module": "^1.0.0", + "resolve": "^1.10.0", "semver": "2 || 3 || 4 || 5", "validate-npm-package-license": "^3.0.1" } @@ -1179,9 +1176,9 @@ "dev": true }, "p-limit": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.0.0.tgz", - "integrity": "sha512-fl5s52lI5ahKCernzzIyAP0QAZbGIovtVHGwpcu1Jr/EpzLVDI2myISHwGqK7m8uQFugVWSrbxH7XnhGtvEc+A==", + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.2.1.tgz", + "integrity": "sha512-85Tk+90UCVWvbDavCLKPOLC9vvY8OwEX/RtKF+/1OADJMVlFfEHOiMTPVyxg7mk/dKa+ipdHm0OUkTvCpMTuwg==", "dev": true, "requires": { "p-try": "^2.0.0" @@ -1197,9 +1194,9 @@ } }, "p-try": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.0.0.tgz", - "integrity": "sha512-hMp0onDKIajHfIkdRk3P4CdCmErkYAxxDtP3Wx/4nZ3aGlau2VKh3mZpcuFkH27WQkL/3WBCPOktzA9ZOAnMQQ==", + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", "dev": true }, "parse-json": { @@ -1235,6 +1232,12 @@ "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=", "dev": true }, + "path-parse": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", + "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", + "dev": true + }, "pify": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", @@ -1251,9 +1254,9 @@ } }, "please-upgrade-node": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/please-upgrade-node/-/please-upgrade-node-3.1.1.tgz", - "integrity": "sha512-KY1uHnQ2NlQHqIJQpnh/i54rKkuxCEBx+voJIS/Mvb+L2iYd2NMotwduhKTMjfC1uKoX3VXOxLjIYG66dfJTVQ==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/please-upgrade-node/-/please-upgrade-node-3.2.0.tgz", + "integrity": "sha512-gQR3WpIgNIKwBMVLkpMUeR3e1/E1y42bqDQZfql+kDeXd8COYfM8PQA4X6y7a8u9Ua9FHmsrrmirW2vHs45hWg==", "dev": true, "requires": { "semver-compare": "^1.0.0" @@ -1341,6 +1344,15 @@ "resolve-from": "^1.0.0" } }, + "resolve": { + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.12.0.tgz", + "integrity": "sha512-B/dOmuoAik5bKcD6s6nXDCjzUKnaDvdkRyAk6rsmsKLipWj4797iothd7jmmUhWTfinVMU+wc56rYKsit2Qy4w==", + "dev": true, + "requires": { + "path-parse": "^1.0.6" + } + }, "resolve-from": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-1.0.1.tgz", @@ -1481,9 +1493,9 @@ } }, "spdx-correct": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.0.2.tgz", - "integrity": "sha512-q9hedtzyXHr5S0A1vEPoK/7l8NpfkFYTq6iCY+Pno2ZbdZR6WexZFtqeVGkGxW3TEJMN914Z55EnAGMmenlIQQ==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.1.0.tgz", + "integrity": "sha512-lr2EZCctC2BNR7j7WzJ2FpDznxky1sjfxvvYEyzxNyb6lZXHODmEoJeFu4JupYlkfha1KZpJyoqiJ7pgA1qq8Q==", "dev": true, "requires": { "spdx-expression-parse": "^3.0.0", @@ -1507,9 +1519,9 @@ } }, "spdx-license-ids": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.2.tgz", - "integrity": "sha512-qky9CVt0lVIECkEsYbNILVnPvycuEBkXoMFLRWsREkomQLevYhtRKC+R91a5TOAQ3bCMjikRwhyaRqj1VYatYg==", + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.5.tgz", + "integrity": "sha512-J+FWzZoynJEXGphVIS+XEh3kFSjZX/1i9gFBaWQcB+/tmpe2qUsSBABpcxqxnAxFdiUFEgAX1bjYGQvIZmoz9Q==", "dev": true }, "sprintf-js": { diff --git a/package.json b/package.json index 7f05bc2..c41f829 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "js-profiler", - "version": "1.24.0", + "version": "1.25.0", "description": "Javascript profiling tool and collection of performance profiles for various JavaScript built-ins.", "main": "./lib/index.js", "man": "./docs/js-profiler.1.gz", @@ -41,14 +41,14 @@ "license": "MIT", "dependencies": { "chalk": "^1.1.3", - "glob": "^7.1.3", + "glob": "^7.1.5", "node-getopt": "^0.2.4" }, "devDependencies": { "@haensl/eslint-config": "^1.3.0", "chai": "^3.5.0", "eslint": "^4.19.1", - "husky": "^1.2.0", + "husky": "^1.3.1", "mocha": "^5.2.0", "sinon": "^1.17.7", "sinon-chai": "^2.14.0" From 995ed7fa09aa3c2149647a3a047dd9bdfb0ed605 Mon Sep 17 00:00:00 2001 From: HP Dietz Date: Tue, 22 Oct 2019 17:58:16 +0200 Subject: [PATCH 2/2] 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])