Catalog npm
Back to packageRELEASE DETAILS

1.5.2

npm

@00sukhjeet00/compilerjs

Code Compiling library

compilercompiler-jscompilerjsjs-compilerjs-transpilertranspilertranspilerjs
Published25 Sept 2021
Direct dependencies1
Transitive dependenciesNot calculated

README

Current package documentation

CompilerJs

CompilerJs is Node JS library use to compile code for programming languages like C/C++, Java, Python.

Setting Up Compilers

In order to compile any programming language , you need to first have the compiler for that programming language in the server machine.

Documentation

1) Require compilerJs

import  { init }  from '@00sukhjeet00/compilerjs';

init();

init() creates a folder named code in your project directory which is used for storage purpose.

Before using other methods , make sure to call init() method.

2) C and C++

//Implementation for windows

const  envData  =  { ext :  "g++",options:{timeout:5000}}  // (uses g++ command to compile )

//Implementation for Linux and Mac OS(Timeout functionlity is not implemented)

const  envData  =  { ext :  "gcc", options:{timeout:5000}  }  // ( uses gcc command to compile )

compileCPP(envData  ,  code  ,(data)=>  {

console.log(data)

//data.error = error message

//data.output = output value

})

3) C and C++ with inputs

//Implementation for windows Linux and Mac OS(Timeout functionlity is not implemented)

const  envData  =  { ext :  "g++",options:{timeout:5000}}  // (uses g++ command to compile )

//Implementation for Linux and Mac OS(Timeout functionlity is not implemented)

const  envData  =  { ext :  "gcc"  ,options:{timeout:5000}};  // ( uses gcc command to compile )

compileCPPWithInput(envData  ,  code  ,  input  ,  (data)=>  {

console.log(data);

});

4) Java

var  envData  =  { ext:"java"  ,options:{timeout:5000}  };

compileJava(  envData  ,  code  ,(data)=>{

console.log(data);

});

5) Java with inputs

const  envData  =  { ext:"java"  ,options:{timeout:5000}  };

compilerJs.compileJavaWithInput(  envData  ,  code  ,  input  ,(data)=>{

console.log(data);

});

6) Python

const  envData  =  { ext:"py"  ,options:{timeout:5000}  };

compilePython(  envData  ,  code  ,(data)=>{

console.log(data);

});

7) Python with inputs

const  envData  =  { ext:"py"  options: {timeout:5000}  };

compilePythonWithInput(  envData  ,  code  ,  input  ,(data)=>{

console.log(data);

});

Timeout functionality

Timeout help to run program for particular time (in ms). It support window and linux system. Timeout can be used similarly in C/C++, Java, Python as showen below.


const  envData={ ext:  "py", options:  {timeout:5000}  }  // timeout: 5 running program for 5 sec.

Demo Code

Python:


import  { init, compilePy }  from '@00sukhjeet00/compilerjs'

init()

const  envData  =  { ext:  'py', options:  { timeout:  1000  }  }

const  code=`print('hello')`

compilePy(envData,  code,  (data)  =>  {

if  (data.error)

console.log(data.error)

else

{

if  (data.timeout)

console.log('TLE')

else

console.log(data.out)

}

})

Similar code structure for other languages

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 1

Native requirements
1 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
cuid
Environment
{
  "local_name": "cuid",
  "alias": false,
  "peer_metadata": null
}
^2.1.8runtime

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "shasum": "e311f660600af4acbceb5093b367d8b4402f7568",
  "tarball": "https://registry.npmjs.org/@00sukhjeet00/compilerjs/-/compilerjs-1.5.2.tgz",
  "fileCount": 7,
  "integrity": "sha512-/beA2n3m7DGd5ys5858Ca+k6wD9SFgh2q2cCa6Z1nqBz+mhBYhctS2pP1zjRRu+98kchg8naB8vmLsyydMuc0A==",
  "signatures": [
    {
      "sig": "MEUCIQDjhUsMWzlddpnvc7gm37rxbJJVlllKFUwTgC5IwE5yyAIgFFwKyRpxWe9k7HLRGfo5UlXsHMjUDHfzG+G3HTB1NbA=",
      "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"
    }
  ],
  "unpackedSize": 29454,
  "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhue0vCRA9TVsSAnZWagAAuPEP/iLeZ3Uvp0/x7R/THvQQ\nMEreYvwnpXSLhuRITy8w9KEoAsiCX+FGE9Qi+w7/aSnCEYILPuBe/YpS9wae\nI1/9xt2IOZARP22UV9iJYhhwjWRpt3mlXuSS4Kq9Kw+KFf/cJzwwP6Gx27Sm\nMY8gi8ct7hf6LbmN8t0EyW9jH1Nj8DZxiGhKoa1RXfXFg23JXEgACGTXIEod\n7bEiE+J6DehZpFo8myCuDTMzhNIpcj2Yh9JVw04VT895oNJcvXJTS9Gs0A0s\nt6jGA+1+CxZMeqe4klQusuZ6Wvkg27butQoBS26nXTpc4UwVryCilAqagTwV\nEwMJH0GuZIH6qDQP/qe0S8BcBmTkSMFqye8IjtYhABgoq07k8V1jekE1cWhN\n+f+yxgE/m9Inhs7ozdB34xomGuiw48kgJ9Zi0MrnRiCzED/iuNkZWXlgvB52\n/2Uwm08mZQB+SA0HQTPuJVg28Ctlzz4orSoW+u/6iW/HMw0X4oJ2JWByJh5j\nCrgSHI1DLiHmHXGsr2O6fbPJUWnEzuAszMEOxd+ox5wu73bMTwEQPi3wIjR7\nySgaNpM2R8ww5VTVVd/G3mtFXC93S3LJylmwfdiEq8jUWSZ7W+bwSaZCKeff\nU4ACISE28TvwuSibffD+ZM+Ao6bkabH0TudcFyIX/19DsLDr3OrNWgD1sOOu\nvN5x\r\n=lxje\r\n-----END PGP SIGNATURE-----\r\n"
}

Repository

PENDING
00sukhjeet00/compilerjs

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 21:54 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:a09a6a4f22c2c0ef55957e5491d33720404ca274e8df40bd1d42fd2489447219

Other collected versions

2.0.05 Oct1.5.315 Oct1.5.125 SeptView all collected versions →