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

@zbox/nodejs

v0.5.0

Published

Node.js binding for ZboxFS

Downloads

166

Readme

zbox-nodejs

This pacakge is Node.js binding for ZboxFS.

ZboxFS is a zero-details, privacy-focused in-app file system. Its goal is to help application store files securely, privately and reliably. Check more details about ZboxFS.

Get Started

Installation

npm i @zbox/nodejs

Hello World Example

Visit https://zbox.io/try to create a test repo. Copy its URI and replace [your_repo_uri] in below.

const assert = require('assert').strict;
const Zbox = require('@zbox/nodejs');

(async () => {
  // create a Zbox instance
  const zbox = new Zbox();

  // initialise environment, called once before using Zbox
  await zbox.initEnv({ log: { level: 'debug' } });

  // open the repo
  var repo = await zbox.openRepo({
    uri: '[your_repo_uri]',
    pwd: 'secret password',
    opts: { create: true }
  });

  // create a file
  var file = await repo.createFile('/hello_world.txt');

  // write content to file
  await file.writeOnce('Hello, World!');

  // seek to the beginning of file
  await file.seek({ from: Zbox.SeekFrom.Start, offset: 0 });

  // read all content as string
  const str = await file.readAllString()
  assert.strictEqual(str, 'Hello, World!');

  // close file and repo
  await file.close();
  await repo.close();

})();

API Documentation

Check the API documentation at https://docs.zbox.io/api/.

How to Build

This is for advanced user. If simply use this package, you don't need to build by yourself as npm install will automatically download the pre-built binary.

This library needs to be compiled to platform-specific binary, it currently supports 64-bit Linux, macOS and Windows.

After running the building command, it will generate index.node shared library in native folder. This library must be used with javascript wrappers, which can be found in lib directory.

Linux

Prerequisites

Docker

Build

Use zboxfs/nodejs docker image to build the shared library.

docker run --rm -v $PWD:/root/zbox zboxfs/nodejs npm run build

macOS

Prerequisites

Rust

Build

Use below command to build the shared library.

npm run build

Windows

Prerequisites

  • Rust

  • windows-build-tools

    npm install --global --production windows-build-tools

Build

Use below command to build the shared library.

npm run build

License

This package is licensed under the Apache 2.0 License - see the LICENSE file for details.