fairmont

A collection of useful functions and utilities.

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.

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.

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.

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"

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.

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

Fairmont is still under heavy development and is alpha quality, meaning you should probably not use it in your production code.

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