Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
DataModel is a minimalistic, in-browser representation of tabular data. It supports Relational Algebra operators which enable you to run filter
, group
, bin
, join
(and many more) operations on the data.
DataModel can be used if you need an in-browser tabular data store for data analysis, visualization or just general use of data. Since DataModel is immutable and enables all relational algebra operations, it can work seamlessly with any JavaScript library.
selection
, projection
, union
, difference
, join
etc out-of-the-box.bin
, groupBy
, calculateVariable
to harness additional power of data transformation.Insert the DataModel build into the <head>
:
<script src="https://cdn.muzejs.org/lib/datamodel/latest/datamodel.js" type="text/javascript"></script>
Install DataModel from NPM:
$ npm install --save datamodel
// Prepare the schema for data
const schema = [
{
name: 'Name',
type: 'dimension'
},
{
name: 'Maker',
type: 'dimension'
},
{
name: 'Horsepower',
type: 'measure',
defAggFn: 'avg'
},
{
name: 'Origin',
type: 'dimension'
}
]
// Prepare the data
const data = [
{
"Name": "chevrolet chevelle malibu",
"Maker": "chevrolet",
"Horsepower": 130,
"Origin": "USA"
},
{
"Name": "buick skylark 320",
"Maker": "buick",
"Horsepower": 165,
"Origin": "USA"
},
{
"Name": "datsun pl510",
"Maker": "datsun",
"Horsepower": 88,
"Origin": "Japan"
}
]
DataModel
constructor and create a new DataModel
instance:import DataModel from 'datamodel';
// Create a new DataModel instance
const dm = new DataModel(data, schema);
console.log(dm.getData().data);
// Output:
// [
// ["chevrolet chevelle malibu", "chevrolet", 130, "USA"],
// ["buick skylark 320", "buick", 165, "USA"],
// ["datsun pl510", "datsun", 88, "Japan"]
// ]
// Perform the selection operation
const selectDm = dm.select((fields) => fields.Origin.value === "USA");
console.log(selectDm.getData().data);
// Output:
// [
// ["chevrolet chevelle malibu", "chevrolet", 130, "USA],
// ["buick skylark 320", "buick", 165, "USA]
// ]
// Perform the projection operation
const projectDm = dm.project(["Origin", "Maker"]);
console.log(projectDm.getData().data);
// Output:
// [
// ["USA", "chevrolet"],
// ["USA", "buick"],
// ["Japan", "datsun"]
// ]
console.log(projectDm.getData().schema);
// Output:
// [
// {"name": "Origin","type": "dimension"},
// {"name": "Maker","type": "dimension"}
// ]
Find detailed documentation and API reference from here.
Your PRs and stars are always welcome.
Checkout the CONTRIBUTING guides.
MIT
FAQs
Relational algebra compliant in-memory tabular data store
We found that datamodel demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.