fast-diff is a JavaScript utility for computing fast text differences between two strings. It is a simplified port of Google's `diff-match-patch` library, specifically optimized for diffing and excluding the match and patch functionalities. The library implements "An O(ND) Difference Algorithm and its Variations" (Myers, 1986) with additional optimizations. The current stable version is 1.3.0, released in October 2020. Its primary differentiator is its focus on high-performance string diffing without the overhead of pattern matching or patching, making it suitable for scenarios where only the differences are needed. The project has an infrequent release cadence, primarily focusing on stability rather than active feature development, as it's a mature port of a well-established algorithm.
npm install fast-diffVerified import paths — ran on the pinned version, not inferred.
Demonstrates basic string diffing, including the optional cursor position parameter, and usage of the exported constants.
For matching or patching, consider using the full `diff-match-patch` library or another diff/patch specific package.
Evaluate if the current feature set meets your needs. For very new JavaScript features or active development, you might need to seek more recently maintained alternatives.
For `fast-diff`, use `import diff from 'fast-diff';` for the default function. If issues persist, ensure your `tsconfig.json` (for TypeScript) or bundler config is set up to correctly handle interop between CJS and ESM modules. In some specific setups, `import * as diff from 'fast-diff'; console.log(diff.default(...));` might be necessary, though less idiomatic.
Use a default import: `import diff from 'fast-diff';`. If you are in a CommonJS module, use `const diff = require('fast-diff');`.The `fast-diff` library only provides the diffing functionality. If you require `match` or `patch` operations, you need to use the original `diff-match-patch` library or an alternative that includes those features.
No dependency data recorded yet.