@jsonjoy.com/fs-snapshot
File system snapshot - serialize and deserialize file system trees to binary or JSON
Last updated 4 months ago by GitHub Actions .
Apache-2.0 · Repository · Bugs · Original npm · Tarball · package.json
$ npm install @jsonjoy.com/fs-snapshot 
SYNC missed versions from official npm registry.

@jsonjoy.com/fs-snapshot

File system snapshot - serialize and deserialize file system trees to binary (CBOR) or JSON format.

Installation

npm install @jsonjoy.com/fs-snapshot

Features

  • Serialize entire file system trees into compact binary (CBOR) or JSON snapshots
  • Restore file system trees from snapshots
  • Supports files, directories, and symbolic links
  • Both synchronous and asynchronous APIs
  • Works with any Node.js-compatible fs module

Usage

Synchronous API

import * as fs from 'fs';
import { toSnapshotSync, fromSnapshotSync } from '@jsonjoy.com/fs-snapshot';

// Create a snapshot of a directory
const snapshot = toSnapshotSync({ fs, path: '/path/to/directory' });

// Restore the snapshot to a different location
fromSnapshotSync(snapshot, { fs, path: '/path/to/restore' });

Asynchronous API

import * as fs from 'fs';
import { toSnapshot, fromSnapshot } from '@jsonjoy.com/fs-snapshot';

// Create a snapshot of a directory
const snapshot = await toSnapshot({ fs: fs.promises, path: '/path/to/directory' });

// Restore the snapshot to a different location
await fromSnapshot(snapshot, { fs: fs.promises, path: '/path/to/restore' });

Binary (CBOR) Snapshots

Binary snapshots are more compact and faster to serialize/deserialize:

import * as fs from 'fs';
import { toBinarySnapshotSync, fromBinarySnapshotSync } from '@jsonjoy.com/fs-snapshot';

// Create a binary snapshot
const binary = toBinarySnapshotSync({ fs, path: '/path/to/directory' });

// Restore from binary snapshot
fromBinarySnapshotSync(binary, { fs, path: '/path/to/restore' });

JSON Snapshots

JSON snapshots are human-readable and easier to debug:

import * as fs from 'fs';
import { toJsonSnapshotSync, fromJsonSnapshotSync } from '@jsonjoy.com/fs-snapshot';

// Create a JSON snapshot
const jsonSnapshot = toJsonSnapshotSync({ fs, path: '/path/to/directory' });

// Restore from JSON snapshot
fromJsonSnapshotSync(jsonSnapshot, { fs, path: '/path/to/restore' });

Snapshot Format

Snapshots are represented as tuples with the following structure:

  • Folder: [0, metadata, { entries }]
  • File: [1, metadata, Uint8Array]
  • Symlink: [2, { target: string }]

License

Apache-2.0

Current Tags

  • 4.80.1                                ...           latest (15 days ago)

49 Versions

  • 4.80.1                                ...           15 days ago
  • 4.80.0                                ...           2 months ago
  • 4.79.0                                ...           2 months ago
  • 4.78.1                                ...           2 months ago
  • 4.78.0                                ...           2 months ago
  • 4.77.0                                ...           2 months ago
  • 4.76.0                                ...           3 months ago
  • 4.75.0                                ...           3 months ago
  • 4.74.0                                ...           3 months ago
  • 4.73.0                                ...           3 months ago
  • 4.72.2                                ...           3 months ago
  • 4.72.1                                ...           3 months ago
  • 4.72.0                                ...           3 months ago
  • 4.71.1                                ...           3 months ago
  • 4.71.0                                ...           3 months ago
  • 4.70.0                                ...           3 months ago
  • 4.69.1                                ...           3 months ago
  • 4.69.0                                ...           3 months ago
  • 4.68.2                                ...           3 months ago
  • 4.68.1                                ...           4 months ago
  • 4.68.0                                ...           4 months ago
  • 4.67.0                                ...           4 months ago
  • 4.66.1                                ...           4 months ago
  • 4.66.0                                ...           4 months ago
  • 4.65.0                                ...           4 months ago
  • 4.64.0                                ...           5 months ago
  • 4.63.0                                ...           5 months ago
  • 4.62.0                                ...           5 months ago
  • 4.61.0                                ...           5 months ago
  • 4.60.0                                ...           5 months ago
  • 4.59.0                                ...           5 months ago
  • 4.58.0                                ...           5 months ago
  • 4.57.8                                ...           5 months ago
  • 4.57.7                                ...           6 months ago
  • 4.57.6                                ...           6 months ago
  • 4.57.5                                ...           6 months ago
  • 4.57.4                                ...           6 months ago
  • 4.57.3                                ...           6 months ago
  • 4.57.2                                ...           7 months ago
  • 4.57.1                                ...           8 months ago
  • 4.57.0                                ...           8 months ago
  • 4.56.11                                ...           9 months ago
  • 4.56.10                                ...           10 months ago
  • 4.56.9                                ...           10 months ago
  • 4.56.8                                ...           10 months ago
  • 4.56.7                                ...           10 months ago
  • 4.56.4                                ...           10 months ago
  • 4.56.2                                ...           10 months ago
  • 4.56.1                                ...           10 months ago
Downloads
Total 105
Today 0
This Week 2
This Month 98
Last Day 0
Last Week 94
Last Month 1
Dev Dependencies (7)
Dependents (2)

© 2010 - cnpmjs.org x YWFE | Home | YWFE