diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 89eefb9..7fda621 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -24,7 +24,7 @@ updates: - "eslint*" ignore: # Below are dependencies that have migrated to ESM - # in their next major version so we can't use them + # in their next major version so they cannot be updated - dependency-name: is-html update-types: ["version-update:semver-major"] open-pull-requests-limit: 20 diff --git a/.github/workflows/automerge.yml b/.github/workflows/automerge.yml index e61c010..cff7766 100644 --- a/.github/workflows/automerge.yml +++ b/.github/workflows/automerge.yml @@ -1,7 +1,7 @@ name: Automerge Dependabot PRs # **What it does**: Automatically merge Dependabot PRs that pass the CI workflow run. -# **Why we have it**: To keep our dependencies up-to-date, to avoid security issues. +# **Why we have it**: Keeps dependencies up-to-date, to avoid security issues. on: workflow_run: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 75060c5..fa305fa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,7 +1,7 @@ name: CI -# **What it does**: Runs our tests. -# **Why we have it**: We want our tests to pass before merging code. +# **What it does**: Runs tests. +# **Why we have it**: Ensures tests pass before merging code. on: push: diff --git a/.npmignore b/.npmignore index a3591c8..bdf7371 100644 --- a/.npmignore +++ b/.npmignore @@ -1,4 +1,4 @@ -# `package.json` is published to npm, so everything we add is included in the installed tarball. +# `package.json` is published to npm, so everything added is included in the installed tarball. # Removing the `files` key and replacing it with this `.npmignore` saves some bytes, which # should improve installation performance slightly * diff --git a/README.md b/README.md index 0079073..6b2216b 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ npm i node-unrtf ### Linux and macOS/Darwin support -For Linux and Mac users, you will need to download the `unrtf` binary separately. +For Linux and Mac users, the `unrtf` binary will need to be installed separately. An example of downloading the binary on a Debian system: diff --git a/test_resources/utils/bt-power-set.js b/test_resources/utils/bt-power-set.js index 03dbfec..f16b179 100644 --- a/test_resources/utils/bt-power-set.js +++ b/test_resources/utils/bt-power-set.js @@ -1,12 +1,11 @@ "use strict"; /** - * @description Bitwise power-set function, adapted from algorithm at - * https://github.com/trekhleb/javascript-algorithms/blob/master/src/algorithms/sets/power-set/btPowerSet.js. + * @description Generates the power set of a given set using a recursive backtracking approach. * @param {*[]} originalSet - Original set of elements we are forming power-set of. - * @param {*[][]} allSubsets - All subsets that have been formed so far. - * @param {*[]} currentSubSet - Current subset that we are forming at the moment. - * @param {number} startAt - The position in original set we are starting to form current subset. + * @param {*[][]} [allSubsets] - All subsets that have been formed so far. Used internally for recursion. + * @param {*[]} [currentSubSet] - The current subset being formed. Used internally for recursion. + * @param {number} [startAt] - The position in the original set from which to start forming the current subset. * @returns {*[][]} All subsets of original set. */ function btPowerSetRecursive( @@ -15,26 +14,10 @@ function btPowerSetRecursive( currentSubSet = [], startAt = 0 ) { - /** - * Let's iterate over originalSet elements that may be added to the subset - * without having duplicates. The value of startAt prevents adding the duplicates. - */ for (let position = startAt; position < originalSet.length; position += 1) { - // Let's push current element to the subset currentSubSet.push(originalSet[position]); - - /** - * Current subset is already valid so let's memorize it. - * We do array destruction here to save the clone of the currentSubSet. - * We need to save a clone since the original currentSubSet is going to be - * mutated in further recursive calls. - */ allSubsets.push([...currentSubSet]); - /** - * Let's try to generate all other subsets for the current subset. - * We're increasing the position by one to avoid duplicates in subset. - */ btPowerSetRecursive( originalSet, allSubsets, @@ -42,11 +25,10 @@ function btPowerSetRecursive( position + 1 ); - // BACKTRACK. Exclude last element from the subset and try the next valid one + // Backtrack the current subset currentSubSet.pop(); } - // Return all subsets of a set return allSubsets; }