Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
the constant function.
JavaScript
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
src
test
README.markdown
package.json

README.markdown

const

The constant function from functional programming: it takes a value and returns a function that will return that value:

var constant = require('const')
var alwaysA = constant('a');

alwaysA() //= 'a'

Useful to lifting a value into the world of functions, e.g. when using promises:

getUserDetails()
    .then(getMessageFromUser, constant('User not found'))

Other names it's gone by in the past:

  • K combinator
  • lift
  • always
Something went wrong with that request. Please try again.