Gathering detailed insights and metrics for my
Gathering detailed insights and metrics for my
Gathering detailed insights and metrics for my
Gathering detailed insights and metrics for my
npm install my
Typescript
Module System
NPM Version
68.7
Supply Chain
99.1
Quality
75.3
Maintenance
100
Vulnerability
100
License
Minified
Minified + Gzipped
Cumulative downloads
Total Downloads
Last day
-27.8%
Compared to previous day
Last week
11.9%
Compared to previous week
Last month
-14.3%
Compared to previous month
Last year
-29.6%
Compared to previous year
No dependencies detected.
This project 'my.js' want to be the ultimate JavaScript module solution for everyone. It's now just some ideas (from long long ago to recently), but I will start to implement some features in very soon.
Let all js be my js
Easy to read, write and maitain the module definitions
Follow ES6 module draft
Server-solution friendly
Add-ons
Allow to add code translators such as wrapper, preprocessor, transformer, compiler, etc.
Example: module directive addon allow import/export/module/submoudle directives in diff styles
1<head> 2 ... 3 <script src="http://hax.github.com/my.js" load="app.js"> 4 ... 5</head>
1require('my').load('app')
1// define the module _traits_ from local file 2module ('traits'). at ('traits.js/lib/traits.js') 3 4// define the module _light_traits_ which follow AMD spec 5module ('light_traits'). at [AMD] ('traits.js/lib/traits.js') 6 7// define the module _qwrap_ as naked script and exports the name _QW_ 8module ('qwrap'). at [SCRIPT] ('core_dom_youa.com.js#QW') 9 10// define the module from the web 11module ('gloader'). at [SCRIPT] ('https://www.google.com/jsapi#google') 12 13// define the module from data uri 14// NOTE: it makes building deployment version possible and easy, 15// all we need to do is resource mapping 16module ('sample1'). at ('data:application/javascript,exports.Greeting = {hello:"world"}') 17 18// define another module which use last module 19module ('sample2'). at ('http://www.example.org/sample2.js') 20 21// define a cross-origin proxy, so all http requests will be routed to the proxy 22resource ('http://*'). from ('/proxy?url=$1') 23 24// so _sample2_ will be transformed, and just like u write: 25module ('sample2'). at ('/proxy?url=http://www.example.org/sample2.js') 26// NOTE: url encode is missed here for easy to understand, but in real impl 27// it should be for encoded each mapping step 28 29// This will be transformed internally to AMD wrapper form just like u write: 30module ('sample2'). at [AMD] ('amdwrap:/proxy?url=http://www.example.org/sample2.js') 31 32// Normally, the _amdwrap_ derefernce will be called to wrap code dynamically, 33// but you can define a server-generated AMD wrapper 34resource ('amdwrap:*'). from ('/amdwrap?url=$1') 35 36// So, it will transform the _sample2_ to: 37module ('sample2'). at [AMD] ('/amdwrap?url=/proxy?url=http://www.example.org/sample2.js') 38// NOTE: url encode is missed here for easy to understand, but in real impl 39// it should be for encoded each mapping step 40 41 42// define a resouce mapping rule, so last module will load source from data URI! 43resource ('http://www.example.org/sample2.js'). from ( 44 "data:,var G = require('sample1').Greeting; console.info(G.hello);" 45) 46 47// define another module from legacy scripts 48module ('sample3'). 49 imports ('Global.console'). 50 imports ('Greeting'). // which will be resolve to last _smaple1_ module 51 include ('sample/legacy.js'). // content: console.info('Hello' + Greeting.hello) 52end 53 54// define a module delegate to directory, so the modules definitions can be distributed 55module ('geo'). at ('geo/*')
Though my.js try to support all loaders and module system, but I recommand you using my.js built-in module system. Currently my.js support two styles of declarations in-box, directive prologues (just like 'use strict'), and labeled module statements (inspired by https://github.com/labeledmodules/labeled-modules-spec/wiki)
1// math.js (directive prologues) 2 3'export {sum, pi}' 4 5function sum(x, y) { 6 return x + y 7} 8var pi = 3.14159265
1// math.js (labeled module statements) 2 3exports: function sum(x, y) { 4 return x + y 5} 6exports: var pi = 3.14159265
1// simple client code (directive prologues) 2 3'import {sum, pi} from "math.js"' 4 5alert("2π = " + sum(pi, pi))
1// simple client code (labeled module statements) 2 3imports: {sum; pi} from: 'math.js' 4 5alert("2π = " + sum(pi, pi))
Cheat sheet:
ES6 module statements my.js directive prologues my.js labeled module statements
* prologues only can occur at * suffix 's' to avoid reserved keywords
the beginning of a file * use ';' instead of ','
1import {a, b} from "m.js" 'import {a, b} from "m.js"' imports: {a; b} from: "m.js"
1import {a:a1} from "m1.js" 'import {a:a1} from "m1.js"' imports: {a:a1} from: "m1.js" 2import {a:a2} from "m2.js" 'import {a:a2} from "m2.js"' imports: {a:a2} from: "m2.js"
1export function f() {...} 'export f' exports: function f() {....} 2 ... 3 function f() {...}
1export var v 'export v' exports: var v 2 ... 3 var v
1var a, b 'export {a, b}' var a, b 2... ... ... 3export {a, b} var a, b exports: {a; b}
1var _a, _b 'export {a: _a, b: _b}' var _a, _b 2... ... ... 3export {a: _a, b: _b} var _a, _b exports: {a: _a; b: _b}
There are three basic concept in this module solution:
module a block of reusable code
namespace
resource the code source
Q: Does the name 'my.js' have any other meaning?
A: Yes, there are many abbrev options, choose what you like, or you can suggest one.
* Module Yes!
* Make happY JavaScript!
* Module Yoga for JavaScript --- make your body flexible
* Module Yammy! --- take what match your taste
* Module Yamiedie...
No vulnerabilities found.
No security vulnerabilities found.