New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@curium.rocks/json-chronicler

Package Overview
Dependencies
Maintainers
1
Versions
135
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@curium.rocks/json-chronicler

Persists objects in JSON format to rolling archive files

  • 0.95.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Json-Chronicler

Quality Gate Status Coverage Security Rating

What does it do?

This library facilitates saving records to local files in JSON format. It will append a record to a json file and honor chronological rotation settings.

How to install

npm install --save @curium.rocks/json-chronicler

How do I use it?

Setup your options

import {JsonChroniclerOptions} from "@curium.rocks/json-chronicler";

const logOptions: JsonChroniclerOptions = {
    name: "yourLoggerName", // used for prefixing the log files
    logDirectory: "./logs", // path to your log directory
    rotationSettings: {
        days: 7,
        hours: 1,
        minutes: 5,
        milliseconds: 750
    } // sums all the properties and will rotate the logs on that interval
}

Create and save a record

import {JsonChronicler} from "@curium.rocks/json-chronicler";
import {IChronicler} from "@curium.rocks/data-emitter-base";

const chronciler: IChronicler = new JsonChronicler(logOptions);
await chronciler.saveRecord({
    toJSON: () => {
        return {
            property1: 0.123,
            property2: "blue"
        }
    }
})

Make your models compatible

import {IJsonSerializable} from "@curium.rocks/data-emitter-base";

/**
 * Example implementation of a model that could be directly passed to
 * a chronicler
 */
export class Model implements IJsonSerializable {
    private hidden = "will not be saved";
    private property1 = 0.123;
    private property2 = "blue";

    /**
     * Provide a map with the desired names and values
     * @return {Record<string, unknown>} map that will be serialized
     */
    toJSON(): Record<string, unknown> {
        return {
            desiredSavedPropName1: this.property1,
            desiredSavedPropName2: this.property2
        };
    }
}

Keywords

FAQs

Package last updated on 11 Mar 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc