https://github.com/dustinspecker/const-func
Create a function always returning a constant
https://github.com/dustinspecker/const-func
Last synced: 3 months ago
JSON representation
Create a function always returning a constant
- Host: GitHub
- URL: https://github.com/dustinspecker/const-func
- Owner: dustinspecker
- License: mit
- Created: 2016-03-17T22:05:07.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-05-28T20:12:53.000Z (about 8 years ago)
- Last Synced: 2025-03-17T02:18:56.216Z (4 months ago)
- Language: JavaScript
- Homepage:
- Size: 11.7 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 17
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# const-func
[](https://badge.fury.io/js/const-func) [](https://travis-ci.org/dustinspecker/const-func) [](https://coveralls.io/r/dustinspecker/const-func?branch=master)[](https://codeclimate.com/github/dustinspecker/const-func) [](https://david-dm.org/dustinspecker/const-func/#info=dependencies&view=table) [](https://david-dm.org/dustinspecker/const-func/#info=devDependencies&view=table)
> Create a function always returning a constant
Like [Elm](http://elm-lang.org/)'s [always](http://package.elm-lang.org/packages/elm-lang/core/latest/Basics#always)
## Install
```
npm install --save const-func
```## Usage
```javascript
import always from 'const-func'const alwaysUndefined = always()
alwaysUndefined()
// => undefinedconst always3 = always(3)
always3()
// => 3const alwaysHi = always('hi')
alwaysHi('whatever')
// => 'hi'
```## API
### always(arg)
Returns a function that always returns a constant value.#### arg
type: `*`default: `undefined`
The constant value to always return from the constant function.
## LICENSE
MIT © [Dustin Specker](https://github.com/dustinspecker)