Skip to content

Latest commit

 

History

History
56 lines (41 loc) · 1.39 KB

node_javascript.md

File metadata and controls

56 lines (41 loc) · 1.39 KB

Quickstart: Node - JavaScript

  1. Initialize your project as a Node project.

    $ npm init -y
    

    Note: -y skips all of the prompts.

  2. Install Accio.

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

  4. Create your app.js file.

    const { accio } = require("@drashland/accio");
    const { readFileSync } = require("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
      .get(); // Finally, get the item
    
    console.log(result.type);
    console.log(result.text);
  5. Run your app.js file.

    $ node app.js
    

    You should see the following:

    bullet
    Fix issue with date objects not being correctly validated.