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
identity, wrap, curry, _, partial, flip,
compose, pipe, variadic, unary, binary, ternary
Logical Functions
f_and, f_or, f_not, f_eq, f_neq
Numeric Functions
gt, lt, gte, lte, add, sub, mul, div, mod,
even, odd, min, max
Type Functions
deep_equal, type, is_type, instance_of
Array functions
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
md5, base64, base64url
File System Functions
exists, stat, read, readdir, read_stream, read_block, lines,
write, chdir, rm, rmdir
Object Functions
include/extend, merge, clone, pluck, property, delegate, bind, detach
String Functions
capitalize, title_case, camel_case, underscored,
dashed, plain_text, html_escape, w
Miscellaneous Functions
times, shell, sleep, timer, memoize, abort
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