npm.io
0.1.0 • Published 6 years ago

@sleep-client/parser

Licence
MIT
Version
0.1.0
Deps
0
Size
14 kB
Vulns
0
Weekly
0

@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
  }
})()