Comparing version 1.0.0-alpha-07 to 1.0.0-alpha-08
@@ -9,3 +9,3 @@ // Generated by CoffeeScript 1.9.1 | ||
describe("Functional programming functions", function(context) { | ||
var _, binary, compose, curry, deep_equal, flip, identity, no_op, partial, pipe, ternary, unary, variadic, wrap; | ||
var _, async, binary, compose, curry, deep_equal, flip, identity, no_op, partial, pipe, promise, ternary, unary, variadic, wrap; | ||
deep_equal = function(a, b) { | ||
@@ -132,14 +132,16 @@ assert = require("assert"); | ||
}); | ||
promise = require("when"); | ||
async = require("./generator").async; | ||
compose = function() { | ||
var f, fx, g, i; | ||
fx = 2 <= arguments.length ? slice.call(arguments, 0, i = arguments.length - 1) : (i = 0, []), f = arguments[i++]; | ||
if (fx.length !== 0) { | ||
if (fx.length === 0) { | ||
return f; | ||
} else { | ||
g = compose.apply(null, fx); | ||
return function() { | ||
return async(function*() { | ||
var ax; | ||
ax = 1 <= arguments.length ? slice.call(arguments, 0) : []; | ||
return g(f.apply(null, ax)); | ||
}; | ||
} else { | ||
return f; | ||
return (yield promise(g((yield promise(f.apply(null, ax)))))); | ||
}); | ||
} | ||
@@ -146,0 +148,0 @@ }; |
@@ -103,5 +103,6 @@ // Generated by CoffeeScript 1.9.1 | ||
include(module.exports, require("./object")); | ||
return include(module.exports, require("./string")); | ||
include(module.exports, require("./string")); | ||
return include(module.exports, require("./generator")); | ||
}); | ||
}).call(this); |
{ | ||
"name": "fairmont", | ||
"version": "1.0.0-alpha-07", | ||
"version": "1.0.0-alpha-08", | ||
"description": "A collection of useful functions and utilities.", | ||
@@ -5,0 +5,0 @@ "files": [ |
# Fairmont | ||
A collection of useful CoffeeScript/JavaScript functions. These include functions to help with functional programming, arrays, objects, and more. Fairmont is inspired by [Underscore][100], [EssentialJS][110], and [prelude.coffee][120]. | ||
A collection of useful JavaScript functions to support a functional style of programming that takes advantage of ES6 features like iterators, generators, and promises. Fairmont is inspired by [Underscore][100], [EssentialJS][110], and [prelude.coffee][120]. | ||
@@ -11,25 +11,21 @@ [100]:http://underscorejs.org/ | ||
Fairmont offers a combination of features we couldn't find in existing libraries: | ||
Fairmont offers a combination of features we couldn't find in existing libraries. In particular, we wanted: | ||
* Functional programming friendly | ||
* ES6 aware (in particular, uses promises and generators for async operations) | ||
* Comprehensive | ||
* To use a functional programming style, even when performing asynchronous operations… | ||
Fairmont is also a literate programming project—the documentation, code, examples, and tests are together, making it easy to see what a function does, how it does it, and why it does it that particular way. | ||
* While coming as close to inline code for performance as possible (read: use lazy evaluation when working with collections)… | ||
### Functional Programming Friendly | ||
* Taking full-advantage of ES6 features like iterators, generators, and promises, which offer powerful new ways of doing things | ||
Fairmont is built on a functional programming foundation, including implementations for currying, partial application, and composition. Most functions are curried by default and designed with composition in mind. | ||
For example, here's how we would define a function that takes a path and returns a content-addressable dictionary of the files it contains. | ||
### ES6 Aware | ||
Fairmont wraps common asynchronous operations so they can be used in `yield` expressions. For example, here's how you can read a file using Fairmont. | ||
```coffee | ||
content = yield read "war-and-peace.txt" | ||
content_map = async (path) -> | ||
paths = collect map (compose resolve, join path), yield readdir path | ||
assoc zip (map (compose md5, read), paths), paths | ||
``` | ||
### Comprehensive | ||
We've seamlessly integrated asychronous functions with synchronous functions, even when doing composition. Behind the scenes we're using iterators to avoid multiple passes across the data. We make two passes here, even though it appears that we're making five. | ||
One of the nice things about Underscore is that it offers a lot of useful functions. Many common tasks can be written entirely using Underscore functions. Fairmont has a similar ambition. While there's nothing wrong with specialized libraries, there are times when you just want a good Swiss Army Knife. | ||
Fairmont is also a literate programming project—the documentation, code, examples, and tests are together, making it easy to see what a function does, how it does it, and why it does it that particular way. | ||
@@ -36,0 +32,0 @@ ## List of Functions |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
86406
28
1591
171