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, EssentialJS, and prelude.coffee.
Why Fairmont?
Fairmont offers a combination of features we couldn't find in existing libraries:
- Functional programming friendly
- ES6 aware (in particular, uses promises and generators for async operations)
- Comprehensive
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.
Functional Programming Friendly
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.
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.
content = yield read "war-and-peace.txt"
Comprehensive
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.
List of Functions
Core Functions
-
API Reference
identity, wrap, curry, _, partial, flip,
compose, pipe, variadic, unary, binary, ternary
Logical Functions
Numeric Functions
-
API Reference
gt, lt, gte, lte, add, sub, mul, div, mod,
even, odd, min, max
Type Functions
Array functions
-
API Reference
fold, foldr, map, filter, any, all, each, cat, slice,
first, last, rest, take, leave, drop, includes, unique_by,
unique, uniq, flatten, dupes, union, intersection, remove, shuffle
Crypto Functions
File System Functions
-
API Reference
exists, stat, read, readdir, write, chdir, rm, rmdir
Object Functions
-
API Reference
include/extend, merge, clone, pluck, property, delegate, bind, detach
String Functions
-
API Reference
capitalize, title_case, camel_case, underscored,
dashed, plain_text, html_escape, w
Miscellaneous Functions
Status
Fairmont is still under heavy development and is alpha
quality, meaning you should probably not use it in your production code.
Roadmap
You can get an idea of what we're planning by looking at the issues list. If you want something that isn't there, and you think it would be a good addition, please open a ticket.
Our overarching goals for the project include:
-
Making the library more comprehensive
-
Improving the tests and documentation
-
Ensuring that we can use an FP style in real-world scenarios
-
Introducing an idiom for supporting lazy evaluation