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

@fabiobianchinicano/add-logging

v1.0.0

Published

En esta práctica trabajamos con un programa que hace que dentro de cada función que se ejecuta se añada una línea que imprima por consola que se está entrando a dicha función. Se nos pide añadir una modificación para que aparte de eso también imprima los

Downloads

22

Readme

Informe Práctica Espree Logging

En esta práctica trabajamos con un programa que hace que dentro de cada función que se ejecuta se añada una línea que imprima por consola que se está entrando a dicha función. Se nos pide añadir una modificación para que aparte de eso también imprima los parámetros con los que se llama a dicha función.

Los pasos a realizar antes de ponernos a tocar el código son:

Instalar las dependencias en el repositorio en el que trabajaremos, se hace usando el comando npm i. Estas dependencias quedan expresadas en el fichero package.json

Ahora utilizaremos node para ejecutar el programa. Si queremos hacer uso del debugger de Chrome ejecutamos node --inspect-brk fichero.js y así la terminal deja escuchando en la dirección 127.0.0.1 (la nuestra) para que Chrome se pueda conectar con un web socket al fichero que hemos pasado con ese comando de forma remota.

Una vez analizado el código utilizando los breakpoints que nos ofrece el debugger de Chrome procedemos a realizar la modificación de la práctica, la cual simplemente se hace declarando un array dentro de la función addBeforeCode en el que metemos todos los parámetros de la función que se está analizando. En concreto esta función está ya parseada a estas alturas del programa, con lo cual tenemos que inspeccionar un árbol sintáctico del que sacaremos dichos parámetros. Luego simplemente añadimos en el console.log() después del nombre de la función el nuevo array que hemos rellenado.

Work in Repl.it

About

This repository contains code samples from the talks:

  1. Parsing, Compiling, and Static Metaprogramming at JSConfEU 2013 by Patrick Dubroy.
  2. Master the Art of the AST and Take Control of Your JS by Yonatan Mevorach.
  3. Talk on the same topic at Javascript Israel by Yonatan Mevorach

Talk Master the Art of the AST and Take Control of Your JS by Yonatan Mevorach

ASTExplorer

  • astexplorer.net demo

ESLint Piggyback example

  • ESLint: Working with Plugins
  • eslint-plugin-piggyback

Babel remove "debugger" example

  • Babel plugin Remove debugger transform. This plugin removes all debugger; statements
  • babel-plugin-transform-remove-debugger at GitHub

jscodeshift example

  • codeshift at GitHub
  • Write Code to Rewrite Your Code: jscodeshift
  • jscodeshift example
  • jscodeshift cpojer/js-codemod no-vars.js

Repositorios interesantes de cowchimp

  • AST Scout is a tool for analyzing and visualizing the relationship between the public API of a Class\Module and its implementations details (e.g. private methods, dependencies used).
  • A web tool to explore the ASTs generated by various parsers. https://astexplorer.net/
  • A curated list of awesome AST resources

Talk Babel plugins: Writing code that writes code - SingaporeJS

Talk Parsing, Compiling, and Static Metaprogramming at JSConfEU 2013 by Patrick Dubroy.

Esprima Examples

  • checkstyle.coffee and logging.coffee contain the original source code for the style checker and logging examples presented in the talk.
  • checkstyle.js and logging.js are the slightly simplified JS versions that were shown in the talk.
  • syntax-highlight.js is taken from the Esprima tutorial Chapter 3. Lexical Analysis (Tokenization)¶

PEG.js Example

altjs.coffee is the code for the "AltJS language in 5 minutes" section presented in the second half of the talk.

Extra Special Bonus!

idgrep.coffee (and idgrep.js) is another example of using Esprima to do static analysis on JavaScript code.

REPL example

> esprima = require('esprima')
{ parse: [Function: parse],
  parseModule: [Function: parseModule],
  parseScript: [Function: parseScript],
  tokenize: [Function: tokenize],
  Syntax: 
   { ... },
  version: '4.0.1' }

> esprima.tokenize('answer = 42', { range: true })
[ { type: 'Identifier', value: 'answer', range: [ 0, 6 ] },
  { type: 'Punctuator', value: '=', range: [ 7, 8 ] },
  { type: 'Numeric', value: '42', range: [ 9, 11 ] } ]

> esprima.parseScript('const answer = 42', { tokens: true })
Script {
  type: 'Program',
  body: 
   [ VariableDeclaration {
       type: 'VariableDeclaration',
       declarations: [Array],
       kind: 'const' } ],
  sourceType: 'script',
  tokens: 
   [ { type: 'Keyword', value: 'const' },
     { type: 'Identifier', value: 'answer' },
     { type: 'Punctuator', value: '=' },
     { type: 'Numeric', value: '42' } ] }

> inspect = require('util')
{ ... }

> console.log(util.inspect(esprima.parseScript('answer = 42'), {depth: null}))
Script {
  type: 'Program',
  body: 
   [ ExpressionStatement {
       type: 'ExpressionStatement',
       expression: 
        AssignmentExpression {
          type: 'AssignmentExpression',
          operator: '=',
          left: Identifier { type: 'Identifier', name: 'answer' },
          right: Literal { type: 'Literal', value: 42, raw: '42' } } } ],
  sourceType: 'script' }
undefined
>