mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-10 21:54:47 +08:00
DISABLE_THIRD_PARTY_CHECK=new npm module causes package-lock change We can get rid of a custom script and use ESLint for these rules. Additionally this means editors will highlight the issue in the editor. Change-Id: I552b52e7f07b4e7430b3f685dbc3b5fad36ffff2 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2052167 Reviewed-by: Paul Lewis <aerotwist@chromium.org> Commit-Queue: Jack Franklin <jacktfranklin@chromium.org>
35 lines
996 B
JavaScript
35 lines
996 B
JavaScript
import _arity from './internal/_arity.js';
|
|
import _curry1 from './internal/_curry1.js';
|
|
|
|
/**
|
|
* Accepts a function `fn` and returns a function that guards invocation of
|
|
* `fn` such that `fn` can only ever be called once, no matter how many times
|
|
* the returned function is invoked. The first value calculated is returned in
|
|
* subsequent invocations.
|
|
*
|
|
* @func
|
|
* @memberOf R
|
|
* @since v0.1.0
|
|
* @category Function
|
|
* @sig (a... -> b) -> (a... -> b)
|
|
* @param {Function} fn The function to wrap in a call-only-once wrapper.
|
|
* @return {Function} The wrapped function.
|
|
* @example
|
|
*
|
|
* const addOneOnce = R.once(x => x + 1);
|
|
* addOneOnce(10); //=> 11
|
|
* addOneOnce(addOneOnce(50)); //=> 11
|
|
*/
|
|
var once = /*#__PURE__*/_curry1(function once(fn) {
|
|
var called = false;
|
|
var result;
|
|
return _arity(fn.length, function () {
|
|
if (called) {
|
|
return result;
|
|
}
|
|
called = true;
|
|
result = fn.apply(this, arguments);
|
|
return result;
|
|
});
|
|
});
|
|
export default once; |