Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
81158 views
1
/**
2
* Copyright 2013-2014, Facebook, Inc.
3
* All rights reserved.
4
*
5
* This source code is licensed under the BSD-style license found in the
6
* LICENSE file in the root directory of this source tree. An additional grant
7
* of patent rights can be found in the PATENTS file in the same directory.
8
*
9
* @providesModule emptyFunction
10
*/
11
12
function makeEmptyFunction(arg) {
13
return function() {
14
return arg;
15
};
16
}
17
18
/**
19
* This function accepts and discards inputs; it has no side effects. This is
20
* primarily useful idiomatically for overridable function endpoints which
21
* always need to be callable, since JS lacks a null-call idiom ala Cocoa.
22
*/
23
function emptyFunction() {}
24
25
emptyFunction.thatReturns = makeEmptyFunction;
26
emptyFunction.thatReturnsFalse = makeEmptyFunction(false);
27
emptyFunction.thatReturnsTrue = makeEmptyFunction(true);
28
emptyFunction.thatReturnsNull = makeEmptyFunction(null);
29
emptyFunction.thatReturnsThis = function() { return this; };
30
emptyFunction.thatReturnsArgument = function(arg) { return arg; };
31
32
module.exports = emptyFunction;
33
34