npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

open-cobol

v1.0.0

Published

A node wrapper method to run COBOL code with open-cobol (Linux)

Downloads

6

Readme

node-open-cobol

This is a wrapper method to pass COBOL code to open-cobol (on Linux) using node.js

It's inspired by node-cobol.

Installation

$ npm install open-cobol

Usage

There are several ways to use this module, explain in detail in the following sections.

Use as node module

The API accept two parameters:

  • string input - it can be COBOL code or a path to a .cbl file contain the COBOL code
  • options - currently only expecting one key args (or just pass nothing) this contain array of values that will pass to the COBOL code, if you require to pass values to your code.
const openCobol = require('open-cobol')
const helloCbl = `
       IDENTIFICATION DIVISION.
       PROGRAM-ID. HELLO.
       ENVIRONMENT DIVISION.
       DATA DIVISION.
       PROCEDURE DIVISION.
       PROGRAM-BEGIN.
       DISPLAY "Hello world".
       PROGRAM-DONE.
       STOP RUN.

`

openCobol(helloCbl)
  .then(result => {
    // result = Hello world
  })

or you put the above code in a file name hello.cbl

    IDENTIFICATION DIVISION.
    PROGRAM-ID. HELLO.
    ENVIRONMENT DIVISION.
    DATA DIVISION.
    PROCEDURE DIVISION.
    PROGRAM-BEGIN.
    DISPLAY "Hello world".
    PROGRAM-DONE.
    STOP RUN.

Then your js code:

openCobol('hello.cbl')
  .then(result => {
    // result = Hello world
  })

HTTP interface

You can use it as a module

const openCobolHttp = require('open-cobol/http')
// the underlying application is using Koa
openCobolHttp.listen(8080)
// this will start up the HTTP server on port 8080
// then you an post your code to it

It's expecting you to using POST using json header with the following keys

  • cbl (string) - the actual COBOL code
  • args (array) - any argument you want to pass to your COBOL code

Another way is to clone this repository, then execute within the root folder

$ npm start

It will start the server on port 3001

Or you can pass an PORT variable to change the port

$ PORT=8080 npm start

Then the server will run on port 8080

Docker

The quickest way is to pull our docker images

For x86

$ docker pull joelchu/ubuntu-node-open-cobol 

Then just run it

$ docker run -d -p 3001:3001 -v /path/to/where/you/want:/home/app/data:rw joelchu/ubuntu-node-open-cobol 

This will run the node-open-cobol in http mode. Then just submit your COBOL code to http://localhost:3001, also the compiled COBOL code will be in the /path/to/where/you/want folder.

For ARM

There are two more images for ARM platform (They were build on Raspberry pi 4b)

  • joeljiezhu/ubuntu-node-open-cobol
  • joeljiezhu/ubuntu-node-open-cobol-cn (this one with source.list from Tsinghua University)

And finally, you can clone this repo and build it yourself. There are Dockerfile and Dockerfile-cn on the root level of this repo.

Using the cli

The command line version is just a simple HTTP client that will call the HTTP intreface, it's handy for doing some quick test.

$ npm i node-open-cobol -g

Then you will get a nodecobc command

First start up your node-open-cobol/http interface, or run the docker image, then:

$ nodecobc /path/to/your/file.cbl

If you have change the port (default is 3001) then you can

$ nodecobc /path/to/your/file.cbl -p 12345

You can also type nodecobc --help to learn more


MIT

Joel Chu (2020)