Set of functions that simply return a value
JavaScript HTML Makefile
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
dist
.gitignore
History.md
Makefile
README.md
component.json
index.js
package.json

README.md

return-function

Set of functions that simply return a value. Can be used for stubs. Contains function that creates functions which return a value.

Installation

Node

npm install return-function

Component

Install Component:

npm install -g component

Then:

component install gamtiq/return-function

Usage

Node, Component

var ret = require("return-function");
...

AMD

define(["dist/return-function"], function(ret) {
    ...
});

Browser

<script type="text/javascript" src="dist/return-function.js"></script>
<script type="text/javascript">
    var ret = returnFunction;
    ...
</script>

Examples

var global = ret.returnGlobal();   // window in browser
var first = ret.returnFirstArg(1, 2, 3);   // 1
var second = ret.returnSecondArg(1, 2, 3);   // 2
var list = ret.returnArgList(1, 2, 3);   // [1, 2, 3]
var f = ret.getValueFunction("some value");
f(123);   // "some value"

API

.emptyFunction()

Empty function that does nothing and returns undefined.

.returnUndefined()

Empty function that does nothing and returns undefined.

.returnNull()

Return null.

.returnTrue()

Return true.

.returnFalse()

Return false.

.returnEmptyStr()

Return empty string.

.returnNaN()

Return NaN.

.returnZero()

Return 0.

.returnOne()

Return 1.

.returnEmptyObject()

Return {}.

.returnEmptyArray()

Return [].

.returnEmptyFunction()

Return function () {}.

.returnDate()

Return new Date().

.returnThis()

Return this.

.returnGlobal()

Return global object (window in browser).

.returnFirstArg()

Return the first argument.

.returnSecondArg()

Return the second argument.

.returnArgList()

Return array of arguments.

.getValueFunction(value)

Return function that returns specified value.