Permalink
Browse files

readme hooray

  • Loading branch information...
1 parent 35ade46 commit 2b3cc21f362b57c14cfd407746d051e069368a24 @substack committed Jul 10, 2012
Showing with 112 additions and 13 deletions.
  1. +1 −6 example/ascend.js
  2. +1 −6 example/min.js
  3. +1 −1 example/rise_mod.js
  4. +109 −0 readme.markdown
View
@@ -1,10 +1,5 @@
var fort = require('../');
+var rows = [ { x : 5 }, { x : 3 }, { x : 2 }, { x : 9 } ];
-var rows = [
- { x : 5 },
- { x : 3 },
- { x : 2 },
- { x : 9 },
-];
var res = fort.ascend(rows, function (row) { return row.x });
console.dir(res);
View
@@ -1,10 +1,5 @@
var fort = require('../');
+var rows = [ { x : 5 }, { x : 3 }, { x : 2 }, { x : 9 } ];
-var rows = [
- { x : 5 },
- { x : 3 },
- { x : 2 },
- { x : 9 },
-];
var r = fort.min(rows, function (row) { return row.x });
console.dir(r);
View
@@ -1,5 +1,5 @@
var fort = require('../');
-
var xs = [ 3, 2, 4, 6, 2, 8, 1, 7 ];
+
var res = fort.rise(xs, function (x) { return x % 4 });
console.dir(res);
View
@@ -0,0 +1,109 @@
+# fort
+
+Sort, min, and max by a transform function.
+
+# example
+
+## minimum of some rows
+
+``` js
+var fort = require('fort');
+var rows = [ { x : 5 }, { x : 3 }, { x : 2 }, { x : 9 } ];
+
+var r = fort.min(rows, function (row) { return row.x });
+console.dir(r);
+```
+
+***
+
+```
+{ x: 2 }
+```
+
+## ascending rows
+
+``` js
+var fort = require('fort');
+var rows = [ { x : 5 }, { x : 3 }, { x : 2 }, { x : 9 } ];
+
+var res = fort.ascend(rows, function (row) { return row.x });
+console.dir(res);
+```
+
+***
+
+```
+[ { x: 2 }, { x: 3 }, { x: 5 }, { x: 9 } ]
+```
+
+## ascending modulo sort
+
+``` js
+var fort = require('fort');
+var xs = [ 3, 2, 4, 6, 2, 8, 1, 7 ];
+
+var res = fort.rise(xs, function (x) { return x % 4 });
+console.dir(res);
+```
+
+***
+
+```
+[ 4, 8, 1, 2, 6, 2, 3, 7 ]
+```
+
+# methods
+
+## fort.min(xs, f)
+
+Return the minimum value from the elements in `xs` after transforming by `f(x)`
+on each element `x` in `xs`.
+
+The return value will be from the original elements in `xs`, not the transformed
+set.
+
+## fort.max(xs, f)
+
+Return the minimum value from the elements in `xs` after transforming by `f(x)`
+on each element `x` in `xs`.
+
+The return value will be from the original elements in `xs`, not the transformed
+set.
+
+## fort.ascend(xs, f)
+
+Return the elements from `xs` sorted into ascending order after transforming by
+`f(x)` on each `x` element in `xs`.
+
+The return array will be comprised of the original elements from `xs`, not the
+transformed values from `f(x)`.
+
+## fort.descend(xs, f)
+
+Return the elements from `xs` sorted into descending order after transforming by
+`f(x)` on each `x` element in `xs`.
+
+The return array will be comprised of the original elements from `xs`, not the
+transformed values from `f(x)`.
+
+## fort.rise(xs, f)
+
+Alias for `fort.ascend()` that is more consistent with the fort theme of this
+module.
+
+## fort.fall(xs, f)
+
+Alias for `fort.descend()` that is more consistent with the fort theme of this
+module.
+
+# install
+
+With [npm](http://npmjs.org) do:
+
+```
+npm install fort
+```
+
+# license
+
+MIT

0 comments on commit 2b3cc21

Please sign in to comment.