String Lerp is a JavaScript module to interpolate (lerp, blend, tween) between two string values, that is, progressively turn one string into another. It uses Levenshtein distance measurements along with other heuristics to try to blend between two strings as naturally as possible.
- string-lerp-1.0.0.tar.gz (16KB)
- npm install string-lerp
- git clone http://git.yukkurigames.com/string-lerp.git
Not really sure what that means? Try it out.
API
In a browser, use
<script type="text/javascript" src="string-lerp.js"></script>
In Node.js and other non-browser environments,
var stringLerp = require("./string-lerp")
Then,
var result = stringLerp.lerp(source, target, amount);
// `source' is the string to start with
// `target' is the string to finish with
// `amount' is an amount to edit the strings, between 0 and 1,
// e.g. 0.23 = 23% from source to target
The internal diff
and patch
routines
are also exposed, as diffLerp
is too slow for
very long strings unless you compute and store the diff list
ahead of time.
License
String Lerp is free software. You can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.