This package has been deprecated

Author message:

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

dsdata
TypeScript icon, indicating that this package has built-in type declarations

1.0.32 • Public • Published

⛯ Divine Star Data ⛯


GitHub top language GitHub repo size npm own loads GitHub latest release GitHub latest version GitHub last commit GitHub commit actiivty GitHub followers GitHub stars GitHub watchers

What is this?

A JSON compressor. It compresses data using the LZMA algorithm. It uses a port of LZMA-JS to TypeScript. Check out the original repo here: link

Why?

Makes it easy to just get and store compressed json data. This is useful if your app generates a lot of data and you want to keep a small footprint on the disk.

Why make it?

Divine Star has several projects that need to store compressed JSON data. All of Divine Star’s projects are written in TypeScript. The node module for LMZA-JS did not have a TypeScript version and was not as flexible as needed. It is still a great library, but it's getting a little out of date. Please show respect to the original creators and their hard work.

Improvements

Just a list of basic improvements/changes that were made to the library:

  • The module exports an ES6 class which can then be instantiated.
  • All functions that the user does not need to access are made private with the new ‘#’ private instance marker.
  • This module makes it easier to move the compression and decompression into any context within an Electron node-integration environment or server side.
  • The helper class makes it easy to just read and write json async without dealing with the compression.

Current Features

  • Read in compressed JSON
  • Write a compressed JSON file
  • Change Compression Level

How To Use

Start a new node project with these commands:

npm init
npm i --save-dev typescript @types/node
npm i --save dsdata

Change your package.json to include:

{
  "type": "module"
}

Create a folder for your TypeScript files and make a new tsconfig file. Change the tsconfig to be like:

{
  "target": "esNext",
  "module": "esNext",
  "moduleResolution": "node",
  "types": ["node", "dsdata"]
}

Finally if you want to use Divine Star Data simply import it and create a new instance by passing it fs/promises.

import { DivineStarData } from "dsdata";
import * as fs from "fs/promises";
const DSD = new DivineStarData(fs);

(async()=>{
    const jsonData =[
        {test:1},
        {test:1},
        {test:1},
        {test:1},
        {test:1},
        {test:1},
        {test:1},
        {test:1},
        {test:1},
        {test:1},
    ];
   await  DSD.write("./test.dsd",jsonData);
   const data = await DSD.read("./test.dsd");
   console.log(data);
})();

Use Just The Converted LZMA-JS

If you want access to just the converted LZMA-JS library just clone the repo and extract the .ts or .js files for the compressor or decompressor. Then you can use them in your project and import their respective classes like any other ES6 class.

Readme

Keywords

none

Package Sidebar

Install

npm i dsdata

Weekly Downloads

1

Version

1.0.32

License

MIT

Unpacked Size

133 kB

Total Files

9

Last publish

Collaborators

  • lucasdamianjohnson