0.2.0 • Published 9 months ago

searate-parser v0.2.0

Weekly downloads
-
License
ISC
Repository
github
Last release
9 months ago

Searates Parser

This tools lets you fetch to tracking data throught Searate service and convert it into more convinent data-structure for handling

Installation

npm install searate-parser

Usage: Fetch & Parse

import { SearateFetcher } from "searate-parser";

const fetcher = new SearateFetcher();

fetcher.setTrackingNumber('ADL300122300')
    .setSeaLine('PCIU')
    .fetchAndParse();

Usage: Only Parse

import { SearateParser } from "searate-parser";
import { readFile } from "fs";

readFile('storage/test.json', "utf-8", (err, data) => {

    /** File Reading Validation */
    if (err)
        throw new Error("File Not Loaded");


    const parser = new SearateParser();
    const result = parser.loadResponse(data)
        .validate()
        .prepareDataStructure();

    console.log("\x1b[42m Test Output ↓ \x1b[0m")
    console.log(result);
    console.log("\x1b[42m Test Output ↑ \x1b[0m")
})

Usage: Only Parse (Json data is provived as string typed scenario)

import { SearateParser } from "searate-parser";
import { readFile } from "fs";

readFile('storage/test.json', "utf-8", (err, data) => {

    /** File Reading Validation */
    if (err)
        throw new Error("File Not Loaded");


    const parser = new SearateParser();
    const result = parser.loadRawResponse(data)
        .toJson()
        .validate()
        .prepareDataStructure();

    console.log("\x1b[42m Test Output ↓ \x1b[0m")
    console.log(result);
    console.log("\x1b[42m Test Output ↑ \x1b[0m")
})
0.2.0

9 months ago

0.1.0

9 months ago