A secure runtime for JavaScript and TypeScript.一个安全的 JavaScript 和 TypeScript 运行时。
运行
- 命令 Deno run <*.js/ts>
// BEM 函数要成为一个 mixins 来让有需要的组件都能享受到
const PREFIX = 'yoi-'
function join(name, mods) {
name = PREFIX + name;
mods = mods.map(function (mod) {
return name + '--' + mod;
});
mods.unshift(name);
return mods.join(' ');
}
function traversing(mods, conf) {
if (!conf) {
return;
}
if (typeof conf === 'string' || typeof conf === 'number') {
mods.push(conf);
} else if (Array.isArray(conf)) {
conf.forEach(function (item) {
traversing(mods, item);
});
} else if (typeof conf === 'object') {
Object.keys(conf).forEach(function (key) {
conf[key] && mods.push(key);
});
}
}
export function bem(name, conf) {
var mods = []
traversing(mods, conf)
return join(name, mods)
}
console.log(bem('info', { dot: true })) // yoi-info yoi-info--dot
console.log(bem('info', { dot: false })) // yoi-info
- 运行 ./bem.js
deno run ./bem.js
调试
我们主要是通过 VSCode 进行调试, 我们就需要些一个调试的配置文件 launch.json。
{
"version": "0.2.0",
"configurations": [
{
"name": "Deno",
"type": "deno",
"request": "launch",
"cwd": "${workspaceFolder}",
"runtimeExecutable": "deno",
"runtimeArgs": ["run", "--inspect-brk", "-A", "<entry_point>"],
"port": 9229
}
]
}