<commit_before>{stdenv, lib, nodejs, nijs}:
{name ? null, function, args, modules ? [], requires ? [], NODE_PATH ? "", async ? false, format ? false}:

let
  nixToJS = import ./nixToJS.nix { inherit lib; };
in
import (stdenv.mkDerivation {
  name = "function-proxy${if name == null then "" else "-${name}"}.nix";
  inherit NODE_PATH;
  buildInputs = [ nodejs nijs ] ++ modules;
  buildCommand = ''
    (
    cat <<EOF
    var fs = require('fs');
    var nijs = require('nijs');

    /* Import all the CommonJS modules that we like to use in this function */
    ${lib.concatMapStrings (require: "var ${require.var} = require('${require.module}');\n") requires}

    /* Define the JavaScript function */
    var fun = ${function};

    /* Convert the function arguments to JavaScript */
    var args = [
      ${stdenv.lib.concatMapStrings (arg: nixToJS arg+",\n") args}
    ];

    /* Define callback interfaces for asynchronous functions */

    var nijsCallbacks = {
        callback : function(err, result) {
            if(err) {
                process.stderr.write(err);
                process.exit(1);
            } else {
                fs.writeFileSync("$out", nijs.jsToNix(result, ${if format then "true" else "false"}));
            }
        }
    };

    /* Evaluate the function */
    var result = fun.apply(this, args);

    ${stdenv.lib.optionalString (!async) ''
      /* Return the evaluation result */
      nijsCallbacks.callback(null, result);
    ''}
    EOF
    ) | node
  '';
})<commit_msg>Removed another deprecated stdenv.lib reference<commit_after>{stdenv, lib, nodejs, nijs}:
{name ? null, function, args, modules ? [], requires ? [], NODE_PATH ? "", async ? false, format ? false}:

let
  nixToJS = import ./nixToJS.nix { inherit lib; };
in
import (stdenv.mkDerivation {
  name = "function-proxy${if name == null then "" else "-${name}"}.nix";
  inherit NODE_PATH;
  buildInputs = [ nodejs nijs ] ++ modules;
  buildCommand = ''
    (
    cat <<EOF
    var fs = require('fs');
    var nijs = require('nijs');

    /* Import all the CommonJS modules that we like to use in this function */
    ${lib.concatMapStrings (require: "var ${require.var} = require('${require.module}');\n") requires}

    /* Define the JavaScript function */
    var fun = ${function};

    /* Convert the function arguments to JavaScript */
    var args = [
      ${lib.concatMapStrings (arg: nixToJS arg+",\n") args}
    ];

    /* Define callback interfaces for asynchronous functions */

    var nijsCallbacks = {
        callback : function(err, result) {
            if(err) {
                process.stderr.write(err);
                process.exit(1);
            } else {
                fs.writeFileSync("$out", nijs.jsToNix(result, ${if format then "true" else "false"}));
            }
        }
    };

    /* Evaluate the function */
    var result = fun.apply(this, args);

    ${lib.optionalString (!async) ''
      /* Return the evaluation result */
      nijsCallbacks.callback(null, result);
    ''}
    EOF
    ) | node
  '';
})
{'fraction_non_alphanumeric': 0.15029469548133595, 'fraction_numerical': 0.0006548788474132286, 'mean_word_length': 2.4874429223744294, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5239215', 'n_tokens_mistral': 957, 'n_tokens_neox': 921, 'n_words': 254}