Sha256: 4aa4e084defc8cac474b8d6da831ef6cfdc746883d4b560a7ff8afbf0d45eb9f

Contents?: true

Size: 686 Bytes

Versions: 11

Compression:

Stored size: 686 Bytes

Contents

'use strict';
var arr = [];
var charCodeCache = [];

module.exports = function (a, b) {
	if (a === b) {
		return 0;
	}

	var aLen = a.length;
	var bLen = b.length;

	if (aLen === 0) {
		return bLen;
	}

	if (bLen === 0) {
		return aLen;
	}

	var bCharCode;
	var ret;
	var tmp;
	var tmp2;
	var i = 0;
	var j = 0;

	while (i < aLen) {
		charCodeCache[i] = a.charCodeAt(i);
		arr[i] = ++i;
	}

	while (j < bLen) {
		bCharCode = b.charCodeAt(j);
		tmp = j++;
		ret = j;

		for (i = 0; i < aLen; i++) {
			tmp2 = bCharCode === charCodeCache[i] ? tmp : tmp + 1;
			tmp = arr[i];
			ret = arr[i] = tmp > ret ? tmp2 > ret ? ret + 1 : tmp2 : tmp2 > tmp ? tmp + 1 : tmp2;
		}
	}

	return ret;
};

Version data entries

11 entries across 11 versions & 4 rubygems

Version Path
ilog-0.4.1 node_modules/leven/index.js
ilog-0.4.0 node_modules/leven/index.js
ilog-0.3.3 node_modules/leven/index.js
xcodebuild-helper-1.2.5 externals/ios-sim-master/node_modules/leven/index.js
xcodebuild-helper-1.2.3 externals/ios-sim-master/node_modules/leven/index.js
es6_tilt-0.1.2 test/dummy/app/assets/javascripts/node_modules/leven/index.js
es6_tilt-0.1.1 test/dummy/app/assets/javascripts/node_modules/leven/index.js
es6_tilt-0.1.0 test/dummy/app/assets/javascripts/node_modules/leven/index.js
gulp_assets-1.0.0.pre.5 template/node_modules/babel-core/node_modules/leven/index.js
gulp_assets-1.0.0.pre.4 template/node_modules/babel-core/node_modules/leven/index.js
gulp_assets-1.0.0.pre.3 template/node_modules/babel-core/node_modules/leven/index.js