Skip to content

Commit

Permalink
Rename to fidola
Browse files Browse the repository at this point in the history
  • Loading branch information
ikarienator committed May 16, 2013
1 parent 5fb54d2 commit 4abaaf2
Show file tree
Hide file tree
Showing 23 changed files with 198 additions and 215 deletions.
18 changes: 9 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ NODE_PATH ?= ./node_modules
JS_MINIFIER = $(NODE_PATH)/uglify-js/bin/uglifyjs
JS_BEAUTIFIER = $(NODE_PATH)/uglify-js/bin/uglifyjs -b -i 2 -nm -ns

all: fast.js fast.min.js
all: fidola.js fidola.min.js

fast.js: Makefile\
fidola.js: Makefile\
lib/*/*.js \
lib/*.js
@rm -f $@
@echo Building fast.js ...
browserify lib/browser.js -o fast.js
@echo Building fidola.js ...
browserify lib/browser.js -o fidola.js

fast.min.js: fast.js
fidola.min.js: fidola.js
@rm -f $@
@echo Building fast.min.js ...
@$(JS_MINIFIER) fast.js > fast.min.js
@echo Building fidola.min.js ...
@$(JS_MINIFIER) fidola.js > fidola.min.js

.PHONY: test cover

Expand All @@ -23,7 +23,7 @@ test: all

cover: all
@npm run-script coverage
@echo "\n\nOpen <fast-root>/coverage/lcov-report/index.html"
@echo "\n\nOpen <fidola-root>/coverage/lcov-report/index.html"

clean:
@rm -f fast.js fast.min.js
@rm -f fidola.js fidola.min.js
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#fast.js
# Fidola

[![Build Status](https://travis-ci.org/ikarienator/fast.js.png?branch=master)](https://travis-ci.org/ikarienator/fast.js)
[![Build Status](https://travis-ci.org/ikarienator/fidola.js.png?branch=master)](https://travis-ci.org/ikarienator/fidola.js)

A simple, tested javascript algorithm library for node.js and browser.
This project is currently under development.
Expand Down
2 changes: 0 additions & 2 deletions fast.min.js

This file was deleted.

101 changes: 42 additions & 59 deletions fast.js → fidola.js
Original file line number Diff line number Diff line change
Expand Up @@ -391,20 +391,20 @@ process.binding = function (name) {

});

require.define("/fast.js",function(require,module,exports,__dirname,__filename,process,global){/**
* @namespace fast
require.define("/fidola.js",function(require,module,exports,__dirname,__filename,process,global){/**
* @namespace fidola
*/
var fast = exports;
var fidola = exports;
function includes(module, exp) {
for (var symbol in exp) {
module[symbol] = exp[symbol];
}
}

/**
* @namespace fast.seq
* @namespace fidola.seq
*/
var seq = fast.seq = {};
var seq = fidola.seq = {};
includes(seq, require("./sequence/BinarySearch"));
includes(seq, require("./sequence/KMP"));
includes(seq, require("./sequence/LCS"));
Expand All @@ -413,9 +413,9 @@ includes(seq, require("./sequence/LIS"));
includes(seq, require("./sequence/Shuffle"));

/**
* @namespace fast.ds
* @namespace fidola.ds
*/
var ds = fast.ds = {};
var ds = fidola.ds = {};
includes(ds, require("./datastructure/BinaryHeap.js"));
includes(ds, require("./datastructure/CartesianTree.js"));
includes(ds, require("./datastructure/RedBlackTree.js"));
Expand All @@ -424,17 +424,17 @@ includes(ds, require("./datastructure/LinkedList.js"));
includes(ds, require("./datastructure/ImmutableArray.js"));

/**
* @namespace fast.nt
* @namespace fidola.nt
*/
var nt = fast.nt = {};
var nt = fidola.nt = {};
includes(nt, require("./numbertheory/Basics.js"));
includes(nt, require("./numbertheory/PrimalityTest.js"));
includes(nt, require("./numbertheory/FNTT.js"));

/**
* @namespace fast.numeric
* @namespace fidola.numeric
*/
var numeric = fast.numeric = {};
var numeric = fidola.numeric = {};
includes(numeric, require("./numeric/FastFourierTransform.js"));
includes(numeric, require("./numeric/CubicPolynomialSolver.js"));
});
Expand Down Expand Up @@ -1750,8 +1750,8 @@ exports.RedBlackTreeNode = RedBlackTreeNode;
exports.RedBlackTree = RedBlackTree;
});

require.define("/datastructure/BinarySearchTree.js",function(require,module,exports,__dirname,__filename,process,global){var fast = require('../fast'),
RedBlackTree = fast.ds.RedBlackTree,
require.define("/datastructure/BinarySearchTree.js",function(require,module,exports,__dirname,__filename,process,global){var fidola = require('../fidola'),
RedBlackTree = fidola.ds.RedBlackTree,
RedBlackTreeNode = RedBlackTree.NODE_TYPE;

/**
Expand Down Expand Up @@ -2110,6 +2110,13 @@ ImmutableArray.prototype = {
return this.foldRight(array, concatFoldRight_);
},

/**
* Get the nth element in the list.
* This is a slow operation.
*
* @param n Index of the element.
* @returns {*}
*/
get: function (n) {
if (n == 0) {
return this.head();
Expand All @@ -2121,6 +2128,7 @@ ImmutableArray.prototype = {
},
/**
* Returns func(...func(func(z, get(0)), get(1)), get(2))... get(n))...).
*
* @param {*} z
* @param {Function} func
* @returns {*}
Expand All @@ -2136,6 +2144,7 @@ ImmutableArray.prototype = {

/**
* Returns: func(get(0), func(get(1), func(get(2), ... get(n), z))...).
*
* @param {*} z
* @param {Function} func
*/
Expand All @@ -2153,9 +2162,9 @@ ImmutableArray.prototype = {
},

/**
*
* @param func
* @returns {*}
* Apply <code>func</code> to all the elements and create an immutable array with the result.
* @param {Function} func
* @returns {ImmutableArray}
*/
map: function (func) {
return this.foldRight(null, function (el, res) {
Expand All @@ -2164,9 +2173,9 @@ ImmutableArray.prototype = {
},

/**
*
* @param func
* @returns {*}
* Create an immutable array only with elements that func(el) is true.
* @param {Function} func
* @returns {ImmutableArray}
*/
filter: function (func) {
return this.foldRight(null, function (el, res) {
Expand All @@ -2179,39 +2188,13 @@ ImmutableArray.prototype = {
},

/**
*
* @returns {*}
*/
reverse: function () {
return this.foldLeft(null, function (res, el) {
return new ImmutableArray(el, res);
});
},

/**
*
*
* @param func
* @returns {*}
*/
reverseMap: function (func) {
return this.foldLeft(null, function (res, el) {
return new ImmutableArray(func(el), res);
});
},

/**
*
* @param func
* @returns {*}
* Create an array of the elements in immutable array.
* @returns {Array}
*/
reverseFilter: function (func) {
return this.foldLeft(null, function (res, el) {
if (func(el)) {
return new ImmutableArray(el, res);
} else {
return res;
}
toArray: function () {
return this.foldLeft([], function (res, el) {
res.push(el);
return res;
});
}
};
Expand All @@ -2223,7 +2206,7 @@ exports.ImmutableArray = ImmutableArray;

require.define("/numbertheory/Basics.js",function(require,module,exports,__dirname,__filename,process,global){/**
* Greatest common divisor of two integers
* @name fast.nt.gcd
* @name fidola.nt.gcd
* @param {Number} a
* @param {Number} b
* @returns {Number}
Expand Down Expand Up @@ -2280,7 +2263,7 @@ function gcd(a, b) {

/**
* Returns a * b % n concerning interger overflow.
* @name fast.nt.multMod
* @name fidola.nt.multMod
* @param {Number} a
* @param {Number} b
* @param {Number} n
Expand Down Expand Up @@ -2312,7 +2295,7 @@ function multMod(a, b, n) {
/**
* Returns pow(a,b) % n with exponentiation by squaring
* algorithm.
* @name fast.nt.powerMod
* @name fidola.nt.powerMod
* @param {Number} a
* @param {Number} b
* @param {Number} n
Expand Down Expand Up @@ -2347,7 +2330,7 @@ exports.powerMod = powerMod;
exports.multMod = multMod;
});

require.define("/numbertheory/PrimalityTest.js",function(require,module,exports,__dirname,__filename,process,global){var fast = require('../fast');
require.define("/numbertheory/PrimalityTest.js",function(require,module,exports,__dirname,__filename,process,global){var fidola = require('../fidola');
/**
* Miller-Rabin Primality Test with base a, odd index d and modular n,
* and n = 2^s * d.
Expand All @@ -2358,15 +2341,15 @@ require.define("/numbertheory/PrimalityTest.js",function(require,module,exports,
* @returns {boolean}
*/
function millerRabinPrimalityTest(a, s, d, n) {
var c = fast.nt.powerMod(a, d, n);
var c = fidola.nt.powerMod(a, d, n);
if (c === 1) {
return true;
}
for (var r = 0; r < s; r++) {
if (c === n - 1) {
return true;
}
c = fast.nt.multMod(c, c, n);
c = fidola.nt.multMod(c, c, n);
}
return false;
}
Expand Down Expand Up @@ -2416,7 +2399,7 @@ function primeQ(small_number) {
preparePrimes();
}
if (small_number < 1048576) {
return fast.seq.binarySearch(SMALL_PRIMES, small_number) !== -1;
return fidola.seq.binarySearch(SMALL_PRIMES, small_number) !== -1;
}
if ((small_number & 1) == 0) {
return false;
Expand Down Expand Up @@ -2845,7 +2828,7 @@ exports.quadraticFunction = quadraticFunction;
exports.cubicFunction = cubicFunction;
});

require.define("/browser.js",function(require,module,exports,__dirname,__filename,process,global){global.fast = require("./fast.js");
require.define("/browser.js",function(require,module,exports,__dirname,__filename,process,global){global.fidola = require("./fidola.js");
});
require("/browser.js");
})();
2 changes: 2 additions & 0 deletions fidola.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
exports = require('./lib/fast.js');
exports = require('./lib/fidola.js');
2 changes: 1 addition & 1 deletion lib/browser.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
global.fast = require("./fast.js");
global.fidola = require("./fidola.js");
4 changes: 2 additions & 2 deletions lib/datastructure/BinarySearchTree.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var fast = require('../fast'),
RedBlackTree = fast.ds.RedBlackTree,
var fidola = require('../fidola'),
RedBlackTree = fidola.ds.RedBlackTree,
RedBlackTreeNode = RedBlackTree.NODE_TYPE;

/**
Expand Down
20 changes: 10 additions & 10 deletions lib/fast.js → lib/fidola.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/**
* @namespace fast
* @namespace fidola
*/
var fast = exports;
var fidola = exports;
function includes(module, exp) {
for (var symbol in exp) {
module[symbol] = exp[symbol];
}
}

/**
* @namespace fast.seq
* @namespace fidola.seq
*/
var seq = fast.seq = {};
var seq = fidola.seq = {};
includes(seq, require("./sequence/BinarySearch"));
includes(seq, require("./sequence/KMP"));
includes(seq, require("./sequence/LCS"));
Expand All @@ -20,9 +20,9 @@ includes(seq, require("./sequence/LIS"));
includes(seq, require("./sequence/Shuffle"));

/**
* @namespace fast.ds
* @namespace fidola.ds
*/
var ds = fast.ds = {};
var ds = fidola.ds = {};
includes(ds, require("./datastructure/BinaryHeap.js"));
includes(ds, require("./datastructure/CartesianTree.js"));
includes(ds, require("./datastructure/RedBlackTree.js"));
Expand All @@ -31,16 +31,16 @@ includes(ds, require("./datastructure/LinkedList.js"));
includes(ds, require("./datastructure/ImmutableArray.js"));

/**
* @namespace fast.nt
* @namespace fidola.nt
*/
var nt = fast.nt = {};
var nt = fidola.nt = {};
includes(nt, require("./numbertheory/Basics.js"));
includes(nt, require("./numbertheory/PrimalityTest.js"));
includes(nt, require("./numbertheory/FNTT.js"));

/**
* @namespace fast.numeric
* @namespace fidola.numeric
*/
var numeric = fast.numeric = {};
var numeric = fidola.numeric = {};
includes(numeric, require("./numeric/FastFourierTransform.js"));
includes(numeric, require("./numeric/CubicPolynomialSolver.js"));
6 changes: 3 additions & 3 deletions lib/numbertheory/Basics.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Greatest common divisor of two integers
* @name fast.nt.gcd
* @name fidola.nt.gcd
* @param {Number} a
* @param {Number} b
* @returns {Number}
Expand Down Expand Up @@ -57,7 +57,7 @@ function gcd(a, b) {

/**
* Returns a * b % n concerning interger overflow.
* @name fast.nt.multMod
* @name fidola.nt.multMod
* @param {Number} a
* @param {Number} b
* @param {Number} n
Expand Down Expand Up @@ -89,7 +89,7 @@ function multMod(a, b, n) {
/**
* Returns pow(a,b) % n with exponentiation by squaring
* algorithm.
* @name fast.nt.powerMod
* @name fidola.nt.powerMod
* @param {Number} a
* @param {Number} b
* @param {Number} n
Expand Down
Loading

0 comments on commit 4abaaf2

Please sign in to comment.