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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@francisco-marques-armas/constant-folding

v1.0.5

Published

Adds logs to javascript code

Downloads

5

Readme

Open in Codespaces

Práctica Espree logging

Guía de uso

Para instalar el paquete, ejecute:

npm install @francisco-marques-armas/constant-folding

Para utilizar el ejecutable, escriba el siguiente comando:

npx funlog <fichero con la función>

Resumen de lo aprendido

Se han añadido opciones en la línea de comandos y mensajes en la entrada de funciones, anotando también el número de línea. Se cuenta con scripts en el package.json (test y cov) para poner a prueba el funcionamiento del programa y estos se ejecutan al realizar integración continua con Github Actions. El paquete ha sido publicado en npmjs con ámbito francisco-marques-armas. Se ha documentado y se ha probado que está accesible. Además, se realiza un estudio de cobertura y se ha aprendido el significado del versionado. imagen

...

Indicar los valores de los argumentos

Se ha modificado el código de logging-espree.js para que el log también indique los valores de los argumentos que se pasaron a la función. Ejemplo:

function foo(a, b) {
  var x = 'blah';
  var y = (function (z) {
    return z+3;
  })(2);
}
foo(1, 'wut', 3);
function foo(a, b) {
    console.log(`Entering foo(${ a }, ${ b })`);
    var x = 'blah';
    var y = function (z) {
        console.log(`Entering <anonymous function>(${ z })`);
        return z + 3;
    }(2);
}
foo(1, 'wut', 3);

CLI con Commander.js

Se han añadido opciones -h y -V automáticamente con Commander, y una opción que permite especificar el fichero de salida.

imagen

La opción -h nos permite mostrar una descripción del programa y sus opciones por la terminal.

imagen

La opción -V muestra la versión del programa. En este caso es la versión 1.0.4, ya que se trata de la primera versión funcional, no han habido parches y se han arreglado cuatro fallos.

imagen

La opción -o vuelva la salida en el archivo que especifiquemos.

imagen

Reto 1: Soportar funciones flecha

Se ha añadido una condición a la entrada del traverse de espree para que también analice nodos ArrowFunctionExpression.

imagen

Reto 2: Añadir el número de línea

Se cuenta con una variable lineN, que obtiene la propiedad del número de línea de la localización de comienzo del nodo, y se añade al mensaje que se implementa en el código.

imagen

Tests and Covering

Se realiza un estudio de cobertura del programa, con el script cov. Se utiliza c8 en vez de nyc porque el segundo causa problemas.

imagen