cobol-mapper
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

COBOL Mapper

Translate a Cobol data block to a JS object. Partial TS support.

Initial release, for now only supports basic PIC types using "X(6)", "9(5)" etc...

Usage

Install in a particular project:

npm i cobol-mapper

Import with:

import { CobolMapper } from "cobol-mapper";

Describe the Cobol data structure with:

const dataMap = [
  { name: "myProp1", pic: "X(8)" },
  { name: "myProp2", pic: "X(6)" },
  { name: "myProp3", pic: "9(5)" },
  { name: "myProp4", pic: "9(10)" },
];

Create an object with:

const cm = new CobolMapper(dataMap)

Set all values using a data block:

cm.setValue("A23     BX    001230012345678")

Set individual values with:

cm.myProp1 = "Some str";
cm.myProp2 = "EX";
cm.myProp3 = 234;
cm.myProp4 = 3456786;

Get all values with:

cm.getValue() // Return all values as a single string.

Get individual values with:

cm.myProp1 // Returns the value of myProp1

Get all properties names with:

cm.getProperties() // Return an array of all properties

Readme

Keywords

Package Sidebar

Install

npm i cobol-mapper

Weekly Downloads

27

Version

0.0.2

License

MIT

Unpacked Size

11 kB

Total Files

7

Last publish

Collaborators

  • gmarcon83