This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

@hackbg/kabinet
TypeScript icon, indicating that this package has built-in type declarations

3.2.7 • Public • Published

literate: typescript

@hackbg/kabinet

Classes for accessing the filesystem.

Your OS's filesystem isn't the most powerful database by far, it's the most human-friendly one out there.

Exports File and Directory classes, as well as example JSON subclasses of the same that take care of extensions and the data format. YAML and TOML subclasses are planned, too.

Reexports fs, fs/promises, as well as mkdirp and rimraf.

Basis of the Receipts subsystem in Fadroma. A "receipt" is a good metaphor for the kind of data best stored with this module: a record of a meaningful interaction between a user and a system, which is stored with the user (as it's recorded by the system's state, anyway). Think keeping track of what programs (e.g. smart contracts) you uploaded to an append-only public compute service (e.g. a programmable blockchain).

import $, { OpaqueDirectory, TextFile, JSONFile } from '@hackbg/kabinet'

const root = $(process.cwd())

// Access files through a directory
const dir = root.in('data').as(OpaqueDirectory).make()
dir.at('file.txt').as(TextFile).save('my data')
dir.at('file.json').as(JSONFile).save({my:'data'})
console.log(dir.list())

// Or directly
console.log(new JSONFile(root, 'data', 'file.json').load())
console.log(root.in('data').at('file.txt').as(TextFile).load())

Readme

Keywords

none

Package Sidebar

Install

npm i @hackbg/kabinet

Weekly Downloads

0

Version

3.2.7

License

MIT

Unpacked Size

36.7 kB

Total Files

7

Last publish

Collaborators

  • aakamenov
  • atanas-krondev
  • denismaxim0v
  • exactlywhoyouthinkitis
  • imollov
  • mradkov