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

@iyulab/data-summerizer

Package Overview
Dependencies
Maintainers
2
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@iyulab/data-summerizer

Summarize the data.

  • 0.0.5
  • unpublished
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
2
Weekly downloads
 
Created
Source

data-summarizer

This library provides a simplified simulation of MongoDB's aggregation framework in TypeScript. It allows for filtering, grouping, sorting, and limiting of in-memory data collections, mimicking the behavior of database operations but in a lightweight, local context.

Installation

To use the Data Aggregator library in your project, you can install it via npm. Run the following command in your project directory:

npm install @iyulab/data-summerizer

Make sure you have Node.js and npm installed on your system. You can download and install Node.js (npm included) from https://nodejs.org/.

Features

The Data Aggregator library provides the following features:

Filtering ($match): Filter your data based on specified criteria. Grouping and Aggregation ($group): Group your data by specific fields and count the number of documents in each group. Sorting ($sort): Sort your data based on one or more fields. Limiting ($limit): Limit the number of documents to return. Usage Below is a simple example demonstrating how to use the Aggregation class to perform data operations:

import { aggregation, AggregationOptions } from "@iyulab/data-summerizer";

// Sample data
const data = [
  { id: 1, name: "Alice", age: 30 },
  { id: 2, name: "Bob", age: 25 },
  { id: 3, name: "Charlie", age: 35 },
  { id: 4, name: "David", age: 40 },
];

// Create an instance of Aggregation with options
const options: AggregationOptions = {
  $match: { age: { $gt: 30 } }, // Filtering: age greater than 30
  $group: { _id: "$age" }, // Grouping by age
  $sort: { age: 1 }, // Sorting by age in ascending order
  $limit: 2, // Limiting to 2 documents
};

// Execute the aggregation
const result = aggregation(data, options);

console.log(result);

This will output the processed data based on the provided aggregation options. See Aggregation Tests

Contribution

Contributions are welcome! Please feel free to submit pull requests or open issues to improve the library or add new features.

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

FAQs

Package last updated on 07 Mar 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