npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@ericwhitedev/lcsts

v1.0.1

Published

Longest Common Subsequence in TypeScript

Readme

LcsTs — Longest Common Subsequence in TypeScript

LcsTs is a TypeScript implementation of the Longest Common Subsequence (LCS) algorithm. It compares two token sequences and returns correlated subsequences describing which runs are equal, inserted, or deleted.

Documentation

Full API reference is published at ericwhitedev.github.io/LcsTs.

To build the documentation locally:

npm run docs

Output is written to docs/api/. Open docs/api/index.html in a browser.

Quick Start

import { compare, createLcsSettings, CorrelationStatus } from '@ericwhitedev/lcsts';

const result = compare(
  ['the', 'quick', 'brown', 'fox'],
  ['the', 'slow', 'brown', 'dog'],
  createLcsSettings(),
);

for (const seq of result) {
  switch (seq.correlationStatus) {
    case CorrelationStatus.Equal:
      console.log('Equal:', seq.comparisonUnitList1!.map(t => t.getShortString()));
      break;
    case CorrelationStatus.Deleted:
      console.log('Deleted:', seq.comparisonUnitList1!.map(t => t.getShortString()));
      break;
    case CorrelationStatus.Inserted:
      console.log('Inserted:', seq.comparisonUnitList2!.map(t => t.getShortString()));
      break;
  }
}
// Equal:    ['the']
// Deleted:  ['quick']
// Inserted: ['slow']
// Equal:    ['brown']
// Deleted:  ['fox']
// Inserted: ['dog']

Custom Tokens

For advanced matching, subclass ComparisonUnitToken or use the built-in ComparisonUnitTokenRegex:

import {
  ComparisonUnitTokenString,
  ComparisonUnitTokenRegex,
  compare,
  createLcsSettings,
} from '@ericwhitedev/lcsts';

const tokens1 = [
  new ComparisonUnitTokenString('hello'),
  new ComparisonUnitTokenString('42'),
];

const tokens2 = [
  new ComparisonUnitTokenString('hello'),
  new ComparisonUnitTokenRegex(/^\d+$/),
];

const result = compare(tokens1, tokens2, createLcsSettings());
// Both tokens match — 'hello' === 'hello', and '42' matches /^\d+$/

Settings

Use createLcsSettings() to get sensible defaults, or pass overrides:

const settings = createLcsSettings({
  detailThreshold: 5,
  findCommonAtBeginning: true,
  findCommonAtEnd: true,
});

| Setting | Default | Description | |---|---|---| | detailThreshold | 3 | Minimum common-subsequence length to count as a match | | findCommonAtBeginning | true | Look for a common prefix before the full algorithm | | findCommonAtBeginningThreshold | 10 | Minimum prefix length to accept | | findCommonAtEnd | false | Look for a common suffix before the full algorithm | | findCommonAtEndThreshold | 10 | Minimum suffix length to accept | | fastFindSearchLength | 12 | Positions to scan during the fast-find optimisation | | fastFindSearchMatch | 6 | Consecutive matches required for fast-find to succeed |

License

MIT © Eric White