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

larvitfs

v2.3.1

Published

Cascading filesystem for node.js

Downloads

227

Readme

Build Status Dependencies Coverage Status

larvitfs

Get a local file from a "virtual" hierarchy, merged filesystem inspired by the Kohana Framework Cascading Filesystem.

The whole module is synchronous to work well with various template engines and other stuff. Since it returnes the resolved files from a local cache, this should normally not be a problem. However, if this module is used for thousands and thousands of files with different filenames this will have an performance impact.

Installation

npm i larvitfs

Usage

Load module

Paths are relative to process.cwd() as first priority. If nothing is found there, all modules will be tested as relative to this path to try to find a matching file. The modules are searched in the order given in package.json dependencies.

CommonJS

const LUtils = require('larvitutils'),
      Lfs    = require('larvitfs'),
      lfs    = new Lfs({
        'basePath':     process.cwd(),            // OPTIONAL
        'cacheMaxSize': 10000,                    // OPTIONAL
        'log':          new (new LUtils()).Log(), // OPTIONAL
        'fs':           require('fs')             // OPTIONAL
      });

ES6 modules

import Lfs from 'larvitfs';
const lfs = new Lfs({}); // And of course with all the options as above

getPathSync()

The idea here is to be able to share files between modules and application in a transparant way.

Lets say you'd wish to serve a HTML file, index.html. The default file resides in our little module "foobar" like this:

./node_modules/foobar/public/index.html

If we run getPathSync('public/index.html'); we'll get the full path back:

const Lfs = require('larvitfs'),
      lfs = new Lfs();

console.log(lfs.getPathSync('public/index.html'));
// /app/absolute/path/node_modules/foobar/public/index.html

But if we add this file to our own application, in ./public/index.html, that file will be higher in priority and will be returned instead:

const Lfs = require('larvitfs'),
      lfs = new Lfs();

console.log(lfs.getPathSync('public/index.html'));
// /app/absolute/path/public/index.html

All modules in node_modules will be searched for the given file. The priority is decided by the list order in dependencies in package.json.

getPathsSync()

The idea with this function is to be able to get a list of paths sorted in the dependency order. First local paths, then dependency paths and then everything else.

const Lfs = require('larvitfs'),
      lfs = new Lfs();

console.log(lfs.getPathsSync('public/index.html'));
// [
//	'/app/absolute/path/public/index.html',
//	'/app/absolute/path/node_modules/directDependency/public/index.html',
//	'/app/absolute/path/node_modules/indirectDependency/public/index.html'
//]