Coder Social home page Coder Social logo

goplay's Introduction

AD

๐Ÿ”ฅ We're hiring! Message me for a referral :)

PROJECTS

  • โญ httpin: Go - HTTP Request from/to Struct, i.e. Bi-directional Data Binding between Go Struct and http.Request (documentation)
  • ๐Ÿฆ‰ owl: Go - a Go Struct Tag Framework and Algorithm Driver
  • caddy-jwt: Go -Caddy Module for JWT Authentication (documentation)
  • distlock: Go - Simple distributed locks using Redis, MySQL, PostgreSQL, etc.
  • password: Go - Password Hashing & Verification
  • goenv: Go - Populate go struct instance with OS environment variables.
  • goplay: TypeScript - Embed Go Playground on your Website (demo)
  • v2raym: Bash - Dead simple v2ray client for macOS (in terminal)
  • droplet.sh: Bash - Import shell scripts like Go
  • python-fossil-delta: Python wrapper of the C implementation of Fossil Delta Encoding Algorithm
  • jsonla: C++ - Parse and manipulate JSON data structure

goplay's People

Contributors

ggicci avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

0xack13

goplay's Issues

Respect event delay in output

Delay property is used to simulate timeouts in console output. It's necessary because the Go playground mocks system time and disables timeout functions like time.Sleep and etc.

For instance, let's take the snippet below:

fmt.Println("fizz")
time.Sleep(2 * time.Second)
fmt.Println("buzz")

If you don't simulate timeout between events, both lines will be printed simultaneously.

To fix this issue, it's necessary to add a simple setTimeout between outputs:

const sleep = n => new Promise((res) => setTimeout(res, n);

 for (const event of js.Events || []) {
      // not sure it this is delay in seconds or nanoseconds
      // but let's assume that .Delay is in seconds for demo purposes.
     if (event.Delay > 0) await sleep(event.Delay);
      switch (event.Kind) {
        case 'stdout':
          stdout.innerText += event.Message
          break
        case 'stderr':
          stderr.innerText += event.Message
          break
        case 'system':
          system.innerText += event.Message
          break
      }
    }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.