Giter Site home page Giter Site logo

fast-diff's People

Contributors

dgreensp avatar dmonad avatar jhchen avatar luin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fast-diff's Issues

Editing position does not work correctly in 1.2.0

In 1.1.2 it works correctly:

node -e 'console.log(require(".")("aaaaa", "aaaa", 1))'
[ [ 0, 'a' ], [ -1, 'a' ], [ 0, 'aaa' ] ]

In 1.2.0 it does not work correctly:

node -e 'console.log(require(".")("aaaaa", "aaaa", 1))'
[ [ -1, 'a' ], [ 0, 'aaaa' ] ]

There are likely more cases, where the editing position does not have the desired effect.

License

What license(s) is this piece of code released under?

Iterator version?

This library is awesome, but one thing it suffers from is huge memory consumption on large strings as the resulting array can be pretty gigantic. I would love a generator version that spits out small chunks instead of a giant result array.

I attempted this by myself but unicode and "cleanup" turned out to be out of my understanding.

See master...LiraNuna:fast-diff-iterator:master for my attempt.

Missing LICENSE file

Hi guys,
would you mind to add LICENSE.md file inside the repo root? Apache 2.0 requires to distribute license text along the source code and now there is none in repo and npm package, so it means that this code cannot be legally used by anyone.

So if you have a few minutes to add this https://www.apache.org/licenses/LICENSE-2.0 to the repository and release new patch version with the license, it would be really great.

Thank you

Support Symbols in the Astral Plane

Hi @jhchen,

I've been happily enjoying your fast-diff library in a custom editor that I'm building.

However, I came across an issue when trying to support code points outside of the BMP. In its current implementation fast-diff checks each JS "character" or "code unit". Being that ES5 JS iterates over code units rather than code points this creates issues with symbols outside the BMP.

A diff of two different string symbols such as "🐶" and "🐯" results in the first code unit matching and the second code unit non-matching. Thereby splitting up the surrogate pairs and potentially causing unwanted side effects.

Fast-Diff Produces:
[ [ 0, '�' ], [ -1, '�' ], [ 1, '�' ] ]

Rather than:
[ [ -1, '🐶' ], [ 1, '🐯' ] ]

I've modified your library to handle surrogate pairs as single "symbols". You can find my changes at fast-diff-astral. If you would like I can submit a pull request.

The method it uses is to break up the string into an array of symbols. Thereby allowing iteration over each symbol and full comparison of each surrogate pair as a single code point.

This may cause some extra overhead in terms of processing speed, which, along with the amount of changes, is why I broke it out into a separate library. That said, it still seems quick but I haven't tested the speed differences.

I've chosen to use a custom method to find and group surrogate pairs into an array rather than using the new ES6 String iterator methods. I did so only to avoid introducing a transpiler to the build process.

Hope you get a chance to look over it. Let me know if you'd like a pull request.

Cheers!

Refs: Great article by Mathias Bynens on JS unicode support, if you haven't already read it.

LICENSE file missing

Hi,

Could you please add a LICENSE file with your license text?
We need a plain text license file for our FOSS report.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.