Catalog npm
Back to packageRELEASE DETAILS

2.0.0

npm

@00sukhjeet00/compilerjs

<h1>CompilerJs </h1>

compilercompiler-jscompilerjsjs-compilerjs-transpilertranspilertranspilerjs
Published5 Oct 2024
Direct dependencies5
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 5

Native requirements
5 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
@types/node
Environment
{
  "local_name": "@types/node",
  "alias": false,
  "peer_metadata": null
}
^22.7.4runtime
cuid
Environment
{
  "local_name": "cuid",
  "alias": false,
  "peer_metadata": null
}
^3.0.0runtime
ts-node
Environment
{
  "local_name": "ts-node",
  "alias": false,
  "peer_metadata": null
}
^10.9.2runtime
typescript
Environment
{
  "local_name": "typescript",
  "alias": false,
  "peer_metadata": null
}
^5.6.2runtime
nodemon
Environment
{
  "local_name": "nodemon",
  "alias": false,
  "peer_metadata": null
}
^3.1.7development

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "integrity": "sha512-MLtHiEjZk7DsKj54RDAbhnBKiMQ09S1kZDhbqi9/cnU7bFMNCgC90lXsrSri49dBs/Gv58pulJZefujJw+2nnQ==",
  "shasum": "c2524192a3263287b26ffb9abaafe1fc927e047f",
  "tarball": "https://registry.npmjs.org/@00sukhjeet00/compilerjs/-/compilerjs-2.0.0.tgz",
  "fileCount": 18,
  "unpackedSize": 57569,
  "signatures": [
    {
      "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
      "sig": "MEUCIQDV0r027O0X4rv1YqHPWQbOdMzSQyz7N6NANZMJqb5mfAIgP5AwhkNUzKyqyIKh3tjbBFXjNCagDeoiO+LdHLPMN74="
    }
  ]
}

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:86ff3cd59a265d38dbb396a98dc5b8271d831dec4773d333fd1f9bf87f2bac00

Other collected versions

1.5.315 Oct1.5.225 Sept1.5.125 SeptView all collected versions →