0.1.0 • Published 4 years ago

@sleep-client/parser v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

@sleep-client/parser

Library for parsing sleep client state files.

Installation

$ npm i @sleep-client/parser

Usage

import {
  parse,
  ParsedStateFile,
  mapParsedToExport
} from "@sleep-client/parser";

(await () => {
  try {
    const parsedStateFile: ParsedStateFile = await parse("./path/to/stateFile");

    const workspaces = parsedStateFile.getWorkspaces();
    const collections = parsedStateFile.getWorkspaceCollections(workspaces[0]);
    const requests = parsedStateFile.getCollectionRequests(collections[0]);

    const stateFileJson = JSON.stringify(mapParsedToExport(parsedStateFile));
  } catch(e){
    e.message // Contains any errors parsing
  }
})()