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

munge

v1.1.0

Published

a tiny node module to munge any strings. useful if you want to obfuscate email addresses to valid, numeric html entities.

Downloads

31

Readme

munge

Build Status

a tiny library to munge any strings (do not ask me why that verb). useful if wou want to obfuscate email addresses to valid, numeric html characters.

as long as spam robots are still dumb, this should significantly reduce the risk of the email address being harvested. i bet you get 60% less spam. this method is user friendlier and way easier to implement than other tricks like javascript or images. because you really can click on the link and it opens in your mail program.

basic example

by default, munge() encodes each letter by random - either ascii or unicode - to make it more difficult for spammers.

because of the random generator the example below does not always produce the same output:

var munge = require('munge');
console.log(munge('[email protected]'));

might output something like:

spacemonkey@moon.com

this is valid html code!

based on rfc1866, ftp://ftp.rfc-editor.org/in-notes/rfc1866.txt

more examples

ascii

var munge = require('munge');
console.log(munge('[email protected]', {encoding: 'ascii'}));

should encode the string with ascii like that:

spacemonkey@moon.com

utf8

var munge = require('munge');
console.log(munge('[email protected]', {encoding: 'utf8'}));

encodes the same blurb but in unicode:

spacemonkey@moon.com

jade/express integration

good idea. you will want to protect your email address on your contact page.

here how you can do it within express and jade. let's say in express you have a route for a contact page (routes/contact.js) like this:

var munge = require('munge');

exports.contact = function(req, res) {
  res.render('contact',
    {
      emailContact: munge('[email protected]')
    }
  );
};

then you can show the munged email address in a jade template called contact.jade with the lines like this inbetween:

...
p email: 
    a(href!="mailto:#{emailContact}") !{emailContact}
...

make sure you use ! exactly like this as this won't escape the ampersand (&) into an html entity. see TJ's remark about escaped stuff at https://github.com/visionmedia/jade#code

todo

  • implement a connect middleware to automagically munge any email addresses
  • have it a piped stream instead (for larger strings; not sure if it makes sense here)

license

MIT