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

suspect

v1.0.3

Published

Get real files or directories names on case sensitive systems

Downloads

18

Readme

suspect

travis-ci

A package that allows you to deal with files and directories manipulations on case sensitive os. sometimes you need to get read a file that may be had different names on the OS.

"On windows, Readme.md, README.md and ReadMe.md are the same, but Linux says NO!" - someone from somewhere... nevermind!

to solve this problem, you can use this package to get the real name of your file or directory so that you can start writing code that will run on all systems and even on your toaster...! Just kidding, ok, no more jokes, let's get serious!!

Installation

    $ npm install suspect

How does it work

Once installed, you can require the module :

    var suspect = require("suspect");

you can then use the following methodes:

.find(path, callback)

This method finds asynchronously the real name of your file or directory you pass its path as first argument. If you think there can be more than one file, you can check findAll method.

    suspect.find('/path/to/file.txt', function (error, realName) {
        if(err) return console.error(err);
        console.log(realName);
    })
.findSync(path)

If you think you're noob and you don't like asynchronous stuff and callbacks, this one if for you, but you still need to use a try catch! It returns null when the file/dir name doesn't exist. check findAllSync if you're looking for all the file/dir names.

    suspect.findSync('/path/to/file.txt');
.findAll(path, callback)

Its name says everything, it returns an array of all files/dirs names, let's say you look for file.txt you can get an array like ['File.txt', 'FILE.txt', ...]

    suspect.findAll('/path/to/file.txt', function (error, allFilesNames) {
        if(err) return console.error(err);
        console.log(allFilesNames);
    })
.findAllSync(path)

You can use this method to make a synchronous call and get your array of files/dirs names found on the specified path.

    suspect.findAllSync('/path/to/file.txt');
.exists(path, callback)

This one is a bit special, if you run fs.exists("./FILENAME", callback) or fs.exists("./fIlEnAmE", callback) on windows, you probably get true even if you have only the file ./FilEnEMe on your path. However, if you want to check if the name you specified does really exist, then you can use this method

    suspect.exists('/path/to/file.txt', function (error, doesExist) {
        if(err) return console.error(err);
        console.log(doesExist); // outputs true or false
    })
.existsSync(path)

If you think that there is no need for a callback when you're waiting for a boolean, then here's your function!

    suspect.existsSync('/path/to/file.txt'); // returns true or false

License

MIT