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 🙏

© 2026 – Pkg Stats / Ryan Hefner

libdsm

v1.3.0

Published

A nodejs binding library for libdsm

Readme

node-libdsm

node-libdsm is a nodejs library to connect to SMB shares (Windows or Samba shared folders). It's a nice alternative to samba-client. Instead of using smbclient to connect to remote hosts, node-libdsm use Videolabs' libdsm, which is much efficient than spawning and listening to smbclient.

Requirements

node-libdsm is compatible with macOS, Windows and Linux.

Installation

npm install libdsm

or

yarn add libdsm

Content

This lib exports 3 classes :

  • SMBSession: Used to connect to a remote host
  • SMBShare: Manage actions on shared folders
  • NetbiosNS: Netbios hepers

Raw access to libdsm is given through the Libdsm exported property.

How to use

new SMBSession(opts)

  • opts (<object>): Session parameters :
  • host (<string>): Remote host name or IP address.
  • user (<string>): Username to connect to host.
  • password (<string>): User's password.
  • domain (<string>): Remote host Active Directory domain (optional).

Creates a new Session to a remote host.

const { SMBSession } = require("libdsm");
const opts = {
  domain: "MYDOMAIN", // Active Directory domain
  server: "10.0.0.1", // hostname or IP
  user: "users",
  password: "P@s5w0rd",
};

const session = new SMBSession(opts);
session.connect().then(() => {
  console.log("Connected to server");
});

session.connectToSharedFolder(name)

  • name (<string>): name of the shared folder you want to connect to.

  • Returns a <Promise> which is resolved with a <SMBShare>.

Connect to one of the host shared folder.

session
  .connect()
  .then(() => {
    return session.connectToSharedFolder("C$");
  })
  .then((share) => {
    console.log("Connected to shared folder C$");
  });

session.disconnect()

  • Returns a <Promise> which is resolved with no argument.

Disconnect from remote host, opened shares or files will be closed.

const session = new SMBSession(opts);
session
  .connect()
  .then(() => {
    console.log("Connected to server");
  })
  .then(() => {
    // Every connected folders will be disconnected
    // Every opened files will be closed
    session.disconnec();
  });

share.listFiles([[path], fileFilter])

  • path (<string>): path of the directory. Pass undefined, null, false or '' to get share root directory content.

  • fileFilter (<RegExp> | <Function>): used to test if a file should be added to directory content listing.

  • Returns a <Promise> which is resolved with a list of <string> representing directory content.

List remote directory content.

share.listFiles("my-folder"); // list content of the folder my-folder in the share
// Output example : ['my-folder\file.txt', 'my-folder\Picture.jpg']

or

share.listFiles(); // list content of the share root
// Output example : ['file.txt', 'Picture.jpg']

Output contains full path information.

listFiles can filter results by passing a <RegExp> or <Function> as second argument.

// Returns only files ending with .txt (case insensitive)
share.listFiles("my-folder", /\.txt$/i);

// Returns only files wich name contains 'foo'
share.listFiles("my-folder", (file) => file.indexOf("foo") >= 0);

share.listFilesRecursively([[path], [fileFilter, [directoryFilter, [depth]]]])

  • path (<string>): path of the directory. Pass undefined, null, false or '' to get share root directory content.

  • fileFilter (<RegExp> | <Function>): used to test if a file should be added to the content listing.

  • directoryFilter (<RegExp> | <Function>): used to test if a directory content should be added to the content listing.

  • depth (<number>): Recursion depth. Default to Infinity.

  • Returns a <Promise> which is resolved with a list of <string> representing directory content.

Recursively list directory content.

// List all files and folders contained inside the share root folder
share.listFilesRecursively();

// List all .txt files of the share, only if path contains log
share.listFilesRecursively("", /\.txt$/i, /log/i);
// Output example : ['logs\file.txt', 'logs\http\file.txt', 'logo\readme.txt']

share.getFileContent(path)

  • path (<string>): Path of the file to read.

  • Returns a <Promise> which is resolved with a <Buffer>, the raw file content.

Read a remote file content.

share
  .getFileContent("my-file.txt")
  .then((contentBuffer) => console.log(contentBuffer.toString()));

share.writeFileContent(path, content)

  • path (<string>): Path of the file to write.

  • content (<buffer> | <string>): content to write to remote file.

  • Returns a <Promise> which is resolved with no argument.

Write content to a remote file.

share
  .writeFileContent("out.txt")
  .then((contentBuffer) => console.log("write OK"));

share.removeFile(path)

  • path (<string>): Path of the file to remote.

  • Returns a <Promise> which is resolved with no argument.

Remove a file from the remote share.

share.removeFile("foo.txt");

share.createDirectory(path)

  • path (<string>): Path of the directory to create.

  • Returns a <Promise> which is resolved with no argument.

Create a directory inside the remote share

share.createDirectory("new-directory");

share.removeEmptyDirectory(path)

  • path (<string>): Path of the directory to remove.

  • Returns a <Promise> which is resolved with no argument.

Remove a directory. The directory must be empty.

share.removeEmptyDirectory("new-directory");

share.removeDirectory(path)

  • path (<string>): Path of the directory to remove.

  • Returns a <Promise> which is resolved with no argument.

Recursively delete directory content, then remove direcory.

share.removeDirectory("new-directory");

share.copyLocalFileToRemote(in, out)

  • in (<string>): Path of the local source file.

  • out (<string>): Path of the remote file destination.

  • Returns a <Promise> which is resolved with no argument.

Copy a local file to the remote host.

share.copyLocalFileToRemote("in.txt", "folder/out.txt");

share.copyRemoteFileToRemote(in, out)

  • in (<string>): Path of the remote source file.

  • out (<string>): Path of the remote file destination.

  • Returns a <Promise> which is resolved with no argument.

Copy a remote file to the remote host.

share.copyRemoteFileToRemote("some/folder/in.txt", "some/other/folder/out.txt");

share.copyRemoteFileToLocal(in, out)

  • in (<string>): Path of the remote source file.

  • out (<string>): Path of the local file destination.

  • Returns a <Promise> which is resolved with no argument.

Copy a remote file locally.

share.copyRemoteFileToLocal("some/folder/in.txt", "some/other/folder/out.txt");