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

ireq

v2.0.0

Published

NodeJS require improovement

Downloads

4

Readme

node-ireq

NodeJS require improovement Module adds requirement biding, relarive to defined project-root path. Made to remove './../../../' hell in deep-nested module (and bring other tricks).

Installation

Just install this via NPM

$ nmp install ireq --save

Usage

You must initiate module first to define project-root.

// index.js
const ireq = require('ireq');
ireq.init(__dirname);
const fs = ireq('fs');

Features

Path binding

You can bind any root-relative path to ireq propery and use it all around the project;

// module.js
const ireq = require('ireq');
ireq.bind('foo', '/path/to/foo');

const bar = ireq.foo('./bar.json');

... or unbind those

ireq.unbind('foo');
// this line will throw an error that there is no such binding
const bar2 = ireq.foo('bar.json');

Use functional syntax if you prefer

const bar = ireq.get('foo', './bar.json');

Nested bindings

Ireq allows You to bind nested paths and require them with dot-case:

ireq.bind('foo', '/path/to/foo');
ireq.foo.bind('bar', '/long/long/long/path/bar');

const fooModule = ireq.foo('./module.js');      // /path/to/foo/module.js
const barModule = ireq.foo.bar('./module.js');  // /path/to/foo/long/long/long/path/bar/module.js

Folder lookup

You can access all modules in binded folder with importing a folder itself. All modules accessable by filenames.

No index.js needed!

Consider we have following directory tree:

.
+-- index.js
+-- utils
|   +-- stringUtils.js
|   +-- numberUtils.js

Notice, there is no index.js in utils folder!

Then requirement of util modules will look similar to this code:

ireq.bind('utils', '/utils');

const { stringUtils, numberUtils } = ireq.utils('');
// stringUtils contains exports of /utils/stringUtils.js
// numberUtils contains exports of /utils/numberUtils.js

Changelog

v.1.0 -- Main-module relative binding and importing.

v.1.1 -- Root path binding and initializing.

v.2.0 -- Automated index lookup for binded folder, and nested bindings.

License

Product is shared under MIT licence.