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

envoijs

v1.0.9

Published

A minimalistic, robust and asynchronous code runner/judge

Downloads

5

Readme

ENVOI LOGO

PR's Welcome

Envoi is a lightweight and robust code execution system capable of executing or judging test cases from source code across multiple languages that are easily extensible/integrated in your usage pattern

Currently Envoi supports: C++, Java, Python 3, Go, JavaScript (Node).

Envoi is fully compatible with TypeScript but can also be used seamlessly with JavaScript

 

Installation

Envoi requires the respective compile/run tools for each language intended to be used installed on the host system and added to PATH. These include | Langauge | Tool | | ------------- |:-------------:| | C++ | g++ | | Java | java jdk | | Python | Python | | Go | go | | JavaScript | node |

Npm installation

$ npm install envoijs

Basic Usage - JavaScript

const { Envoi, Languages, Verdict } = require('envoijs');
const runCodeExample = async () => {
  const sourceCode = `print("Hello",input())`;
  const result = await Envoi({
    input: 'From Envoi',
    sourceCode: sourceCode,
    language: Languages.PYTHON
  });
  console.log(result); //{ verdict: 'AC', output: 'Hello From Envoi' }
  if (result.verdict === Verdict.AC)
    //check verdict if accepted (indicating success)
    console.log('success');
};
runCodeExample();

API

Envoi(submission) : Promise<SubmissionVerdict>

Returns a promise resolving to a SubmissionVerdict

Parameters

submission

Type: Submission

Submission

An object type representing a submission

properties

sourceCode and language are required | Property | Type | description |default | | ------------- |:-------------:|-------------|--------------| | sourceCode |string | the source code to execute | - | | language | string | the programming language, can use the helper enum Languages |- | | input? | string | input fed into the program (stdin) | null| | testCases? | TestCase[] | test cases to run against the program | [ ]| | timeout? | number |milliseconds before timing out the program (TLE) | 5000 |

SubmissionVerdict

An object type representing the submission result

properties

| Property | Type | description | | -------- | :-------------------: | ---------------------------------------------------------------------------------------------------------------------------------------- | | verdict | Verdict | the verdict of the submission - | | output | string | the output of the program, can also be a description of the compilation error/runtime error or a simple message. i.e "passed test cases" | - |

Verdict

An enum representing the verdict of a submission as strings

properties

| Property | Value | description | | ----------- | :-------------: | ----------------------------------------------------------- | | AC | 'AC' | The source code executed successfully/passed all test cases | - | | COMPILATION | 'COMPILATION' | Compilation error | - | | ERROR | 'ERROR' | An error during the whole execution process | | MLE | 'MLE' | Memory limit exceeded (NOT YET IMPLEMENTED) | | PENDING | 'PENDING' | Submission is pending | | RUNTIME | 'RUNTIME' | Runtime error | | TLE | 'TLE' | Time limit exceeded (timedout) | | WA | 'WA' | Wrong answer (Failed test cases) |

Languages

An enum representing all the supported languages as string

properties

| Property | Value | | ---------- | :------------: | | CPP | 'c++' | - | | GO | 'go' | | JAVA | 'java' | | JAVASCRIPT | 'javascript' | | PYTHON | 'python' |

TestCase

An object type representing a submission testcase

properties

both properties are required | Property | Type | description | | ------------- |:-------------:|-------------| | input |string | input for the test case (stdin) |
| expectedOutput | string |expected output for the test case|-

Running against test cases - JavaScript

const { Envoi, Languages, Verdict } = require('envoijs');
const runCodeExample = async () => {
  const sourceCode = `
  #include <iostream>
  using namespace std;
  int main(){
    int a,b;
    cin>>a>>b;
    cout<<a+b<<endl;
    return 0;
  }`;
  const result = await Envoi({
    sourceCode: sourceCode,
    language: Languages.CPP,
    testCases: [
      {
        input: '2 3',
        expectedOutput: '5'
      },
      {
        input: '21 4',
        expectedOutput: '27' //fail this test case
      }
    ]
  });
  console.log(result); //{ output: 'For input: 21 4\nFound: 25\nExpected:27', verdict: 'WA' }
  if (result.verdict === Verdict.WA) console.log('WRONG ANSWER');
};
runCodeExample();

Running against test cases - TypeScript

import { Envoi, Languages, Verdict, SubmissionVerdict, TestCase } from 'envoijs';
const runCodeExample = async () => {
  const sourceCode = `
    #include <iostream>
    using namespace std;
    int main(){
      int a,b;
      cin>>a>>b;
      cout<<a+b<<endl;
      return 0;
    }`;
  const testCases: TestCase[] = [
    {
      input: '2 3',
      expectedOutput: '5'
    },
    {
      input: '21 4',
      expectedOutput: '27' //fail this test case
    }
  ];
  const result: SubmissionVerdict = await Envoi({
    sourceCode: sourceCode,
    language: Languages.CPP,
    testCases: testCases
  });
  console.log(result); //{ output: 'For input: 21 4\nFound: 25\nExpected:27', verdict: 'WA' }
  if (result.verdict === Verdict.WA) console.log('WRONG ANSWER');
};
runCodeExample();