npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

fluentdb

v0.0.51

Published

Do dataset joins, mergings, filters, mappings, orderings, groupings, mergings, reducings (aggregations), and similar operations on datast style objects. A 'Dataset' is an array of objects with named properties. Inspired by c# linq method syntax.

Downloads

19

Readme

Moved

** FluentDB has been renamed to fluent-data. **

If you are here, search for fluent-data in npmjs or github.

Introduction

** I am close to release of Version 1! Go to The Future and check out 'Before Version 1 Release'. **

Manipulate datasets by chaining methods. Includes capacity to map, filter, sort, group, reduce, and merge data.

FluentDB works like many of the methods on Array.prototype. However, FluentDB makes it much easier to work with arrays when their elements are objects. It also includes methods simply not available on Array.prototype.

FluentDB syntax is similar to LINQ in c#. C# developers frustrated with the lack of a LINQ functionality in javascript may be encouraged by FluentDB. Some of the syntax can even be friendlier and more powerful in comparison.

Getting Started

To install:

npm install FluentDB 

To import:

// client
import $$ from './node_modules/FluentDB/dist/FluentDB.client.js';

// server
let $$ = require('FluentDB');

// but the examples in this documentation will use
let $$ = require('./dist/FluentDB.server.js');

Example:

Consider these datasets:

let customers = [
    { id: 1, name: 'Alice' },
    { id: 2, name: 'Benny' } 
];

let purchases = [
    { customer: 2, speed: 15, rating: 50, storeId: 1 },
    { customer: 1, speed: 5, rating: 90, storeId: 1 },
    { customer: 1, speed: 7, rating: 55, storeId: 1 },
    { customer: 2, speed: 6, rating: 88, storeId: 1 },
    { customer: 1, speed: 25, rating: 35, storeId: 1 },
    { customer: 1, speed: 40, rating: 2, storeId: 3, closed: true },
    { customer: 2, speed: 4, rating: 88, storeId: 1 },
    { customer: 1, speed: 1, rating: 96, storeId: 2 },
    { customer: 1, speed: 2, rating: 94, storeId: 2 },
    { customer: 1, speed: 1, rating: 94, storeId: 2 }
];

The following exmaple uses many of the methods available to analyze the two datasets.

let $$ = require('./dist/FluentDB.server.js');

let result = 
    $$(purchases)
    .filter(p => !p.closed)
    .merge(customers, (p,c) => p.customer == c.id, 'both null') // inner join
    .group(p => [p.customer, p.storeId]) 
    .reduce(p => ({
        customer: $$.first(p.name),
        store: $$.first(p.storeId),
        orders: $$.count(p.id), 
        speed: $$.avg(p.speed),
        rating: $$.avg(p.rating),
        correlation: $$.cor(p.speed, p.rating)
    }))
    .sort(p => [p.customer, -p.rating])
    .get(p => ({
        ...p, 
        speed: $$.round(p.speed, 2),
        rating: $$.round(p.rating, 2),
        orders: undefined // won't show in final results
    }));

console.log(result);

This results in three rows for analysis:

[
  {
    customer: 'Alice',
    store: 2,
    speed: 1.33,
    rating: 94.67,
    correlation: -0.5
  },
  {
    customer: 'Alice',
    store: 1,
    speed: 12.33,
    rating: 60,
    correlation: -0.8315708645692353
  },
  {
    customer: 'Benny',
    store: 1,
    speed: 8.33,
    rating: 75.33,
    correlation: -0.9853292781642932
  }
]

Operations and Features

The following operations are available on FluentDB:

  • get: Returns the dataset as an array.
  • map: Replaces each row in a dataset with the result of a function called on each row.
  • filter: Chooses particular rows from a dataset.
  • sort: Sorts a dataset.
  • distinct: Eliminates duplicates in a dataset.
  • merge: Brings in values from another set of data. Can be done horizontally (such as with a join) or vertically (such as with an insert).
  • group: Group rows of a dataset into nested datasets. Or reverse this with ungroup
  • reduce: Aggregate a dataset. Create custom aggregators with reducer.
  • with: Work with a dataset without breaking the fluency/chaining syntax.

Click on the links to go to the wiki and learn more about them.