Ai
2 Star 0 Fork 0

mirrors_WebReflection/interface

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
es5.js 661 Bytes
一键复制 编辑 原始数据 按行查看 历史
Andrea Giammarchi 提交于 2017-06-19 17:13 +08:00 . 100% code coverage
// this is an overly simplified approach
// if you need fully compatible extend
// use the non ES5 version and transpile it
function Class(Super) {
function Interface() {
return O.setPrototypeOf(
Super.apply(this, arguments) || this,
Interface.prototype
);
}
O.setPrototypeOf(Interface.prototype, Super.prototype);
return O.setPrototypeOf(Interface, Super);
}
const fs = require('fs');
fs.writeFileSync(
'interface.es5.js',
fs.readFileSync('interface.js').toString()
.replace(/class\s+extends\s+(\S+)\s+\{\s*\}/g, 'Class($1)')
.replace(
/(\s+function Interface)/,
'\n\n// ES5 patch\n' + Class + '$1'
)
);
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mirrors_WebReflection/interface.git
git@gitee.com:mirrors_WebReflection/interface.git
mirrors_WebReflection
interface
interface
master

搜索帮助