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

node-resourcer

v0.2.2

Published

This module attempts to ease the loading and parsing of resource files into the application. It'll load automatically any file of a known format into a hash. That hash will be structured accordingly to the folder structure.

Readme

#Resourcer

This module attempts to ease the loading and parsing of resource files into the application. It'll load automatically any file of a known format into a hash. That hash will be structured accordingly to the folder structure.

So, a JSON file stored on: resources/jsons/names.json with the following structure:

{ 
	firstNames : ["Alicia", "Michel", "Penelope"]
}

You can use Resourcer like this:

var resourcer = require("resourcer")();

resourcer.init({
	path: "/resources/"
});

//.... later on
console.log(resourcer.R.jsons.names.firstNames);
//This will print: ["Alicia", "Michel", "Penelope"]

##Init method

The init method takes two arguments: options and an optional callback.

The options supported are:

  • path: (Mandatory) It's the relative path of the folder containing all the resources.
  • extraFormats: (Optional) Hash containing the extra known formats and their respective parsers.
  • verbose: (Optional, defaulted to false) If true, errors and info messages will be printed on the console.

The optinal callback will be executed after all the resources are loaded.

##Known formats

By default, Resourcer is able to parse JSON and XML file formats, but it's easily extensible, allowing other file formats to be used. In order to add support for other formats, just specify the extension and it's parser on the initmethod:

resourcer.init({
	path: "/resources/",
	extraFormats: {
		txt: parserFunction
	}
});

The parser function will receive the content of the file, and a callback. The callback function receives two parameters, an error (if any) and the json structure that the resource was turned into.

##Original content

Even though all resources are turned into a JSON structure, it's original form is kept, in case it's required by the developer. In order to access the original content, just call the original method from the resource.

Going back to the first example, doing:

resourcer.R.jsons.names.original();

Will return the string content of the file names.json This can be specially useful for non-json resources.

##Resource list

The nodes of the resource tree that don't represent the content of a specific file, are called PathNodes and they are able to list their child resources, using the method listResources.

i.e:

console.log(resourcer.R.jsons.listResources());
//Will print: ['names']

##Contributing

If you feel like contributing with bug-fixing, new features or just ideas, please create the issue and (if required) the pull-request.