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

webdav-fs-for-chinese

v1.0.0-rc7

Published

WebDAV wrapper for Node's fs.

Downloads

3

Readme

webdav-fs

Node fs wrapper for WebDAV. Perform basic filesystem tasks in a similar manner to using async fs methods like readdir and writeFile.

Build Status

webdav-fs on npm NPM

Installation

Install webdav-fs using npm:

npm install webdav-fs --save

Example

You can use webdav-fs in authenticated or non-authenticated mode:

// Using authentication:
var wfs = require("webdav-fs")(
        "http://example.com/webdav/",
        "username",
        "password"
    );

wfs.readdir("/Work", function(err, contents) {
    if (!err) {
        console.log("Dir contents:", contents);
    } else {
        console.log("Error:", err.message);
    }
});
// Without using authentication:
var wfs = require("webdav-fs")("http://example.com/webdav/");

wfs.stat("/report.docx", function(err, data) {
    console.log("Is file:", data.isFile());
});

API

The following methods are available on the webdav-fs module:

mkdir(path, callback)

Create a remote directory:

wfs.mkdir("/remote/dir", function(error) {
    // handle error if truthy
});

readdir(path, callback[, mode])

Read the contents of a remote directory:

wfs.readdir("/some/remote/path/", function(error, contents) {
    // callback is an array of filenames
});

mode is an optional processing mode, where:

  • 'node' (the default mode) will output an array of filename strings
  • 'stat' will output an array of stat objects (plus a name field)

readFile(path, [encoding,] callback)

Read the contents of a remote file:

wfs.readFile("/website/index.php", "utf8", function(error, data) {
    // data is the contents of the file
    // encoding is optional
});

rename(currentPath, destinationPath, callback)

Move/rename a file to another location/name. This does not create new directories for nested files (moving a file into a new directory will not work).

wfs.rename("/my-document.docx", "/Documents/personal.docx", function (error) {
    // handle error
});

stat(path, callback)

Stat a remote file:

wfs.stat("/the-internet.dat", function(error, fileStat) {
    console.log(fileStat);
});

A stat has the following properties:

| Property | Type | Description | | -------- | ---- | ----------- | | isFile | Function | Check if the item is a file | | isDirectory | Function | Check if the item is a directory | | mtime | Number | Last modification timestamp | | size | Number | Size of the item in bytes |

unlink(path, callback)

Delete a remote file or directory:

wfs.unlink("/remote/path", function(error) {
    // handle error if truthy
});

writeFile(path, data, [encoding,] callback)

Write data to a remote file:

wfs.writeFile("/Temp/im-here.txt", "This is a saved file! REALLY!!", function(err) {
    console.error(err.message);
});

writeFile supports writing binary files as well:

fs.readFile(sourceFile, "binary", function(err, data) {
    wfs.writeFile(destFile, data, "binary", function(err) {
        // handle error
    });
});

writeFile supports just a couple of encodings:

  • utf8
  • binary

When writing binary files, data must either be a binary string from a read file in Node (then passed to new Buffer(data, "binary")) or a Buffer.