<commit_before>/******************************************************************************
 *                                    ~fn~                                    *
 *                                  ‾‾‾‾‾‾‾‾                                  *
 * Function utilities.                                                        *
 *     _________________________________________________________________      *
 *        Copyright (c) 2011 <NAME> // Licenced under MIT/X11        *
 ******************************************************************************/
void function (root) {

    var fn

    , slice = Array.prototype.slice


    ///// Function partial /////////////////////////////////////////////////////
    //
    //   (fn:Fn, args...) ↦ Fn
    //
    // Return a function that'll always have the given arguments
    // prepended to argument list passed to the function.
    //
    function partial(fn) {
        var args = slice.call(arguments, 1)
        return function() { return fn.apply(this, args.concat(slice.call(arguments))) }
    }


    ///// Function delay ///////////////////////////////////////////////////////
    //
    //   (fn:Fn, seconds:Num) ↦ Num
    //
    // Calls the function after the given number of seconds.
    //
    // Returns an ID to a timer, such that the call to the function can
    // be cancelled by passing that ID to `clearTimeout`.
    //
    function delay(fn, seconds) { var args
        args = slice.call(arguments, 2)
        if (args.length)  fn = fn.bind.apply(fn, args)

        return setTimeout(fn, seconds * 1000)
    }

    ///// Function defer ///////////////////////////////////////////////////////
    //
    //   (fn:Fn) ↦ Num
    //
    // Same as `delay`, but calls the function as soon as the engine is
    // not busy doing other things.
    //
    function defer(fn) { var args
        args = slice.call(arguments, 1)
        return delay.apply(this, [fn, 0].concat(args))
    }


    ///// Function wrap ////////////////////////////////////////////////////////
    //
    //   (fn:Fn[, wrapper:Fn]) ↦ Fn
    //
    // Returns a function that passes the given function as the first
    // argument for any other function.
    //
    function wrap(fn, wrapper) {
        if (!wrapper)
            wrapper = function(f){ f.apply(this, slice.call(arguments, 1)) }

        return partial(wrapper, fn)
    }




    ///// Exports //////////////////////////////////////////////////////////////
    fn = typeof exports == 'undefined'?  root.black.fn = { }
       :                                 exports

    fn.partial = partial
    fn.delay   = delay<commit_msg>src/fn: Fixes description for the `wrap` function.<commit_after>/******************************************************************************
 *                                    ~fn~                                    *
 *                                  ‾‾‾‾‾‾‾‾                                  *
 * Function utilities.                                                        *
 *     _________________________________________________________________      *
 *        Copyright (c) 2011 <NAME> // Licenced under MIT/X11        *
 ******************************************************************************/
void function (root) {

    var fn

    , slice = Array.prototype.slice


    ///// Function partial /////////////////////////////////////////////////////
    //
    //   (fn:Fn, args...) ↦ Fn
    //
    // Return a function that'll always have the given arguments
    // prepended to argument list passed to the function.
    //
    function partial(fn) {
        var args = slice.call(arguments, 1)
        return function() { return fn.apply(this, args.concat(slice.call(arguments))) }
    }


    ///// Function delay ///////////////////////////////////////////////////////
    //
    //   (fn:Fn, seconds:Num) ↦ Num
    //
    // Calls the function after the given number of seconds.
    //
    // Returns an ID to a timer, such that the call to the function can
    // be cancelled by passing that ID to `clearTimeout`.
    //
    function delay(fn, seconds) { var args
        args = slice.call(arguments, 2)
        if (args.length)  fn = fn.bind.apply(fn, args)

        return setTimeout(fn, seconds * 1000)
    }

    ///// Function defer ///////////////////////////////////////////////////////
    //
    //   (fn:Fn) ↦ Num
    //
    // Same as `delay`, but calls the function as soon as the engine is
    // not busy doing other things.
    //
    function defer(fn) { var args
        args = slice.call(arguments, 1)
        return delay.apply(this, [fn, 0].concat(args))
    }


    ///// Function wrap ////////////////////////////////////////////////////////
    //
    //   (fn:Fn[, wrapper:Fn]) ↦ Fn
    //
    // Returns a function that passes the given `wrapper` as the first
    // argument for `fn`.
    //
    function wrap(fn, wrapper) {
        if (!wrapper)
            wrapper = function(f){ f.apply(this, slice.call(arguments, 1)) }

        return partial(wrapper, fn)
    }




    ///// Exports //////////////////////////////////////////////////////////////
    fn = typeof exports == 'undefined'?  root.black.fn = { }
       :                                 exports

    fn.partial = partial
    fn.delay   = delay
{'fraction_non_alphanumeric': 0.26451734539969834, 'fraction_numerical': 0.005656108597285068, 'mean_word_length': 1.2021585720215857, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5024769', 'n_tokens_mistral': 1338, 'n_tokens_neox': 1213, 'n_words': 377}