Catalog npm
Back to packageRELEASE DETAILS

1.5.3

npm

@00sukhjeet00/compilerjs

Code Compiling library

compilercompilerjscompiler-jsjs-compilerjs-transpilertranspilertranspilerjs
Published15 Oct 2022
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": "67cb85a8fdf9876024d3f9aa5c410658f436a98d",
  "tarball": "https://registry.npmjs.org/@00sukhjeet00/compilerjs/-/compilerjs-1.5.3.tgz",
  "fileCount": 7,
  "integrity": "sha512-pAfDNFHwX7O7j0F2sUAS9LLIh8jC/Vxyb1xSCvn5Dftwe8InQp/NXxH2WC0ZnA0dDj6CGVt7CmiZrbltw/RyQg==",
  "signatures": [
    {
      "sig": "MEQCIALUEi29SAxIrbTv4aFri7c5jqb4queddWCPL+l2u3RmAiBW76xURVM37D9F00LBYOzDgPYfnatiP+bukzXfIX4otg==",
      "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"
    }
  ],
  "unpackedSize": 26624,
  "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjSky6ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmr+Fw/9GUjIqNexGiS4Q1K+znInmi3Kdo6JLQU+jf5ti5B/WEk2X2Y1\r\ntS7HCuTsSd8rUoGIosWS4bJ07r9HiSO/21UKJi9fWqnyGyNM3tus8caNhyjY\r\nLBe8NIX1qUgj8wp3nUgWAexQ8w93VQJA5qFGQU32/3lvtYoyIzphdH8QGitp\r\niTOxzFvauGZ6qRudFAE83gduN2wceT28EyBJ3E6muoT5F55Nm818wOaRLav1\r\nJrmxPv3gqLcK1A23rPQvQVv9am00kWpvAjf26yg92AKSo0+iPr1nDTtJs/t5\r\nxS26ytYq4yI0Gsb+gX3tj1NRJYFEWmgBxW0KqFSAfIRaxp80WehJ+gFDcxhU\r\nbjTKvXIKlX97xh+5Gro4FbkwYBxoDFQirw72QokfKqNX98baE8oyB1EMAZW9\r\ncJA/bd5Wp5jm5PW8z6XUeRAiVokH7PEvcK/zZeR6YbUFb8yuzvirEKftpI5G\r\n9Ckkr2y3a1E2Cue3LolY2FEMAspmhUmPfpFlyEqRi6rtyfQzyBAY61/A4EHf\r\ncGASffQaBoepgNBIP71NFLBplc+XmIgU/mWdVy6UYZyChyfgarZhkYOwsvJT\r\nkmOTSFqHAsgO1CSVvu3Zyg4QYrJ9y1cFnRmPkBeS63GliQtWaKFWEgtBnhKw\r\n2mGf1PBCbUTq52goUzTj8tT9vtCB6/ybeuM=\r\n=7qE6\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:96c4346bdd436e5965b32ef0f2bb2c81ab2df28afecc18fdbaf582e18c2b337f

Other collected versions

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