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

flipfind

v0.1.4

Published

auto-find & resolve a file or path that is somewhere nearby in an optimized manner

Downloads

33

Readme

🔎 🎯 flipfind

find and resolve files automatically searches nearby paths in an optimized order

NPM version MIT License fliphub flipfam

usage

yarn add flipfind
npm i flipfind --save
// can be used as a class for chaining and debugging
const {Finder} = require('flipfind')

// or as a function for easier fun
const finder = require('flipfind')

🔊 debug

example debug output

const found = Finder.file('./src/eh').debug().all().asObj().find()

👣 steps

to optimize, it will go through the steps in order and return once it finds the correct existing path. If .debug is used with .all, it will go through every step and output the results so you can see the process.

  1. if a file and dir are given, it will attempt to resolve using file + dir
  2. if the given file is absolute, and if it exists
  3. checks with the cwd
  4. checks with require.main extracts the dirname from it
  5. checks the app-root-path
  6. checks a glob for very near files
  • filters to ensure it does-include the file and/or dir passed in through options
  1. checks with the mono-root

📘 examples

// will return null
const found = Finder.file('not-real').find()

// without ext
Finder.file('eh').find()
// with ext
Finder.file('eh.js').find()
// can use relative,  
Finder.file('./src/eh').find()
// or shorthand
Finder.file('src/eh').find()
// with dir
Finder.file('eh').dir('test/fixtures').find()

// return an object
const {
  abs,
  file,
  name,
  ext,
  dir,
} = Finder.file('src/eh').asObj().find()

// as function
find('src/eh')

📝 todo

  • add fallback for resolving a file that does not yet exist - currently is null, will require an option
  • cache the results