<commit_before>// AsciiFrames constructor
var AsciiFrames = function (options) {

    var self = this;

    /**
     * loadFrames
     *
     * This method loads the frames that must be animated.
     *
     * @param options: an array of strings representing the frames of animation
     * @return
     */
    self.loadFrames = function (options) {

        // validate options
        if (!options) { throw new Error ("First argument must be an array or an object."); }
        if (options.constructor === Array) {
            self._frames = options;
        }

        // object
        if (options.constructor === Object) {
            throw new Error ("Not yet implemented");
        }
    };

    /*
     *  AsciiFrames#startAnimation (options)
     *
     *  Start the ASCII animation
     *  options -> an object containing the following fields
     *              * frameDelay: time in miliseconds
     *              * repeat:     boolean
     *
     * */
    self.startAnimation = function (options) {

        // validate options
        if (!options) { throw new Error ("First argument must be an object."); }

        // frame delay
        options.frameDelay = Number(options.frameDelay);

        console.log("\u001b[2J\u001b[0;0H");
        var cFrame = 0
          , frameCount = self._frames.length
          , repeat = Boolean(options.repeat)
          , animation = setInterval(function () {

                // show current frame
                process.stdout.cursorTo(0, 0);
                process.stdout.write(self._frames[++cFrame % frameCount]);

                // animation finished
                if (cFrame >= frameCount && !repeat) {
                    clearInterval(animation);
                }

            }, options.frameDelay);
    }
};

module.exports = AsciiFrames;
<commit_msg>Code refactoring, renaming AsciiFrames in cli-frames<commit_after>// Dependencies
var CliUpdate = require("cli-update");

/**
 * CliFrames
 * Creates a new instance of CliFrames.
 *
 * @name CliFrames
 * @function
 * @param {Object} opt_options An optional object containing:
 *
 *  - `frames` (Array): The frames to be loaded.
 *  - `autostart` (Object): If provided, the animation will be autostarted.
 *     The object will be provided to `start` function.
 *
 * @return {CliFrames} The CliFrames instance.
 */
var CliFrames = module.exports = function (opt_options) {

    var self = this;
    opt_options = Object(opt_options);

    /**
     * load
     * Loads the animation frames.
     *
     * @name load
     * @function
     * @param {Object} options An array of strings representing the animation frames.
     * @return {CliFrames} The CliFrames instance.
     */
    self.load = function(options) {
        if (!Array.isArray(options)) { throw new Error("First argument must be an array of strings."); }
        self.frames = options;
        return self;
    };

    /**
     * start
     * Starts the CLI animation.
     *
     * @name start
     * @function
     * @param {Object} options An object containing the following fields:
     *
     *  - `delay` (Number): The frame delay in milliseconds (default: `100`).
     *  - `repeat` (Boolean): If `true`, the animation will be repeated infinitely.
     *
     * @return {CliFrames} The CliFrames instance.
     */
    self.start = function(options) {

        options = Object(options);
        options.delay = Number(options.delay || 100);

        var cFrame = 0
          , frameCount = self.frames.length
          , repeat = Boolean(options.repeat)
          , animation = setInterval(function() {
                CliUpdate.render(self.frames[++cFrame % frameCount]);
                if (cFrame >= frameCount && !repeat) {
                    clearInterval(animation);
                }
            }, options.delay);

        return CliFrames;
    };

    if (opt_options.frames) {
        self.load(opt_options.frames);
    }

    if (opt_options.autostart) {
        self.start(opt_options.autostart);
    }
};

{'fraction_non_alphanumeric': 0.11077844311377245, 'fraction_numerical': 0.004740518962075849, 'mean_word_length': 1.9962630792227205, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '5943725', 'n_tokens_mistral': 1138, 'n_tokens_neox': 1059, 'n_words': 313}