Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dustinspecker/const-func
Create a function always returning a constant
https://github.com/dustinspecker/const-func
Last synced: 2 days 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 8 years ago)
- Default Branch: master
- Last Pushed: 2017-05-28T20:12:53.000Z (over 7 years ago)
- Last Synced: 2024-10-13T16:10:42.033Z (26 days ago)
- Language: JavaScript
- Homepage:
- Size: 11.7 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 17
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# const-func
[![NPM version](https://badge.fury.io/js/const-func.svg)](https://badge.fury.io/js/const-func) [![Build Status](https://travis-ci.org/dustinspecker/const-func.svg)](https://travis-ci.org/dustinspecker/const-func) [![Coverage Status](https://img.shields.io/coveralls/dustinspecker/const-func.svg)](https://coveralls.io/r/dustinspecker/const-func?branch=master)[![Code Climate](https://codeclimate.com/github/dustinspecker/const-func/badges/gpa.svg)](https://codeclimate.com/github/dustinspecker/const-func) [![Dependencies](https://david-dm.org/dustinspecker/const-func.svg)](https://david-dm.org/dustinspecker/const-func/#info=dependencies&view=table) [![DevDependencies](https://david-dm.org/dustinspecker/const-func/dev-status.svg)](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)