0.3.2 • Published 6 years ago

include.modern v0.3.2

Weekly downloads
1
License
GPL-3.0
Repository
github
Last release
6 years ago

include.modern

All Platform use to like importScripts function

usage

make a module

ex1

    this.constructor.name === "Object" ? module.exports = myModule: Object.assign(this, {myModule});

ex2: Using is.modern

    is.server ? module.exports = myModule: Object.assign(this, {myModule});

ex3: Using is.modern

    is.server && (module.exports = myModule)
    is.server || Object.assign(this, {myModule});

including

Node.js

npm install include.modern

let include = require("include.modern");
//You can do it like a importScripts

/*
The means of same...

let http = require("http"),
    express = require("express"),
    myCtrls = require(./myCtrls.js);
*/

include("http", "express",  "./myCtrls.js");

//define global

include("http", "express", "./myCtrls.js", {
    io: "socket.io",
    myClass: "./my.class.js"
    myTemplate: "./template/my.template.js"
});

/*
The means of same...
let ctrls = {
    route: require("./route.js"),
    index: require("./controllers/index.js"),
    foo: require("./controllers/foo.js"),
    bar: require("./controllers/bar.js")
}
*/

const path = "./controllers/";
include.setPath(path);
let ctrls = include("./route.js", {
    index: path + "index.js",
    foo: path + "foo.js",
    bar: path + "bar.js"
}, {});

Worker

Download this repository.

let include = importScripts("../my_js_folder/include.modern.js");
//You can do it like a importScripts

include("./my0.js", "./my1.js", "./my2.js");

Browser

insert first this tag

<script src="https://cdn.jsdelivr.net/npm/include.modern/include.modern.min.js" async defer></script>
<script src="./my_module_folder/my.js" defer></script>

and my.js file can use

/*
You can do it like a importScripts && return Promise and Promise.then === Promise.defer
As You like to use it!
*/
include("./js/my0.js", "./js/my1.js", "./js/my2.js").defer(() => {
    //scripting here
});

Happy Hacking!!!

0.3.2

6 years ago

0.3.1

6 years ago

0.3.0

6 years ago

0.2.5

6 years ago

0.2.1

6 years ago

0.1.6

6 years ago

0.1.5

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago

0.0.1

6 years ago