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

npm_plugin_example

v0.2.5

Published

A NPM Plugin Test

Downloads

22

Readme

npm plugin example

installation

npm install npm_plugin_example

description of the plugin

In the rootfloder of the project there is the main.js. From here we require the Plugins that are lying inside the Plugins folder. Inside the rootfolder there is one file right now, the jquery.helperTools.js, where the "Plugins" are bundled. Maybe it is useful to split these files. Inside this file, we have multiple Modules. The syntax of defining an npm module is

module.exports.moduleName = (function() {
	//functions
})();

Inside these modules we can declare functions and variables as usual. We also can define functions that can be accessed from another scope. Example:


//global functions. can be accessed from all modules.
function createPlugin(name) {
	return `Creating Plugin for ${name}.`
}

//...

module.exports.mathHelpers = (function() {
	//our functions and variables. These cannot be accessed from another scope
	var pluginName = 'math',
		defaults = {
			fieldA : 'js-field-a',
			fieldB : 'js-field-b',
			submit : 'js-submit'
		};

	//function for adding two numbers.
	function add(a,b) {
		return a + b;
	}

	//...

	//we can return an object where we declare variables and functions. those functions can be accessed from another scope.
	return {
		//functions always return something.
		getPlugin: function (options) {
			//Wraps the Plugin as a jQuery Plugin
			return createPlugin(pluginName);
		},
		testPlugin: function (a, b) {
			var str = `a: ${a}, b: ${b}, Add: ${add(a,b)}, multiply: ${multiply(a,b)}, sqrt1: ${sqrt(a)}, sqrt2: ${sqrt(b)}`;
			return str;
		}
	}
})();

In the main.js we can require multiple modules. We can also access the variables and functions that we returned.

//requiring the actual file
var helperTools = require('./plugins/jquery.helperTools.js'),
	//requiring the actual modules
	//Works like this: moduleName = helperTools.moduleName,
	mathHelpers = helperTools.mathHelpers,
	greetingsHelpers = helperTools.greetingsHelpers;
//access a function we defined before
console.log(mathHelpers.testPlugin(4,4)); //output: a: 4, b: 4, Add: 8, multiply: 16, sqrt1: 2, sqrt2: 2

running the plugin

npm start

testing the plugin (not implemented yet)

npm test