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

wandbox-api.js

v1.2.1

Published

A basic wrapper for Wandbox API (Unofficial).

Downloads

5

Readme

Wandbox-API.js

A basic wrapper for Wandbox API (Unofficial).

Table of Contents

Install

This package requires axios for HTTP client.

npm install axios @tfagaming/wandbox-api
yarn add axios @tfagaming/wandbox-api

Supported languages

These are the languages that Wandbox can compile: Bash script, C, C#, C++, Crystal, D, Elixir, Erlang, Go, Groovy, Haskell, Java, JavaScript, Julia, Lazy K, Lisp, Lua, Nim, OCaml, OpenSSL, PHP, Pascal, Perl, Pony, Python, R, Ruby, Rust, SQL, Scala, Swift, TypeScript, Vim script, and Zig.

Usage

import { WandboxAPI } from 'wandbox-api.js';

const api = new WandboxAPI();

Get compilers list:

await api.getCompilersList();

Find best compiler by language name:

// By language name:
await api.findBestCompiler('javascript');
await api.findBestCompiler('Rust', 0.75);

// By file extension:
await api.findBestCompiler('py', 0.2);
await api.findBestCompiler('cs');

Info: The rate parameter in the options must be in this following condition: 0 < rate ≤ 1

Compile a code from string:

Note: The empty array is Stdin (Standard Input). If there is no input for the code, simply use an empty array.

  1. Using compiler name only:
await api.compileFromString(
    { name: 'nodejs-v16.14.0' }, `console.log('Hello world!');`, []
);
  1. Using the method findBestCompiler():
const compilers = await api.findBestCompiler('javascript');

await api.compileFromString(
    compilers[index], `console.log('Hello world!');`, []
);

Compile a code from a file (using fs#readFileSync):

Note: The empty array is Stdin (Standard Input). If there is no input for the code, simply use an empty array.

  1. Using compiler name only:
await api.compileFromFile(
    { name: 'typescript-4.2.4' }, `/path/to/the/file.ts`, []
);
  1. Using the method findBestCompiler():
const compilers = await api.findBestCompiler('typescript');

await api.compileFromFile(
    compilers[index], `/path/to/the/file.ts`, []
);

Get sponsors:

await api.getSponsors();

Find a template by compiler name:

await api.findTemplate('gcc');
await api.findTemplate('clang');

Example: C++ "Hello World!":

Create a new C++ file: (*.cpp)

#include <iostream>

int main() {
    std::cout << "Hello World!";
    return 0;
}

Create a new wrapper and compile the file code:

const api = new WandboxAPI();

const compilers = await api.findBestCompiler('c++', 0.5);

const output = await api.compileFromFile(
    compilers[0], `/path/to/the/cpp/file.cpp`
);

console.log(output);

Output from the console (JSON format):

{
  status: '0',
  compiler_output: '',
  compiler_error: '',
  compiler_message: '',
  program_output: 'Hello World!',
  program_error: '',
  program_message: 'Hello World!'
}

License

GPL-3.0, General Public License v3.0.