node package manager
We need your input. Help make JavaScript better: Take the 2017 JavaScript Ecosystem survey ยป



Pointless is a library for working with values, arrays, objects, functions, and promises with a uniform interface and in a point-free style.

It does not provide any facilities for working with the DOM, but can be extended to do so via plugins.

Pointless is inspired by:

  • jQuery
  • Underscore
  • @raganwald
  • @domenic


P is the main function. It returns a Pointless object.

Pointless objects wrap values. The original value is accessible via the ._ property.

equal( P(42)._, 42 );

Pointless objects provide many methods for manipulating their values.

All methods available on Pointless objects are also available as "static" methods on the P function. These methods take in an unwrapped value as their first argument and return an unwrapped value. They are meant for quick application of a single Pointless method. To apply more than one Pointless method to a value, consider chaining off a Pointless object instead.


deepEqual( P([ 1, 2 ]).map(add1)._, [ 2, 3 ] );

function add1(val) { return val + 1; }


equal( P([ 1, 2 ]).reduce(add)._, 3 );

function add(a, b) { return a + b; }


deepEqual( P([ 1, 2 ]).each(add1)._, [ 1, 2 ] );

function add1(val) { return val + 1; }

ifFirst, ifNotFirst

fs.exists('file.txt', P.maybeIfFirst(
        fs.readFile, 'file.txt', 'utf-8',
        P.maybeIfNotFirst(console.log, console.error)

.ifFirst(function() {
    .ifNotFirst(console.log, console.error);

.applyToFirst(P.nodeBackLast(fs.readFile), 'utf-8')
.ifNotFirst(console.log, console.error);


Pointless objects have a .then() method:

P(42).then(function(val) { equal( val, 42 ); });

.then() returns a Pointless object wrapping the return value of its callback:

equal( P(42).then(add1)._, 43 );

function add1(val) { return val + 1; }

This method is supposed to resemble the .then() method from Promises/A.


Pointless objects work well with promises. Invoke .eventually() to get a Pointless object with a .then() method that is Promises/A compliant.

All of the usual Pointless methods are still available but they all implicitly call .then() so that they can be applied to the resolved values.

Code to map the results of a promise for an array that looks like this:

getPromiseForArray().then(function(arr) {

can become this:


The value of that Pointless object will be a promise. To use the fulfilled value of that promise, pass a callback function to .then() just like you would do with the result of the previous example:

.then(function(values) {
    // values and everything in it has been fulfilled.

Pointless relies on Q for its promise implementation. If you need support for promises, be sure to include Q. If you never call .eventually(), you don't need to bother including Q.