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

@datadog/sketches-js

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@datadog/sketches-js

TypeScript implementation of DDSketch, a distributed quantile sketch algorithm

  • 2.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.2M
decreased by-19.47%
Maintainers
1
Weekly downloads
 
Created

What is @datadog/sketches-js?

@datadog/sketches-js is a JavaScript library for working with data sketches, which are probabilistic data structures used for efficiently summarizing and querying large datasets. This package is particularly useful for applications that require real-time analytics and monitoring, such as those in observability and telemetry.

What are @datadog/sketches-js's main functionalities?

DDSketch

DDSketch is a data structure for accurately tracking quantiles in a data stream. The code sample demonstrates how to create a DDSketch, add data points to it, and query the median (50th percentile).

const { DDSketch } = require('@datadog/sketches-js');

const sketch = new DDSketch();
sketch.accept(10);
sketch.accept(20);
sketch.accept(30);
console.log(sketch.getQuantile(0.5));

Merge Sketches

This feature allows you to merge two DDSketch instances. The code sample shows how to create two sketches, add data points to them, and then merge them into one sketch.

const { DDSketch } = require('@datadog/sketches-js');

const sketch1 = new DDSketch();
sketch1.accept(10);

const sketch2 = new DDSketch();
sketch2.accept(20);

sketch1.merge(sketch2);
console.log(sketch1.getQuantile(0.5));

Serialization

Serialization allows you to convert a DDSketch to a format that can be stored or transmitted and then later reconstructed. The code sample demonstrates how to serialize and deserialize a DDSketch.

const { DDSketch } = require('@datadog/sketches-js');

const sketch = new DDSketch();
sketch.accept(10);
const serialized = sketch.serialize();
console.log(serialized);

const deserializedSketch = DDSketch.deserialize(serialized);
console.log(deserializedSketch.getQuantile(0.5));

Other packages similar to @datadog/sketches-js

Keywords

FAQs

Package last updated on 23 Apr 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