Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@georges-tech/tardis

Package Overview
Dependencies
Maintainers
0
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@georges-tech/tardis

Temporal property implementation for reading historized data

  • 1.2.1
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
8.4K
increased by131.61%
Maintainers
0
Weekly downloads
 
Created
Source

Tardis

Temporal property implementation for reading historized data.

Installation

npm install @georges-tech/tardis

Usage

You create a Tardis service through createHistoryService by providing an array of documents that must contain the following properties :

  /**
   * Date at which the configuration starts to be valid
   */
  effective_date: Date;

  /**
   * Date at which the new configuration has been created
   */
  known_at: Date;

  /**
   * Optional end date for limited time configurations 
   */
  end_date?: Date;

You can add as much properties as you like, depending on your use case, that will be returned by services.

Documents may contain a computed end_date, being the next effective document date if it exists. Otherwise, it is undefined.

While creating the service, you can provide a date to work on the related timeline.

Example

import tardis from '@georges-tech/tardis';

const documents = [{
  effective_date: new Date('2020-01-01'),
  known_at: new Date('2020-05-01'),
  data: {
    value: 'old',
  }
}, {
  effective_date: new Date('2020-03-01'),
  known_at: new Date('2020-10-01'),
  data: {
    value: 'new',
  }
}]
const historyService = tardis.createHistoryService({ documents });

const januaryConfiguration = historyService.getConfigurationAtDate({ date: new Date('2020-01-03') });
// januaryConfiguration.data.value = 'old'
// januaryConfiguration.end_date = new Date('2020-03-01')

const mayConfiguration = historyService.getConfigurationAtDate({ date: new Date('2020-05-03') });
// mayConfiguration.data.value = 'new'
// mayConfiguration.end_date = undefined

With given date

import tardis from '@georges-tech/tardis';

const documents = [{
  effective_date: new Date('2020-01-01'),
  known_at: new Date('2020-05-01'),
  data: {
    value: 'old',
  }
}, {
  effective_date: new Date('2020-03-01'),
  known_at: new Date('2020-10-01'),
  data: {
    value: 'new',
  },
  {
  effective_date: new Date('2020-04-01'),
  known_at: new Date('2020-12-01'),
  data: {
    value: 'new 2',
  }
}]
const historyService = tardis.createHistoryService({ documents, date: new Date('2020-11-01') });

const januaryConfiguration = historyService.getConfigurationAtDate({ date: new Date('2020-01-03') });
// januaryConfiguration.data.value = 'old'
// januaryConfiguration.end_date = new Date('2020-03-01')

const mayConfiguration = historyService.getConfigurationAtDate({ date: new Date('2020-05-03') });
// mayConfiguration.data.value = 'new'
// mayConfiguration.end_date = undefined
// Here we keep the configuration known on 01/10 because on the given date we did not yet know the "new2" configuration

FAQs

Package last updated on 09 Oct 2024

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