Skip to content

An easy way to search for deeply nested data in large datasets. Works in Node, Deno, and the browser.

Notifications You must be signed in to change notification settings

drashland/accio

Repository files navigation

Accio

An easy way to search for deeply nested data in large datasets

Quickstart

The below quickstart uses Node and TypeScript. If this quickstart does not fit your needs, check out the other guides below:

Quickstart: Node - TypeScript

  1. Initialize your project as a Node project.

    $ npm init -y
    

    Note: -y skips all of the prompts.

  2. Install Accio and the ts-node CLI.

    $ npm install @drashland/accio
    $ npm install -g ts-node
    
  3. Create your data.json file. You can copy the example_data.json file from this repository.

  4. Create your app.ts file.

    import { accio } from "@drashland/accio";
    import { readFileSync } from "fs";
    
    const data = readFileSync("./data.json", "utf-8");
    
    const result = accio(data)
      .array("versions") // Target the array named "versions"
      .findOne({ // In the array, find one object that has a name field ...
        name: "v0.0.3", // ... with the value of "v0.0.3"
      })
      .array("release_notes") // In the object, target the array named "release_notes"
      .findOne({ // In the array, find one object that has a title field ...
        title: "Bug Fixes", // ... with the value of "Bug Fixes"
      })
      .array("body") // In the object, target the array named "body"
      .first(); // Target the first object in the array
    
    // Create the typing for the result
    type SomeType = {
      type: string;
      text: string;
    };
    
    // Use the `.get()` call and pass in the typing to get a typed result
    const typedResult = result.get<SomeType>();
    
    console.log(typedResult.type);
    console.log(typedResult.text);
  5. Run your app.ts file.

    $ ts-node app.ts
    

    You should see the following:

    bullet
    Fix issue with date objects not being correctly validated.
    

Tutorials

API

View the full API documentation here.


Want to contribute? Follow the Contributing Guidelines here. All code is released under the MIT License.

About

An easy way to search for deeply nested data in large datasets. Works in Node, Deno, and the browser.

Topics

Resources

Stars

Watchers

Forks