Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
chain-able-deps / dist / fp / bind.js
Size: Mime:
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var arity_1 = require("./arity");
var curry_1 = require("./curry");
/**
 * Creates a function that is bound to a context.
 * @since 5.0.0-beta.5
 * @memberOf fp
 *
 * @param {Function} fn The function to bind to context
 * @param {Object} thisArg The context to bind `fn` to
 * @return {Function} A function that will execute in the context of `thisArg`.
 *
 * @tests fp/bind
 *
 * @func
 * @fork v0.6.0
 * @category Function
 * @category Object
 * @sig (* -> *) -> {*} -> (* -> *)
 * @symb bind(f, o)(a, b) = f.call(o, a, b)
 *
 * {@link https://github.com/jashkenas/underscore/blob/master/underscore.js#L765 underscore-bind}
 * {@link https://github.com/lodash/lodash/blob/master/bindKey.js lodash-bind-key}
 * {@link https://github.com/ramda/ramda/blob/master/src/partial.js ramda-partial}
 * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind mozilla-Function.bind}
 * @see {@link mozilla-Function.bind}
 * @see {@link ramda-partial}
 * @see {@link lodash-bind-key}
 * @see {@link underscore-bind}
 *
 * @NOTE `bind` does not provide the additional argument-binding capabilities of
 *       [Function.prototype.bind](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind).
 *
 * @example
 *
 *      var log = bind(console.log, console);
 *      R.pipe(R.assoc('a', 2), R.tap(log), R.assoc('a', 3))({a: 1}); //=> {a: 3}
 *      // logs {a: 2}
 *
 */
exports.default = curry_1.default(2, function bind(fn, thisArg) {
    return arity_1.default(fn.length, function () {
        return fn.apply(thisArg, arguments);
    });
});
//# sourceMappingURL=bind.js.map