← All reportsPublic report

trekhleb/javascript-algorithms

📝 Algorithms and data structures implemented in JavaScript with explanations and links to further readings

197k stars JavaScript View on GitHubprofiled 11d ago
Try GitZoid
3PRs this week
1Contributors
630Deps scanned
6Issues found
01 · Repo overview

How javascript-algorithms is put together

This is an educational library of algorithms and data structures implemented in plain JavaScript (ES modules under src/), organized as a flat catalog rather than an application: there are no servers, routes, or datastores. Each algorithm/data structure lives in its own directory containing the implementation file(s), a README with explanations in many languages, and Jest tests (matched via /__tests__/ patterns). Shared infrastructure consists of a Comparator utility, a base Sort class with a SortTester harness, and tooling configured through package.json, .babelrc, .eslintrc, and jest.config.js.

Languages

JavaScript

Frameworks

JestBabelESLint (airbnb config)Husky

Infrastructure

GitHub Actions CI (badge referenced in README)Codecov coverage reportingNode.js >=22 runtime requirement (.nvmrc present)

Major components

Data structures catalog (src/data-structures)

Implements linked lists, deque, stack, queue, hash table, heap/priority queue, trie, trees (BST/AVL/red-black/segment/Fenwick), graph, disjoint set, bloom filter, and LRU cache as standalone classes.

Graph algorithms (src/algorithms/graph)

Provides traversal (DFS/BFS), cycle detection, topological sorting, shortest paths (Dijkstra, Bellman-Ford, Floyd-Warshall), MST (Kruskal, Prim), articulation points, bridges, Eulerian/Hamiltonian paths, and strongly connected components.

Sorting framework (src/algorithms/sorting)

Defines a base Sort class wrapping a Comparator plus a SortTester harness that all sorting implementations share.

Math algorithms (src/algorithms/math)

Bit manipulation, number theory (factorial, primes, GCD/LCM, sieve), matrix operations, fast powering, Horner's method, and Fourier transform implementations.

String & set algorithms (src/algorithms/string, src/algorithms/sets)

Substring search (KMP, Z, Rabin-Karp), edit distance, palindromes, permutations/combinations, knapsack, LCS/LIS/SCS, and maximum subarray.

Cryptography demos (src/algorithms/cryptography)

Classical cipher demonstrations (Caesar, Hill, rail fence) and polynomial hashing used by string-search algorithms.

Search & tree traversal (src/algorithms/search, src/algorithms/tree)

Linear, jump, binary, and interpolation search plus DFS/BFS tree traversals.

Shared utilities (src/utils/comparator)

Comparator abstraction enabling custom comparison functions across heaps, sorts, graphs, and other structures.

02 · Weekly changes

README cleanup: backers section removed and links added to the project's satellite apps for thinking and drawing.

1 weeksWeek of 2026-07-20

This week's activity on the javascript-algorithms repository focused on housekeeping and promotion rather than new algorithms. The project removed its Project Backers section from the README and added links to two companion apps, 'thinking' and 'drawing', helping readers discover related tools.

Docs

Removed Project Backers section

The list of financial supporters was taken out of the project's main documentation page.

Docs

Added links to satellite apps (thinking)

A link to the companion 'thinking' app was added so visitors can explore related learning tools.

Docs

Added links to satellite apps (drawing)

A link to the companion 'drawing' app was added alongside the thinking app link.

03 · Security check

Dependencies and code review

630 dependencies scanned

Dependency advisories

Security Watch

6 vulnerable packages (12 advisories) across 630 scanned dependencies.

warninghigh · npmfixed in 7.29.4

@babel/plugin-transform-modules-systemjs 7.29.0

1 advisory. Fixed in 7.29.4.

How it can be abusedThis Babel plugin runs during builds and tests and turns source files into different JavaScript. If an attacker could get a crafted file compiled here, the output could contain code that was never in the input. In practice this library only compiles its own trusted algorithm files, so only developers building or testing untrusted third-party JavaScript would be exposed.

  • highGHSA-fv7c-fp4j-7gwp@babel/plugin-transform-modules-systemjs generates arbitrary code when compiling malicious input
warninghigh · npmfixed in 5.0.7

brace-expansion 2.0.2

3 advisories. Fixed in 5.0.7.

How it can be abusedbrace-expansion turns patterns like {a,b} into lists of strings. An attacker who can feed a crafted pattern to it could make expansion take huge amounts of time or memory and crash the process. In this project it only comes in indirectly through test tooling like glob/minimatch during development, so anyone running tests on trusted files could be slowed or crashed, but no real application code uses it.

  • highGHSA-3jxr-9vmj-r5cpbrace-expansion: DoS via exponential-time expansion of consecutive non-expanding {} groups
  • highGHSA-mh99-v99m-4gvgbrace-expansion: DoS via unbounded expansion length causing an out-of-memory process crash
  • highGHSA-rgw5-rvv9-x895brace-expansion: DoS via unbounded intermediate arrays, bypassing the CVE-2026-14257 mitigation
warninghigh · npmfixed in 3.4.0

flatted 3.3.3

2 advisories. Fixed in 3.4.0.

How it can be abusedThis package parses serialized data, and a crafted input could crash the process through runaway recursion or sneak properties onto core JavaScript objects. In this repo it only matters if flatted is actually used to parse untrusted input, which an offline algorithm catalog with no servers or user data does not do, so real users of the library are not meaningfully affected.

warninghigh · npmfixed in 3.15.0

js-yaml 3.14.2

2 advisories. Fixed in 3.15.0.

How it can be abusedAn attacker would need to feed this project a maliciously crafted YAML file so that parsing it burns excessive CPU and slows the machine down. Since this is an educational library that never parses YAML from users, the flaw only matters to developers running its own test tooling, not to anyone using the library.

  • highGHSA-52cp-r559-cp3mjs-yaml: YAML merge-key chains can force quadratic CPU consumption
  • highGHSA-5p4m-2wfm-xmqjJS-YAML: Quadratic CPU consumption in !!omap resolution (3.x and 4.x) — CVE-2026-59870 fix not backported
warninghigh · npmfixed in 10.2.3

minimatch 9.0.5

3 advisories. Fixed in 10.2.3.

How it can be abusedAn attacker could send a crafted filename or pattern that makes minimatch hang while matching, freezing whatever process calls it. Here the library is only used indirectly by test tooling on local files, so no untrusted input reaches it and real users are not affected.

  • highGHSA-23c5-xmqv-rm74minimatch ReDoS: nested *() extglobs generate catastrophically backtracking regular expressions
  • highGHSA-3ppc-4f35-3m26minimatch has a ReDoS via repeated wildcards with non-matching literal in pattern
  • highGHSA-7r86-cg39-jmmjminimatch has ReDoS: matchOne() combinatorial backtracking via multiple non-adjacent GLOBSTAR segments
warninghigh · npmfixed in 4.0.4

picomatch 4.0.3

1 advisory. Fixed in 4.0.4.

How it can be abusedAn attacker could send a specially crafted file-matching pattern that makes picomatch hang and burn CPU, freezing whatever process runs the matching. Here the library is only used by developer tools like Jest to match test files, so only someone running tests with attacker-supplied patterns would be affected.

Code review

No concrete code-level issues confirmed.

Get this report every week for your repos.

GitZoid learns each repo, reports what changed, and flags what needs attention. One flat price for the whole team.

$19 a month, flat · First 10 outputs free · No card required