.jslib ES6+ support test
Object function Literal: NG[Build Error]
// NG: [Build Error]
mergeInto(LibraryManager.library, {
fnc() {
}
});
Object Arrow Function: NG[Runtime Error]
// NG: [Runtime Error]
mergeInto(LibraryManager.library, {
fnc:() => {
}
});
Async Function: OK
// OK
mergeInto(LibraryManager.library, {
$asyncFnc: async function(a, b, c) {
return new Promise(resolve => {
setTimeout(() => {
console.log(Date.now());
resolve();
}, 1000);
});
},
fnc__deps: ['$asyncFnc'],
fnc: async function(){
await asyncFnc();
await asyncFnc();
await asyncFnc();
}
});
Default Parameters: OK
// OK
mergeInto(LibraryManager.library, {
fnc: function(a = 3, b = 4) {
console.log(a, b);
}
});
Rest parameters: OK
// OK
mergeInto(LibraryManager.library, {
fnc: function(a, ...args) {
console.log(a);
args.forEach(x => console.log(x));
}
});
Arrow Function: OK
// OK
mergeInto(LibraryManager.library, {
fnc: function(...args) {
args.forEach(x => console.log(x));
}
});
let / const: OK
// OK
mergeInto(LibraryManager.library, {
fnc: function(a, b, c) {
let d = a;
const e = b;
console.log(d, e);
}
});
New Object Literal: OK
// OK
mergeInto(LibraryManager.library, {
fnc: function(a, b, c) {
let obj = {a, b, c};
console.log(JSON.stringify(obj));
}
});
Template Literal: OK
// OK
mergeInto(LibraryManager.library, {
fnc: function(a, b, c) {
console.log(`Template Literal test:${a}, ${b}, ${c}`);
}
});
Destructuring assignment: OK and NG
// OK
mergeInto(LibraryManager.library, {
fnc: function() {
let a, b, c;
[a, b, c] = [1, 2, 3];
console.log(`${a}, ${b}, ${c}`);
}
});
// NG: [Runtime Error]
mergeInto(LibraryManager.library, {
fnc: function() {
let [a, b, c] = [1, 2, 3];
console.log(`${a}, ${b}, ${c}`);
}
});
// NG: [Runtime Error]
mergeInto(LibraryManager.library, {
fnc: function(a, b, c) {
let {d, e, f} = {d:a, e:b, f:c};
console.log(`${a}, ${b}, ${c}`);
}
});
Object Function Literal was a very strong hope, but I’m very sorry that it wasn’t supported.