Skip to content

Commit

Permalink
chore: use impersonal language
Browse files Browse the repository at this point in the history
  • Loading branch information
Fdawgs committed Jan 30, 2025
1 parent 58c6f7b commit 79b852c
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/automerge.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
2 changes: 1 addition & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -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
*
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
28 changes: 5 additions & 23 deletions test_resources/utils/bt-power-set.js
Original file line number Diff line number Diff line change
@@ -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(
Expand All @@ -15,38 +14,21 @@ 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,
currentSubSet,
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;
}

Expand Down

0 comments on commit 79b852c

Please sign in to comment.