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

node-module-info

v0.1.4

Published

Full information about module in NodeJS

Downloads

33

Readme

node-module-info npm versionBuild StatusCoverage Status

Full information about module in NodeJS.

Install

npm install node-module-info --save

Example

var getInfo = require("node-module-info");
getInfo("./module1", "/path/to/caller/");
getInfo("dependence1/file1", "/path/to/caller/");
getInfo("/absolute/file/of/module", "/path/to/caller/");
getInfo("/module/without/caller");

Usage

Lib supports:

getCallerInfo: () => Info; //return same info about caller
getFullPath: () => string; //get full path (resolved only for dependence)
getResolvedPath: () => string;  //resolve module path, throw error for non-existing
getRootPath: () => string; //root path of app (get first path, before first node_modules)
getPackagePath: () => string; //package path for current module
getRelativePath: () => string; //relative path from package path
getRelativeName: () => string; //relative path without extension
getDefineName: ()=>string;//name for use with builders, `npm!package@version#path`
isAbsoulte: () => boolean; //is module path absolute
isDependence: () => boolean; //is dependence of caller (if caller setted) or false
isRelative: () => boolean; //is starts with "." if caller setted, or if not absolute
isSystem: () => boolean; //if caller setted check for internal modules
getPackageInfo: () => { //info from package.json from package path
    name: string;
    version: string;
    ///...full info
};

Typings

export interface Info {
    getFullInfo: () => {
        fullPath: string,
        resolvedPath: string,
        rootPath: string,
        packagePath: string,
        relativePath: string,
        relativeName: string,
        defineName: string,
        isDependence: boolean,
        isSystem: boolean,
        isAbsolute: boolean,
        isRelative: boolean,
        packageInfo: Package,
        nearestPackageJSON: string
    },
    getCallerInfo: () => Info;
    getFullPath: () => string;
    getResolvedPath: () => string;
    getRootPath: () => string;
    getPackagePath: () => string;
    getRelativePath: () => string;
    getRelativeName: () => string;
    getDefineName: () => string;
    isAbsoulte: () => boolean;
    isDependence: () => boolean;
    isRelative: () => boolean;
    isSystem: () => boolean;
    getPackageInfo: () => Package;
}
export interface Package {
    name: string;
    version: string;
}

Tests

npm install
npm test