npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

br-code

v5.0.0

Published

JavaScript em Português — Compile código PT-BR para JavaScript

Downloads

279

Readme

JSBr - JavaScript Brasil 🇧🇷

Programe em Português, Execute em JavaScript!

JSBr é uma linguagem de programação que permite escrever código JavaScript usando palavras-chave e sintaxe em português brasileiro. O código é transpilado para JavaScript padrão.

🚀 Instalação

npm install -g br-code

📝 Exemplo Rápido

arquivo.jsbr:

funcao saudacao(nome) {
  variavel mensagem = "Olá, " + nome + "!";
  retorna mensagem;
}

variavel resultado = saudacao("Brasil");
escreva(resultado);

// Estruturas de controle
se (resultado) {
  escreva("Sucesso!");
} senao {
  escreva("Erro!");
}

// Loops
para (variavel i = 0; i < 5; i++) {
  escreva("Número: " + i);
}

// Arrays
variavel numeros = [1, 2, 3, 4, 5];
numeros.paraCada(num => {
  escreva(num * 2);
});

Compilado para JavaScript:

function saudacao(nome) {
  let mensagem = "Olá, " + nome + "!";
  return mensagem;
}

let resultado = saudacao("Brasil");
console.log(resultado);

if (resultado) {
  console.log("Sucesso!");
} else {
  console.log("Erro!");
}

for (let i = 0; i < 5; i++) {
  console.log("Número: " + i);
}

let numeros = [1, 2, 3, 4, 5];
numeros.forEach(num => {
  console.log(num * 2);
});

🛠️ Uso da CLI

Compilar arquivo

jsbr compilar arquivo.jsbr
jsbr compilar arquivo.jsbr -o saida.js
jsbr compilar arquivo.jsbr --watch  # Modo observação

Executar arquivo

jsbr executar arquivo.jsbr

Criar novo projeto

jsbr iniciar meu-projeto
cd meu-projeto
npm install
npm run executar

📚 Palavras-chave

Declarações

  • variavellet
  • constanteconst
  • funcaofunction

Controle de Fluxo

  • seif
  • senaoelse
  • senao seelse if
  • parafor
  • enquantowhile
  • facado
  • interrompabreak
  • continuecontinue
  • retornareturn
  • comutaswitch
  • casocase

Try/Catch

  • tentetry
  • capturecatch
  • finalmentefinally
  • lancethrow

Valores

  • verdadeirotrue
  • falsofalse
  • nulonull
  • indefinidoundefined

Classes e OOP

  • classeclass
  • estendeextends
  • construtorconstructor
  • estaticostatic
  • novonew
  • estethis
  • supersuper

Async/Await

  • asincronoasync
  • aguardeawait

Módulos

  • exportaexport
  • importaimport
  • padraodefault
  • comoas
  • defrom

🔧 Funções Built-in

Console

  • escreva()console.log()
  • erro()console.error()
  • aviso()console.warn()
  • info()console.info()

Arrays

  • .paraCada().forEach()
  • .mapeie().map()
  • .filtre().filter()
  • .reduza().reduce()
  • .encontre().find()
  • .algum().some()
  • .todo().every()

Strings

  • .inclui().includes()
  • .comecaCom().startsWith()
  • .terminaCom().endsWith()
  • .divida().split()
  • .maiuscula().toUpperCase()
  • .minuscula().toLowerCase()

Math

  • aleatorio()Math.random()
  • arredonde()Math.round()
  • piso()Math.floor()
  • teto()Math.ceil()

💻 Uso Programático

const jsbr = require('jsbr');

// Compilar código
const codigoJSBr = `
  funcao soma(a, b) {
    retorna a + b;
  }
  escreva(soma(2, 3));
`;

const codigoJS = jsbr.compile(codigoJSBr);
console.log(codigoJS);

// Executar diretamente
jsbr.run(codigoJSBr);

🎯 Exemplos Completos

Servidor Web (Express)

importa express de "express";

constante app = express();
constante porta = 3000;

app.get("/", (req, res) => {
  res.send("Olá do JSBr!");
});

app.listen(porta, () => {
  escreva("Servidor rodando na porta " + porta);
});

Classe e Herança

classe Pessoa {
  construtor(nome, idade) {
    este.nome = nome;
    este.idade = idade;
  }
  
  apresentar() {
    retorna "Olá, sou " + este.nome;
  }
}

classe Desenvolvedor estende Pessoa {
  construtor(nome, idade, linguagem) {
    super(nome, idade);
    este.linguagem = linguagem;
  }
  
  programar() {
    escreva(este.nome + " está programando em " + este.linguagem);
  }
}

variavel dev = novo Desenvolvedor("João", 25, "JSBr");
escreva(dev.apresentar());
dev.programar();

Async/Await

asincrono funcao buscarDados() {
  tente {
    variavel resposta = aguarde fetch("https://api.exemplo.com/dados");
    variavel dados = aguarde resposta.json();
    retorna dados;
  } capture (erro) {
    erro("Erro ao buscar dados:", erro);
  }
}

buscarDados().then(dados => escreva(dados));

🤝 Contribuindo

Contribuições são bem-vindas! Sinta-se à vontade para:

  1. Fazer fork do projeto
  2. Criar uma branch para sua feature (git checkout -b feature/MinhaFeature)
  3. Commit suas mudanças (git commit -m 'Adiciona MinhaFeature')
  4. Push para a branch (git push origin feature/MinhaFeature)
  5. Abrir um Pull Request

📄 Licença

MIT License - veja o arquivo LICENSE para detalhes.

🌟 Roadmap

  • [ ] Suporte a TypeScript (JSBr com tipos)
  • [ ] Plugin para VS Code com syntax highlighting
  • [ ] REPL interativo
  • [ ] Geração de source maps
  • [ ] Suporte a JSX/React
  • [ ] Integração com frameworks (Vue, React, Angular)
  • [ ] Playground online
  • [ ] Documentação completa

👥 Autor

Feito com ❤️ para a comunidade brasileira de desenvolvedores!


JSBr - Porque programar em português é massa! 🚀🇧🇷