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

noda

v0.6.0

Published

NOde Developing Assistant

Downloads

27,204

Readme

noda

NOde Developing Assistant

noda is a very lower-level package which will help you easily accessing files and directories in your package or adjacent to your Node.js file.

Table of contents

Links

Get Started

const noda = require('noda');

const foo = noda.inRequire('util/foo');
// require <homedir>/util/foo.js
// Here <homedir> is home directory of current node.js package(module).

const bar = noda.osRequire('./foo/bar');
// require ./foo/bar/<platform>.js
// Here platform equals to the returned value of os.platform().

const lib = noda.requireDir('./lib');
// require all sub modules in ./lib and return a hash object

API

Before read APIs, please understand that

  1. The phrase "current package" refers to the NPM package which contains the nodejs file where code noda.* located.
  2. Parameter subpath refers to pathname relative to the basepath of "current package".
  3. Because all functions are synchronous, postfix Sync is omitted.
  4. For functions with name prefixed with preposition in, the scope is "current package". E.g. noda.inRead() will read a file in current package.
  5. For functions with name prefixed with preposition next, up and down, the scope is "current file". E.g. noda.nextRead() will read a file adjacent to current file.
  • noda.bindings(string name)
    Require an addon.node.
    This method is allowed to be required as noda/bindings.

  • noda.packageOf(string id, Object module)
    Return the object parsed from package.json which belongs to the special package named id according to the view angle of special module.

  • noda.currentPackage()
    Return the object parsed from package.json which belongs to current package.

  • noda.once(Function action)
    Run specified function immediately when the code is first time reached.

  • noda.inExists(string subpath, boolean resolveAsModule)
    Judge whether file or directory exists. If resolveAsModule set true, subpath will be tentatively regarded as JS/JSON module path in the current package when the exact file not exists. This method is synchronuous.

  • noda.inRead(string subpath [, string encoding, boolean nullIfNotFound ])
    Read content of file.

  • noda.inReaddir(string subpath)
    Read the contents of a directory.

  • noda.inRequire(string subpath)
    Require js or json.

  • noda.inRequireDir(string dirname, Array | string ignores)
    Based on requireDir(), but the dirname is regarded as relative path to home directory of the package in which the caller is located.
    ignores includes those that SHOULD NOT be required. If '*/' contained in ignores, all sub directories will not be required whether or not index.js exists in the sub directories. If '*' contained in ignores, all .js files will not be required.

  • noda.inResolve(string subpath)
    Resolve the subpath into an absolute path.

  • noda.nextRead(string subpath [, string encoding, boolean nullIfNotFound ])
    Read content of file.

  • noda.osRequire(string dirname)
    Require module whose name is same with the name of current platform. Relative dirname is acceptable.

  • noda.requireDir(string dirname, Array | string ignores)
    Read the directory and require all javascript modules except those excluded, and returned them in an object with keys equal to modules' name. Relative dirname is acceptable.
    ATTENTION:Directory "node_modules" is always ignored whether or not it is explictly added in ignores.

  • noda.upResolve(string pathname)
    Find sub-directory or file in ascent directory and return the full path.

  • noda.downResolve(string pathname [, number depth, string order ])
    Find sub-directory or file in descent directory and return the full path. The value of order may be DFS (means depth-first search) or BFS (means breadth-first search).

  • noda.existsInPackage
    Alias of noda.inExists.

  • noda.readInPackage
    Alias of noda.inRead.

  • noda.requireInPackage
    Alias of noda.inRequire.

  • noda.requireDirInPackage
    Alias of noda.inRequireDir.

  • noda.resolveInPackage
    Alias of noda.inResolve.

Examples

Suppose that there is an NPM package named ching:

+ ching
  + bin
  + command
  + lib
  + node_modules
  + util
  . CHANGELOG.md
  . conf.js
  . index.js
  . package.json
  . README.md

Let's see what noda can do.

// FILE: ching/command/init/index.js
const noda = require('noda');

// Read ching/package.json and return the parsed JSON object.
noda.currentPackage();

// Require ching/util/rc.js and return.
noda.inRequire('util/rc');