index.js
function Threadify(options) {
    if (typeof(options) == "string") {
        options = {methods: [options]};
    } else if (Array.isArray(options)) {
        options = {methods: options};
    } else {
        if (options !== undefined && typeof(options) != "object") {
            throw new Error("[Threadify] You must specify either: \nNothing\nA string\nAn array of string\n")
        }
    }
    var options = Object.assign({
        module: null,
        exportsPath: null,
        methods: []
    }, options);
    // We automatically search the class or the object in the module loaded
    if (!options.module) {
        var cacheFounded = null;
        var pathExport = [];
        var parsedModule = [require.main, require.cache];
        for (var i in require.cache) {
            var cache = require.cache[i];

            // If module have exports, we search the class/object in it
            if (cache.exports) {
                var objectToSearch = {};

                // We exclude electron modules because of a lot of loop references
                if (isElectron && cache.filename.indexOf("/node_modules/electron/") >= 0) {
                    continue;
                }
                var pathObject = [];
                if (cache.exports !== this) {
                    pathObject = findObject(this, cache.exports, [], parsedModule);
                }

                if (pathObject !== null) {
                    cacheFounded = {module: cache, pathToClass: pathObject};
                    break;
                }
            }

        }
        if (!cacheFounded) {
           throw new Error("[Threadify] Class to threadify must be in a non-core separate module.");
        } else {
           options.module = cacheFounded.module.filename;
           options.exportsPath = cacheFounded.pathToClass;
        }
    }
    return ThreadifyAll(this, options);
}
function Threadify(options) {
    if (typeof(options) == "string") {
        options = {methods: [options]};
    } else if (Array.isArray(options)) {
        options = {methods: options};
    } else {
        if (options !== undefined && typeof(options) != "object") {
            throw new Error("[Threadify] You must specify either: \nNothing\nA string\nAn array of string\n")
        }
    }
    var options = Object.assign({
        module: null,
        exportsPath: null,
        methods: []
    }, options);
    // We automatically search the class or the object in the module loaded
    if (!options.module) {
        var cacheFounded = null;
        var pathExport = [];
        var parsedModule = [require.main, require.cache];
        for (var i in require.cache) {
            var cache = require.cache[i];

            // If module have exports, we search the class/object in it
            if (cache.exports) {
                var objectToSearch = {};

                // We exclude electron modules because of a lot of loop references
                if (isElectron && cache.filename.indexOf("/node_modules/electron/") >= 0) {
                    continue;
                }
                var pathObject = [];
                if (cache.exports !== this) {
                    pathObject = findObject(this, cache.exports, [], parsedModule);
                }

                if (pathObject !== null) {
                    cacheFounded = {module: cache, pathToClass: pathObject};
                    break;
                }
            }

        }
        if (!cacheFounded) {
           throw new Error("[Threadify] Class to threadify must be in a non-core separate module.");
        } else {
           options.module = cacheFounded.module.filename;
           options.exportsPath = cacheFounded.pathToClass;
        }
    }
    return ThreadifyAll(this, options);
}
function Threadify ( options ) { if ( typeof ( options ) == "string" ) { options = { methods : [ options ] } ; } else if ( Array . isArray ( options ) ) { options = { methods : options } ; } else { if ( options !== undefined && typeof ( options ) != "object" ) { throw new Error ( "[Threadify] You must specify either: \nNothing\nA string\nAn array of string\n" ) } } var options = Object . assign ( { module : null , exportsPath : null , methods : [ ] } , options ) ; // We automatically search the class or the object in the module loaded if ( ! options . module ) { var cacheFounded = null ; var pathExport = [ ] ; var parsedModule = [ require . main , require . cache ] ; for ( var i in require . cache ) { var cache = require . cache [ i ] ; // If module have exports, we search the class/object in it if ( cache . exports ) { var objectToSearch = { } ; // We exclude electron modules because of a lot of loop references if ( isElectron && cache . filename . indexOf ( "/node_modules/electron/" ) >= 0 ) { continue ; } var pathObject = [ ] ; if ( cache . exports !== this ) { pathObject = findObject ( this , cache . exports , [ ] , parsedModule ) ; } if ( pathObject !== null ) { cacheFounded = { module : cache , pathToClass : pathObject } ; break ; } } } if ( ! cacheFounded ) { throw new Error ( "[Threadify] Class to threadify must be in a non-core separate module." ) ; } else { options . module = cacheFounded . module . filename ; options . exportsPath = cacheFounded . pathToClass ; } } return ThreadifyAll ( this , options ) ; }
Threadify a class or an object defined in a separate uncore module
Cored module like fs, path, and others can't be threadified

Options can be:
- Nothing: all functions are threadified
- A String: the specific function is threadified
- An array of string: all the functions specified are threadified

For class only:
The current object is sent to the thread and then reproduced
If you want to use some properties, be sure to have them accessible (public properties)
Private ones can't be accessed
Threadify a class or an object defined in a separate uncore module Cored module like fs path and others can t be threadified