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

qfs

v0.0.1

Published

File I/O in jQuery way

Downloads

3

Readme

#qfs

File I/O in jQuery way.

#Install

$ git clone git://github.com/tommy351/qfs.git

#Test

make test

#Example

// Get the stats synchronously
qfs(path).stat();

// Get the stats asynchronously
qfs(path).stat(function(err, stat){
  // do something
});

#Documentaion

##Core

###qfs(path, […])

path can be a path, or an array with multiple paths.

When pass multiple arguments, qfs will join them automatically.

Example:


qfs('/foo/bar');

qfs(['/foo', '/bar']);

qfs('/foo/bar', 'baz');

##Data

###path()

Get the path of the target.

Example:

qfs('/foo/bar').path();
// Return '/foo/bar'

qfs('/foo/bar/baz/..').path();
// Return '/foo/bar'

###name()

Get the name of the target.

Example:

qfs('/foo/bar').name();
// Return 'bar'

qfs('/foo/bar/baz.js').name();
// Return 'baz.js'

###dir()

Get the directory name of the target.

Example:

qfs('/foo/bar').dir();
// Return '/foo'

###ext()

Get the extension of the target.

qfs('/foo/bar/baz.js').ext();
// Return '.js'

###stat([callback])

Get the status of the target.

callback gets two arguments (err, stats).

Reference: Class: fs.Stats

###fstat([callback])

Same as stat, except that the target is specified by the file descriptor fd.

###lstat([callback])

Same as stat, except that if the target is a symbolic link, then return to the link itself.

###exists([callback])

Check whether the target exists or not.

callback gets one argument (exist).

##Query

###children([selector], [callback])

Get the children of the target directory.

selector can be a regular expression, function or a string.

callback gets two arguments (err, files).

###siblings([selector], [callback])

Get the siblings of the target directory.

selector can be a regular expression, function or a string.

callback gets two arguments (err, files).

###parent()

Get the parent of the target.

###parents()

Get the ancestors of the target, up to the root directory.

###parentsUntil(name)

Get the ancestors of the target, up to but not including the directory matched by the name.

##Filter

###eq(index)

Get the specified index of the target.

index can be a negative integer, counting backwards from last.

###first()

Get the first element of the target.

###last()

Get the last element of the target.

###slice(start, [end])

Get the elements of a specified range from the target.

start and end can be a negative integer, counting backwards from last.

###filter(selector)

Get the elements matched selector from the target.

selector can be a regular expression, function or a string.

Example:

// Regular expression
qfs(path).children().filter(/pattern/)

// Function
qfs(path).children().filter(function(i){
  return this.ext() === '.txt';
});

// String
qfs(path).children().filter('.txt');
qfs(path).children().filter('test.txt');

###not(selector)

Remove the elements matched selector from the target.

An inverse function of filter.

##Loop

###each(iterator)

Iterate over the target.

###map(iterator)

Produce a new object with return values.

##I/O

###mkdir(name, [callback])

Create a directory named name in the target directory.

No arguments other than a possible exception are given to the completion callback.

###rename(name, [callback])

Rename the target to name.

No arguments other than a possible exception are given to the completion callback.

###remove([callback])

Remove the target.

No arguments other than a possible exception are given to the completion callback.

###empty([callback])

If the target is a directory, remove everything in the target.

If the target is a file, clear the target.

No arguments other than a possible exception are given to the completion callback.

###write(data, [callback])

Write data to the target file.

If the target exists, overwrite the target with data, otherwise create a new file with data.

callback gets one argument (err).

###read([callback])

Read the data from the target.

If the target is a directory, get the children of the target.

If the target is a file, get the content of the target.

callback gets two arguments (err, data).

###append(data, [callback])

Append data to the target file.

If the target is a directory, create a new directory named data in the target.

If the target is a file, append data to the target.

callback gets one argument (err).

###content([data], [callback])

If data is defined, write data to the target file, otherwise read the data from the target.

callback get two arguments (err, data) when reading, one argument (err) when writing.

###chmod(mode, [callback])

Change the permissions of the target.

No arguments other than a possible exception are given to the completion callback.

###fchmod(mode, [callback])

Same as chmod, except that the target is specified by the file descriptor fd.

###lchmod(mode, [callback])

Same as chmod, except that the target is a symbolic link, then return to the link itself.

###chown(uid, gid, [callback])

Change the ownership of the target.

No arguments other than a possible exception are given to the completion callback.

###fchown(uid, gid, [callback])

Same as chown, except that the target is specified by the file descriptor fd.

###lchown(uid, gid, [callback])

Same as chown, except that the target is a symbolic link, then return to the link itself.

##Utilities

###toArray()

Transform the target to an array.