{"size": 1499, "ext": "js", "max_stars_repo_path": "packages/fes-cli/build/mock/util.js", "max_stars_repo_name": "zybeargithub/fee.js", "max_stars_repo_stars_event_min_datetime": "2021-06-26T01:06:51.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-05T01:38:58.000Z", "max_issues_repo_path": "packages/fes-cli/build/mock/util.js", "max_issues_repo_name": "zybeargithub/fee.js", "max_issues_repo_issues_event_min_datetime": "2021-09-02T16:18:45.000Z", "max_issues_repo_issues_event_max_datetime": "2021-09-02T16:18:45.000Z", "max_forks_repo_path": "packages/fes-cli/build/mock/util.js", "max_forks_repo_name": "zybeargithub/fee.js", "max_forks_repo_forks_event_min_datetime": "2021-12-04T10:25:16.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-04T10:25:16.000Z"}
{"max_stars_count": 3, "max_issues_count": 1, "max_forks_count": 1, "avg_line_length": 23.7936507937, "max_line_length": 60, "alphanum_fraction": 0.4683122081}
const fs = require('fs');

const toString = Object.prototype.toString;
module.exports = {

    isArray(value) {
        return toString.call(value) === '[object Array]';
    },

    isObject(value) {
        return toString.call(value) === '[object Object]';
    },

    isFunction(value) {
        return toString.call(value) === '[object Function]';
    },

    each(val, callback) {
        if (this.isArray(val)) {
            val.forEach(callback);
        }
        if (this.isObject(val)) {
            Object.keys(val).forEach((key) => {
                callback(val[key], key);
            });
        }
    },

    watchFile(filename, callback) {
        const isWin = (process.platform === 'win32');
        if (isWin) {
            return fs.watch(filename, (event) => {
                if (event === 'change') {
                    return callback(filename);
                }
                return null;
            });
        }
        return fs.watchFile(filename, {
            interval: 200
        }, (curr, prev) => {
            if (curr.mtime > prev.mtime) {
                return callback(filename);
            }
            return null;
        });
    },

    unwatchFile(watcher, filename) {
        if (watcher) {
            watcher.close && watcher.close();
        } else {
            fs.unwatchFile(filename);
        }
    },

    cleanCache(modulePath) {
        if (require.cache[modulePath]) {
            delete require.cache[modulePath];
        }
    }
};
