🚀 Launch Week Day 2:Introducing Custom Tabs for Org Alerts.Learn More →
Socket
Book a DemoInstallSign in
Socket

hackerearth-node

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hackerearth-node

nodeJS library for using HackerEarth API

latest
Source
npmnpm
Version
2.3.9
Version published
Maintainers
1
Created
Source

HackerEarth-node

NPM Dark badge

awesomeBuild Status

Node JS library for using HackerEarth API

This library helps you to compile your code with HackerEarth API v3

Using HackerEarth API you can compile and run your code using their codeTable

PreRequisite

- Make sure you are using latest version of nodeJS. - You have to obtain your client secret key from [HackerEarth Here](http://www.hackerearth.com/api/register/) and voila you are done!

Install

npm install hackerearth-node

Set Up

var hackerEarth=require('hackerearth-node'); //require the Library
//Now set your application 
var hackerEarth=new hackerEarth(
                                '**********',  //Your Client Secret Key here this is mandatory
                                ''  //mode sync=1 or async(optional)=0 or null async is by default and preferred for nodeJS
);
var config={};
config.time_limit=1;  //your time limit in integer
config.memory_limit=323244;  //your memory limit in integer
config.source='';  //your source code for which you want to use hackerEarth api
config.input="";  //input against which you have to test your source code
config.language="C/C++/Py/C#"; //optional choose any one of them or none

Compile Your code

- Using Callbacks
  ``` javascript
  //compile your code 
  hackerEarth.compile(config,function(err,response){
        if(err) {
          //deal with error
        } else {
          //deal with response
        }
  });

  ```
  • Using Promises

    //compile your code 
    hackerEarth.compile(config)
                            .then(result => {
                              //Handle Result
                            })
                            .catch(err => {
                              //Handle Error
                            });
    
    

Run Your Code

- Using Callbacks
  ``` javascript
  //compile your code 
  hackerEarth.run(config,function(err,response){
        if(err) {
          //deal with error
        } else {
          //deal with response
        }
  });

  ```
  • Using Promises

    //compile your code 
    hackerEarth.run(config)
                        .then(result => {
                          //Handle Result
                        })
                        .catch(err => {
                          //Handle Error
                        });
    
    

Wanna Debug ?

>Append `debug=HE` before your node server command or whatever is calling HackerEath-node module.

Todos

  • Use ES6 in source and transpile to babel for older version and put it into distribution/
  • Promisify whole package
  • Using travis build tools for testing

Contact me on

[![Twitter][1.1]][1] [![Facebook][2.1]][2] [1.1]: http://i.imgur.com/tXSoThF.png [2.1]: http://i.imgur.com/P3YfQoD.png [1]: http://www.twitter.com/Tarun_Garg2 [2]: http://www.facebook.com/tarungarg546

Keywords

HackerEarth

FAQs

Package last updated on 02 Jul 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts