Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/johnny-shaman/include.modern
All Platform use to like importScripts function
https://github.com/johnny-shaman/include.modern
Last synced: 15 days ago
JSON representation
All Platform use to like importScripts function
- Host: GitHub
- URL: https://github.com/johnny-shaman/include.modern
- Owner: johnny-shaman
- License: gpl-3.0
- Created: 2018-04-08T09:15:04.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-04-13T10:48:23.000Z (almost 7 years ago)
- Last Synced: 2024-12-23T10:40:19.256Z (about 2 months ago)
- Language: JavaScript
- Size: 28.3 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# include.modern
All Platform use to like importScripts function# usage
## make a module
### ex1
~~~javascript
this.constructor.name === "Object" ? module.exports = myModule: Object.assign(this, {myModule});
~~~### ex2: Using is.modern
~~~javascript
is.server ? module.exports = myModule: Object.assign(this, {myModule});
~~~### ex3: Using is.modern
~~~javascript
is.server && (module.exports = myModule)
is.server || Object.assign(this, {myModule});
~~~## including
### Node.js
npm install include.modern
~~~javascript
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.
~~~javascript
let include = importScripts("../my_js_folder/include.modern.js");
//You can do it like a importScriptsinclude("./my0.js", "./my1.js", "./my2.js");
~~~### Browser
insert first this tag
~~~html~~~
and my.js file can use
~~~javascript
/*
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!!!