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 🙏

© 2026 – Pkg Stats / Ryan Hefner

babel-plugin-hashp

v1.0.0

Published

A Babel plugin for better debugging

Readme

babel-plugin-hashp

babel-plugin-hashp is a Babel plugin inspired by Clojure's Hashp library. It provides an easy way to add debug logging to your JavaScript code.

Usage

Once installed, you can use the #p prefix to log expressions in various contexts:

// 1. Basic variable declaration
let #p count = 1;
// Transforms to:
let count = 1;
console.log("#p count => ", count);


// 2. Expression in variable declaration
let #p sum = 1 + 1;
// Transforms to:
let sum = 1 + 1;
console.log("#p sum => ", sum);


// 3. Object property
const obj = { name: "John", #p age: 3 };
// Transforms to:
const obj = {
  name: "John",
  age: (value => {
    console.log("#p age => ", value);
    return value;
  })(3)
};


// 4. Array element
const arr = [1, 2, 3, #p 4, 5];
// Transforms to:
const arr = [1, 2, 3, (value => {
  console.log("#p 4 => ", value);
  return value;
})(4), 5];


// 5. Function argument
function greet(#p name) { return name + '!'}
// Transforms to:
function greet(name) {
  console.log("#p name => ", name);
  return name + '!';
}
greet(5);


// 6. Return value
function calculateArea(width, height) {
  return #p (width * height);
}
// Transforms to:
function calculateArea(width, height) {
  return (value => {
    console.log("#p (width * height) => ", value);
    return value;
  })(width * height);
}
calculateArea(2,3);


// 7. Conditional expression
const isEven = #p (count === 1 ? 7 : "wrong");
// Transforms to:
const isEven = (value => {
  console.log("#p (count === 1 ? 7 : \"wrong\") => ", value);
  return value;
})(count === 1 ? 7 : "wrong");


// 8. Template literal
const message = `The count is ${#p (count + 7)}`;
// Transforms to:
const message = `The count is ${(value => {
  console.log("#p (count + 7) => ", value);
  return value;
})(count + 7)}`;


// 9. Arrow function
const double = (x) => #p (x * 2 - 1);
// Transforms to:
const double = x => (value => {
  console.log("#p (x * 2 - 1) => ", value);
  return value;
})(x * 2 - 1);
double(5);


// 10. Object method
const calculator = {
  add: (a, b) => #p (a + b),
};
// Transforms to:
const calculator = {
  add: (a, b) => (value => {
    console.log("#p (a + b) => ", value);
    return value;
  })(a + b)
};
calculator.add(5, 5);


//11. Destructuring assignment
const { #p x, y } = { x: 11, y: 20 };
// Transforms to:
const _temp = {
  x: 11,
  y: 20
};
const x = _temp.x;
const y = _temp.y;
console.log("#p x => ", x);


// 12. Spread operator
const newArr = [...#p arr, 6, 7, 8];
// Transforms to:
const newArr = [...(value => {
  console.log("#p arr => ", value);
  return value;
})(arr), 6, 7, 8];


// 13. Default parameter
function welcome(#p name = "12") {
  console.log(`Welcome, ${name}!`);
}
// Transforms to:
function welcome(name = "12") {
  console.log("#p name => ", name);
  console.log(`Welcome, ${name}!`);
}
welcome();


// 14. Nested object
const user = {
  details: {
    #p id: 13,
    email: "[email protected]"
  }
};
// Transforms to:
const user = {
  details: {
    id: (value => {
      console.log("#p id => ", value);
      return value;
    })(13),
    email: "[email protected]"
  }
};
Object.keys(user);


// 15. Array method argument
const numbers = [13, 14, 15];
const doubled = numbers.map(n => #p (n + 1));
// Transforms to:
const numbers = [13, 14, 15];
const doubled = numbers.map(n => (value => {
  console.log("#p (n + 1) => ", value);
  return value;
})(n + 1));


// 16. Async function
async function fetchData() {
  const response = await fetch('https://jsonplaceholder.typicode.com/todos/1');
  return #p (await response.json());
}
// Transforms to:
async function fetchData() {
  const response = await fetch('https://jsonplaceholder.typicode.com/todos/1');
  return (value => {
    console.log("#p (await response.json()) => ", value);
    return value;
  })(await response.json());
}
fetchData();


// 17. Class property
class Counter {
  #p count = 17;
  
  increment() {
    this.count++;
  }
}
// Transforms to:
class Counter {
  count = (value => {
    console.log("#p count => ", value);
    return value;
  })(17);
  increment() {
    this.count++;
  }
}
const counter = new Counter();


// 18. Multiple debug points in one expression
const result = #p (1 + #p (9 * 2));
// Transforms to:
const result = (value => {
  console.log("#p (1 + (9 * 2)) => ", value);
  return value;
})(1 + (value => {
  console.log("#p (9 * 2) => ", value);
  return value;
})(9 * 2));


// 19. Ternary operator
const status = #p (isEven ? "Even" : "Odd");
// Transforms to:
const status = (value => {
  console.log("#p (isEven ? \"Even\" : \"Odd\") => ", value);
  return value;
})(isEven ? "Even" : "Odd");


// 20. Tagged template literal
function debug(strings, ...values) {
  return strings.reduce((acc, str, i) => 
    acc + str + (#p values[i] || ''), '');
}
// Transforms to:
function debug(strings, ...values) {
  return strings.reduce((acc, str, i) => acc + str + ((value => {
    console.log("#p values => ", value);
    return value;
  })(values)[i] || ''), '');
}
const debugMessage = debug`Count: ${count}, Sum: ${sum}`;

Install

npm

npm install --save-dev babel-plugin-hashp

yarn

yarn add --dev babel-plugin-hashp

Configuration

You can configure the plugin by adding the following to your .babelrc file:

{
  "plugins": [
    ["babel-plugin-hashp"]
  ]
}

License

babel-plugin-hashp is released under the MIT license.