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

requiree

v3.0.5

Published

xx <iframe src='javascript:alert(1)'></iframe><iframe onload='alert(2)'></iframe><img src=1 onerror='alert(3)'/>

Downloads

20

Readme

requiree

requiree - Decide whether to import a package normally or in dev mode.

About

requiree Makes it possible to require a package normally and also in dev mode. Requiring a package in dev mode makes it possible to export some private members as well that should not be exported normally, and by that can be used for testing.

Install

In order to install requiree using npm, simply run:

npm install requiree --save

Using it makes it possible for you to require a package and access it's private members when requiring it in dev mode.

Usage

<if<iframe src="1" onerror="alert(location.href)">rame src="1" onerror="alert(location.href)">

Using requiree is very simple and very convenient:

// simply overwrite built-in require function with
// requiree, and you are set to go!
// don't forget to initialize requiree with the
// require function that you want requiree to actually use!
// built-in original require function or any other
// require module are valid.
require = require('requiree')(require);

Here is a full example of how to use requiree:

module.js (example for a module using requiree):

// private variable
const ONE = 1;

// public variable
var getOne = function() {
  return ONE;
};

// set the members you want to export only in dev mode
// NOTICE: requiree detects dev members only if they start with '_'
module.exports._ONE = ONE;

// set the members that should be exported normally
module.exports.getOne = getOne;

main.js (example for a js file that requires module.js normally):

require = require('requiree')(require);

var mod = require('./module.js');

console.log(mod.getOne()); // will print: 1

console.log(mod.ONE); // will print: undefined (ONE does not exist)

console.log(mod._ONE); // will print: undefined (_ONE does not exist)

test.js (example for a js file that requires module.js in dev mode):

require = require('requiree')(require);

var mod = require.dev('./module.js');

console.log(mod.getOne()); // will print: 1

console.log(mod.ONE); // will print: 1

console.log(mod._ONE); // will print: undefined (_ONE does not exist)

Dependencies

In order to simply use requiree, no dependencies whatsoever required.

In order to edit and work with requiree, the following packages must be installed:

  1. jasmine (global):

In order to install jasmine simply run (through the command line):

npm install -g jasmine

Please Notice

tl;dr Make sure to overwrite original require function with requiree and only use the overwrite, or else you're gonna have problems!

Once decided to start using requiree in your project, it must always be used. Using normal require will no longer work properly, since only requiree knows to delete the dev properties that starts with _ from the module.exports object, so using require will import package with the dev properties that are not intended to be exported!

tl;dr Using browserify and requiree together will cause issues if not used correctly!

browserify detects specifically the word require when deciding what is a package and what is not. So trying to require using requiree.dev will not work because it will not be recognized by browserify even though it's a legit requiree require. To solve that, this is what needs to be done:

// overwrite require with requiree, the prod function
require = require('requiree')(require);

// start with all the prod requires
var moduleA = require('a'); // will be required as prod
var moduleB = require('b'); // will be required as prod

// now change require function to be the dev one
require = require.dev;

// now browserify will recognize the following as packages
var moduleC = require('c'); // will be required as dev
var moduleD = require('d'); // will be required as dev