A secure runtime for JavaScript and TypeScript. A secure JavaScript and TypeScript runtime.

run

  • Deno run <*.js/ts>
// The BEM function needs to be a mixins to be enjoyed by all components that need it
const PREFIX = 'yoi-'

function join(name, mods) {
  name = PREFIX + name;
  mods = mods.map(function (mod) {
    return name + The '-' + 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
Copy the code
  • Run. / bem. Js
deno run ./bem.js
Copy the code

debugging

We mainly debug through VSCode, so we need some configuration file launch.json for debugging.

{
  "version": "0.2.0"."configurations": [{"name": "Deno"."type": "deno"."request": "launch"."cwd": "${workspaceFolder}"."runtimeExecutable": "deno"."runtimeArgs": ["run"."--inspect-brk"."-A"."<entry_point>"]."port": 9229}}]Copy the code