Added Gulp.js for compiling SCSS stylesheets
This commit is contained in:
25
node_modules/fast-levenshtein/LICENSE.md
generated
vendored
Normal file
25
node_modules/fast-levenshtein/LICENSE.md
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
(MIT License)
|
||||
|
||||
Copyright (c) 2013 [Ramesh Nair](http://www.hiddentao.com/)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation
|
||||
files (the "Software"), to deal in the Software without
|
||||
restriction, including without limitation the rights to use,
|
||||
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following
|
||||
conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
120
node_modules/fast-levenshtein/README.md
generated
vendored
Normal file
120
node_modules/fast-levenshtein/README.md
generated
vendored
Normal file
@ -0,0 +1,120 @@
|
||||
# fast-levenshtein - Levenshtein algorithm in Javascript
|
||||
|
||||
[](http://travis-ci.org/hiddentao/fast-levenshtein)
|
||||
|
||||
An efficient Javascript implementation of the [Levenshtein algorithm](http://en.wikipedia.org/wiki/Levenshtein_distance) with asynchronous callback support.
|
||||
|
||||
## Features
|
||||
|
||||
* Works in node.js and in the browser.
|
||||
* Better performance than other implementations by not needing to store the whole matrix ([more info](http://www.codeproject.com/Articles/13525/Fast-memory-efficient-Levenshtein-algorithm)).
|
||||
* Provides synchronous and asynchronous versions of the algorithm.
|
||||
* Asynchronous version is almost as fast as the synchronous version for small strings and can also provide progress updates.
|
||||
* Comprehensive test suite and performance benchmark.
|
||||
* Small: <1 KB minified and gzipped
|
||||
|
||||
## Installation
|
||||
|
||||
### node.js
|
||||
|
||||
Install using [npm](http://npmjs.org/):
|
||||
|
||||
```bash
|
||||
$ npm install fast-levenshtein
|
||||
```
|
||||
|
||||
### Browser
|
||||
|
||||
Using bower:
|
||||
|
||||
```bash
|
||||
$ bower install fast-levenshtein
|
||||
```
|
||||
|
||||
If you are not using any module loader system then the API will then be accessible via the `window.Levenshtein` object.
|
||||
|
||||
## Examples
|
||||
|
||||
**Synchronous**
|
||||
|
||||
```javascript
|
||||
var levenshtein = require('fast-levenshtein');
|
||||
|
||||
var distance = levenshtein.get('back', 'book'); // 2
|
||||
var distance = levenshtein.get('我愛你', '我叫你'); // 1
|
||||
```
|
||||
|
||||
**Asynchronous**
|
||||
|
||||
```javascript
|
||||
var levenshtein = require('fast-levenshtein');
|
||||
|
||||
levenshtein.getAsync('back', 'book', function (err, distance) {
|
||||
// err is null unless an error was thrown
|
||||
// distance equals 2
|
||||
});
|
||||
```
|
||||
|
||||
**Asynchronous with progress updates**
|
||||
|
||||
```javascript
|
||||
var levenshtein = require('fast-levenshtein');
|
||||
|
||||
var hugeText1 = fs.readFileSync(...);
|
||||
var hugeText2 = fs.readFileSync(...);
|
||||
|
||||
levenshtein.getAsync(hugeText1, hugeText2, function (err, distance) {
|
||||
// process the results as normal
|
||||
}, {
|
||||
progress: function(percentComplete) {
|
||||
console.log(percentComplete + ' % completed so far...');
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
## Building and Testing
|
||||
|
||||
To build the code and run the tests:
|
||||
|
||||
```bash
|
||||
$ npm install -g grunt-cli
|
||||
$ npm install
|
||||
$ npm run build
|
||||
```
|
||||
|
||||
## Performance
|
||||
|
||||
_Thanks to [Titus Wormer](https://github.com/wooorm) for [encouraging me](https://github.com/hiddentao/fast-levenshtein/issues/1) to do this._
|
||||
|
||||
Benchmarked against other node.js levenshtein distance modules (on Macbook Air 2012, Core i7, 8GB RAM):
|
||||
|
||||
```bash
|
||||
Running suite Implementation comparison [benchmark/speed.js]...
|
||||
>> levenshtein-edit-distance x 234 ops/sec ±3.02% (73 runs sampled)
|
||||
>> levenshtein-component x 422 ops/sec ±4.38% (83 runs sampled)
|
||||
>> levenshtein-deltas x 283 ops/sec ±3.83% (78 runs sampled)
|
||||
>> natural x 255 ops/sec ±0.76% (88 runs sampled)
|
||||
>> levenshtein x 180 ops/sec ±3.55% (86 runs sampled)
|
||||
>> fast-levenshtein x 1,792 ops/sec ±2.72% (95 runs sampled)
|
||||
Benchmark done.
|
||||
Fastest test is fast-levenshtein at 4.2x faster than levenshtein-component
|
||||
```
|
||||
|
||||
You can run this benchmark yourself by doing:
|
||||
|
||||
```bash
|
||||
$ npm install -g grunt-cli
|
||||
$ npm install
|
||||
$ npm run build
|
||||
$ npm run benchmark
|
||||
```
|
||||
|
||||
## Contributing
|
||||
|
||||
If you wish to submit a pull request please update and/or create new tests for any changes you make and ensure the grunt build passes.
|
||||
|
||||
See [CONTRIBUTING.md](https://github.com/hiddentao/fast-levenshtein/blob/master/CONTRIBUTING.md) for details.
|
||||
|
||||
## License
|
||||
|
||||
MIT - see [LICENSE.md](https://github.com/hiddentao/fast-levenshtein/blob/master/LICENSE.md)
|
211
node_modules/fast-levenshtein/levenshtein.js
generated
vendored
Normal file
211
node_modules/fast-levenshtein/levenshtein.js
generated
vendored
Normal file
@ -0,0 +1,211 @@
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Extend an Object with another Object's properties.
|
||||
*
|
||||
* The source objects are specified as additional arguments.
|
||||
*
|
||||
* @param dst Object the object to extend.
|
||||
*
|
||||
* @return Object the final object.
|
||||
*/
|
||||
var _extend = function(dst) {
|
||||
var sources = Array.prototype.slice.call(arguments, 1);
|
||||
for (var i=0; i<sources.length; ++i) {
|
||||
var src = sources[i];
|
||||
for (var p in src) {
|
||||
if (src.hasOwnProperty(p)) dst[p] = src[p];
|
||||
}
|
||||
}
|
||||
return dst;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Defer execution of given function.
|
||||
* @param {Function} func
|
||||
*/
|
||||
var _defer = function(func) {
|
||||
if (typeof setImmediate === 'function') {
|
||||
return setImmediate(func);
|
||||
} else {
|
||||
return setTimeout(func, 0);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Based on the algorithm at http://en.wikipedia.org/wiki/Levenshtein_distance.
|
||||
*/
|
||||
var Levenshtein = {
|
||||
/**
|
||||
* Calculate levenshtein distance of the two strings.
|
||||
*
|
||||
* @param str1 String the first string.
|
||||
* @param str2 String the second string.
|
||||
* @return Integer the levenshtein distance (0 and above).
|
||||
*/
|
||||
get: function(str1, str2) {
|
||||
// base cases
|
||||
if (str1 === str2) return 0;
|
||||
if (str1.length === 0) return str2.length;
|
||||
if (str2.length === 0) return str1.length;
|
||||
|
||||
// two rows
|
||||
var prevRow = new Array(str2.length + 1),
|
||||
curCol, nextCol, i, j, tmp;
|
||||
|
||||
// initialise previous row
|
||||
for (i=0; i<prevRow.length; ++i) {
|
||||
prevRow[i] = i;
|
||||
}
|
||||
|
||||
// calculate current row distance from previous row
|
||||
for (i=0; i<str1.length; ++i) {
|
||||
nextCol = i + 1;
|
||||
|
||||
for (j=0; j<str2.length; ++j) {
|
||||
curCol = nextCol;
|
||||
|
||||
// substution
|
||||
nextCol = prevRow[j] + ( (str1.charAt(i) === str2.charAt(j)) ? 0 : 1 );
|
||||
// insertion
|
||||
tmp = curCol + 1;
|
||||
if (nextCol > tmp) {
|
||||
nextCol = tmp;
|
||||
}
|
||||
// deletion
|
||||
tmp = prevRow[j + 1] + 1;
|
||||
if (nextCol > tmp) {
|
||||
nextCol = tmp;
|
||||
}
|
||||
|
||||
// copy current col value into previous (in preparation for next iteration)
|
||||
prevRow[j] = curCol;
|
||||
}
|
||||
|
||||
// copy last col value into previous (in preparation for next iteration)
|
||||
prevRow[j] = nextCol;
|
||||
}
|
||||
|
||||
return nextCol;
|
||||
},
|
||||
|
||||
/**
|
||||
* Asynchronously calculate levenshtein distance of the two strings.
|
||||
*
|
||||
* @param str1 String the first string.
|
||||
* @param str2 String the second string.
|
||||
* @param cb Function callback function with signature: function(Error err, int distance)
|
||||
* @param [options] Object additional options.
|
||||
* @param [options.progress] Function progress callback with signature: function(percentComplete)
|
||||
*/
|
||||
getAsync: function(str1, str2, cb, options) {
|
||||
options = _extend({}, {
|
||||
progress: null
|
||||
}, options);
|
||||
|
||||
// base cases
|
||||
if (str1 === str2) return cb(null, 0);
|
||||
if (str1.length === 0) return cb(null, str2.length);
|
||||
if (str2.length === 0) return cb(null, str1.length);
|
||||
|
||||
// two rows
|
||||
var prevRow = new Array(str2.length + 1),
|
||||
curCol, nextCol,
|
||||
i, j, tmp,
|
||||
startTime, currentTime;
|
||||
|
||||
// initialise previous row
|
||||
for (i=0; i<prevRow.length; ++i) {
|
||||
prevRow[i] = i;
|
||||
}
|
||||
|
||||
nextCol = 1;
|
||||
i = 0;
|
||||
j = -1;
|
||||
|
||||
var __calculate = function() {
|
||||
// reset timer
|
||||
startTime = new Date().valueOf();
|
||||
currentTime = startTime;
|
||||
|
||||
// keep going until one second has elapsed
|
||||
while (currentTime - startTime < 1000) {
|
||||
// reached end of current row?
|
||||
if (str2.length <= (++j)) {
|
||||
// copy current into previous (in preparation for next iteration)
|
||||
prevRow[j] = nextCol;
|
||||
|
||||
// if already done all chars
|
||||
if (str1.length <= (++i)) {
|
||||
return cb(null, nextCol);
|
||||
}
|
||||
// else if we have more left to do
|
||||
else {
|
||||
nextCol = i + 1;
|
||||
j = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// calculation
|
||||
curCol = nextCol;
|
||||
|
||||
// substution
|
||||
nextCol = prevRow[j] + ( (str1.charAt(i) === str2.charAt(j)) ? 0 : 1 );
|
||||
// insertion
|
||||
tmp = curCol + 1;
|
||||
if (nextCol > tmp) {
|
||||
nextCol = tmp;
|
||||
}
|
||||
// deletion
|
||||
tmp = prevRow[j + 1] + 1;
|
||||
if (nextCol > tmp) {
|
||||
nextCol = tmp;
|
||||
}
|
||||
|
||||
// copy current into previous (in preparation for next iteration)
|
||||
prevRow[j] = curCol;
|
||||
|
||||
// get current time
|
||||
currentTime = new Date().valueOf();
|
||||
}
|
||||
|
||||
// send a progress update?
|
||||
if (null !== options.progress) {
|
||||
try {
|
||||
options.progress.call(null, (i * 100.0/ str1.length));
|
||||
} catch (err) {
|
||||
return cb('Progress callback: ' + err.toString());
|
||||
}
|
||||
}
|
||||
|
||||
// next iteration
|
||||
_defer(__calculate);
|
||||
};
|
||||
|
||||
__calculate();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// amd
|
||||
if (typeof define !== "undefined" && define !== null && define.amd) {
|
||||
define(function() {
|
||||
return Levenshtein;
|
||||
});
|
||||
}
|
||||
// commonjs
|
||||
else if (typeof module !== "undefined" && module !== null && typeof exports !== "undefined" && module.exports === exports) {
|
||||
module.exports = Levenshtein;
|
||||
}
|
||||
// web worker
|
||||
else if (typeof self !== "undefined" && typeof self.postMessage === 'function' && typeof self.importScripts === 'function') {
|
||||
self.Levenshtein = Levenshtein;
|
||||
}
|
||||
// browser main thread
|
||||
else if (typeof window !== "undefined" && window !== null) {
|
||||
window.Levenshtein = Levenshtein;
|
||||
}
|
||||
}());
|
||||
|
37
node_modules/fast-levenshtein/package.json
generated
vendored
Normal file
37
node_modules/fast-levenshtein/package.json
generated
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
{
|
||||
"name": "fast-levenshtein",
|
||||
"version": "1.1.4",
|
||||
"description": "Efficient implementation of Levenshtein algorithm with asynchronous callback support",
|
||||
"main": "levenshtein.js",
|
||||
"files": [
|
||||
"levenshtein.js"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "grunt build",
|
||||
"benchmark": "grunt benchmark",
|
||||
"test": "mocha"
|
||||
},
|
||||
"devDependencies": {
|
||||
"chai": "~1.5.0",
|
||||
"grunt": "~0.4.1",
|
||||
"grunt-benchmark": "~0.2.0",
|
||||
"grunt-contrib-jshint": "~0.4.3",
|
||||
"grunt-contrib-uglify": "~0.2.0",
|
||||
"grunt-mocha-test": "~0.2.2",
|
||||
"grunt-npm-install": "~0.1.0",
|
||||
"load-grunt-tasks": "~0.6.0",
|
||||
"lodash": "^4.0.1",
|
||||
"mocha": "~1.9.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/hiddentao/fast-levenshtein.git"
|
||||
},
|
||||
"keywords": [
|
||||
"levenshtein",
|
||||
"distance",
|
||||
"string"
|
||||
],
|
||||
"author": "Ramesh Nair <ram@hiddentao.com> (http://www.hiddentao.com/)",
|
||||
"license": "MIT"
|
||||
}
|
Reference in New Issue
Block a user