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

qir

v0.4.1

Published

another fs

Downloads

1,552

Readme

qir

another fs

If links in this document not avaiable, please access README on GitHub directly.

Description

qir is variant of dir which is abbreviation of directory. Actually, this package is based on built-in module fs and offers easy utilities helping access with file system.

ToC

Links

Get Started

const qir = require('qir');

// Sync mode.
qir.syncing.mkd('/foo/bar/quz');

// Async mode.
qir.asyncing.rmfr('/foo').then(() => {
    // ...
});

API

There are two collections of methods in this package.

const qir       = require('qir');
const qirSync   = require('qir/syncing');
const qirAsync  = require('qir/asyncing');
const SyncDir   = require('qir/SyncDir');
const AsyncDir  = require('qir/AsyncDir');

qir.syncing  === qirSync    // true
qir.asyncing === qirAsync   // true
qir.SyncDir  === SyncDir    // true
qir.AsyncDir === AsyncDir   // true
  • class qir.AsyncDir( string basepath )
  • class qir.SyncDir( string basepath )
  • Object qir.syncing
  • Object qir.asyncing

The method collections syncing and asyncing are parallel, so are the classes AsyncDir and SyncDir.

Each of the method collections and class instances has following methods:

  • void | Promise(void)
    appendFile( string filename, string | Buffer data )

  • void | Promise(void)
    clear()
    Only available for instances of AsyncDir and SyncDir.
    Remove everything in the directory and the directory itself.

  • void | Promise(void)
    copy( string src, string dest)

  • void | Promise(void)
    copyFile( string src, string dest, number flags )

  • stream.Readable | Promise(stream.Readable)
    createReadStream( string filename[, Object options] )

  • stream.Writable | Promise(stream.Writable)
    createWriteStream( string filename[, Object options] )

  • boolean
    exists( string pathname )
    Only available for instances of AsyncDir and SyncDir.

  • string[]
    find( object options )
    Only available for asyncing and instances of AsyncDir.
    See sore/find for details of options.

  • void | Promise(void)
    link( string existingPath, string newPath )

  • void | Promise(void)
    mkd( string dirname )

  • void | Promise(void)
    mkd_temp( string dirname [, string prefix] )

  • void | Promise(void)
    mkd_parent( string pathname )

  • integer | Promise(integer)
    open( string filename [, string | number flags [, integer mode ] ] )

  • string | Buffer | Promis(string) | Promise(Buffer)
    readFile( string pathname )
    Only available for instances of AsyncDir and SyncDir.

  • JSON | Promise(JSON)
    readJSON( string filename )

  • string[] | Promis(string[])
    readdir( string dirname )

  • void | Promise(void)
    rename( string oldPath, string newPath )

  • string
    resolve( string pathname )
    Only available for instances of AsyncDir and SyncDir.

  • void | Promise(void)
    rmfr( string pathname )

  • fs.Stats | Promise(fs.Stats)
    stat( string pathname )
    ATTENTION: This method is some different from built-in fs.stats which will throws an Error if the target is not accessible. It will return null in such case.

  • void | Promise(void)
    symlink( string target, string pathname [, string type ] )

  • void | Promise(void)
    touch( string filename )

  • void | Promise(void)
    writeFile ( string filename, string | Buffer | TypedArray | DataView data )

  • void | Promise(void)
    writeJSON ( string filename, JSON json )

ATTENTIONS:

  • In asynchronous mode, the leading type names represent NOT what the function will return on invoked, BUT data in .then(data). Actually, each function will return an instance of Promise in asynchronous mode.

  • When pathname (dirname or filename) occurs in methods of new AsyncDir() and new SyncDir(), it will be regarded to be relative to the basepath.

  • Some methods accept same arguments with the homonynic methods in fs. But not each method has a symmetrical one in fs.

  • All methods in qir.asyncing and new AsyncDir() will return an instance of Promise.

  • All methods will automatically create parent directories if necessary.

Why qir

It is tedious to create an embedded directory with built-in module fs. E.g.

// If you wannt to create a directory /foo/bar/quz while /foo doesnot exist:
fs.mkdirSync('/foo');
fs.mkdirSync('/foo/bar');
fs.mkdirSync('/foo/bar/quz');

// You may complete these operations in one step via `qir`.
qir.syncing.mkd('/foo/bar/quz');