AobaJSDS is a TypeScript library designed to manage JSON-based files as a dataset. It provides a robust framework for handling structured data in the form of rows and columns, similar to a database table. The library supports features like sorting, filtering, and views, making it ideal for working with tabular data in JSON format.
- Dataset Management: Load, parse, and manage JSON-based datasets.
- Views: Create and manage multiple views of the dataset.
- Sorting: Sort data based on one or more columns.
- Filtering: Apply filters to create subsets of the data.
- Column Management: Define and manage columns with aliases.
- Compressed File Support: Handle
.json.gzcompressed JSON files. - TypeScript Support: Fully typed for better development experience.
To install the library, use npm or yarn:
npm install aobajsdsor
yarn add aobajsdsBasic Example
import { TableCore } from 'aobajsds';
(async () => {
const table = new TableCore();
// Initialize with raw data
await table.intialize({
name: 'exampleTable',
rawData: [
{ id: 1, name: 'John Doe', age: 30 },
{ id: 2, name: 'Jane Smith', age: 25 },
],
});
console.log('Table Name:', table.name); // Output: exampleTable
console.log('Rows:', table.rows()); // Output: [{ id: 1, name: 'John Doe', age: 30 }, { id: 2, name: 'Jane Smith', age: 25 }]
})();
TableCore
initalize(options: TableOptions): Promise<void>- Intializes the table with the provided options.
- Options:
name: Name of the table.fileName: Path to a JSON.jsonor.json.gzfile.rawData: Array of objects (JSON) representing the table.
columns(options: ViewOptions): ColumnDefinition[]- Retrieves the columns for the specified view.
rows(options: ViewOptions): {[key: string]: any}[]- Retrieves the rows for the specified view.
sort(options: SortOptions): string | number- Sorts the dataset based on the provided options, and creates a new view.
name: string- Gets or sets the name of the table
view: string |number- Gets or sets the active view
AobaJSDS supports the following file types:
- Standard JSON Files
.json - Compressed JSON Files
.json.gz
- Node.js (>=14.x)
- TypeScript (>=4.x)
- npm or yarn
- Clone the repository:
git clone https://github.com/jchirayil/aobajsds.git
cd aobajsds- Install dependencies:
npm installTo build the library, run:
npm run buildTo run the test suite, use:
npm testContributions are welcome! Please follow these steps:
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Commit your changes and push them to your fork.
- Submit a pull request.
The project is licensed under the MIT License. See the LICENSE file for details.
Special thanks to the contributors and open-source community for their support.
- JSZip for compressed file handling.
For questions or support, please open an issue on the GitHub respository.