All Projects → kuoruan → v8go-polyfills

kuoruan / v8go-polyfills

Licence: MIT License
Add polyfills to rogchap/v8go

Programming Languages

go
31211 projects - #10 most used programming language
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to v8go-polyfills

appHistory
A polyfill for the AppHistory proposal
Stars: ✭ 21 (-16%)
Mutual labels:  polyfill
scoped
Scoped CSS polyfill
Stars: ✭ 67 (+168%)
Mutual labels:  polyfill
fromentries
Object.fromEntries() ponyfill (in 6 lines)
Stars: ✭ 62 (+148%)
Mutual labels:  polyfill
async generator
Making it easy to write async iterators in Python 3.5
Stars: ✭ 87 (+248%)
Mutual labels:  polyfill
audioworklet-polyfill
strictly unofficial polyfill for Web Audio API AudioWorklet
Stars: ✭ 49 (+96%)
Mutual labels:  polyfill
core-web
like core-js but for Web APIs (based on polyfill.io)
Stars: ✭ 34 (+36%)
Mutual labels:  polyfill
NetStandardPolyfills
Type and Reflection polyfill extension methods. .NET 3.5+ and .NET Standard 1.0+.
Stars: ✭ 22 (-12%)
Mutual labels:  polyfill
rangefix
Workaround for browser bugs in Range.prototype.getClientRects and Range.prototype.getBoundingClientRect.
Stars: ✭ 35 (+40%)
Mutual labels:  polyfill
mini-create-react-context
(A smaller) polyfill for the react context API
Stars: ✭ 34 (+36%)
Mutual labels:  polyfill
webvr-polyfill-dpdb
An up-to-date Device Parameter Database for the WebVR Polyfill
Stars: ✭ 29 (+16%)
Mutual labels:  polyfill
Array.prototype.at
An ES-spec-compliant (proposed) `Array.prototype.at`shim/polyfill/replacement that works as far down as ES3.
Stars: ✭ 20 (-20%)
Mutual labels:  polyfill
pdjs
JavaScript External for Pure Data based on V8
Stars: ✭ 45 (+80%)
Mutual labels:  v8
object-shape
Get a description of a JS object's shape.
Stars: ✭ 24 (-4%)
Mutual labels:  v8
o9n
🖥 A screen.orientation ponyfill
Stars: ✭ 55 (+120%)
Mutual labels:  polyfill
web-streams-polyfill
Web Streams, based on the WHATWG spec reference implementation
Stars: ✭ 198 (+692%)
Mutual labels:  polyfill
Framework
Advanced modding framework for multiplayer modifications
Stars: ✭ 21 (-16%)
Mutual labels:  v8
String.prototype.matchAll
Spec-compliant polyfill for String.prototype.matchAll, in ES2020
Stars: ✭ 14 (-44%)
Mutual labels:  polyfill
JustDraw
A Test for Android Canvas Painting with JavaScript Engine
Stars: ✭ 42 (+68%)
Mutual labels:  v8
Gapotchenko.FX
.NET polyfill to the future. A versatile RAD framework for .NET platform.
Stars: ✭ 23 (-8%)
Mutual labels:  polyfill
rust rewrite
A programming environment that aims to help people learn how to program in JavaScript, while giving them a tour on how old computers and their limitations used to be.
Stars: ✭ 26 (+4%)
Mutual labels:  v8

Polyfills for V8Go

Install

go get -u go.kuoruan.net/v8go-polyfills

This module uses Golang embed, so requires Go version 1.16

Polyfill List

  • base64: atob and btoa

  • console: console.log

  • fetch: fetch

  • timers: setTimeout, clearTimeout, setInterval and clearInterval

  • url: URL and URLSearchParams

Usage

fetch polyfill

package main

import (
	"errors"
	"fmt"
	"time"

	"go.kuoruan.net/v8go-polyfills/fetch"
	"rogchap.com/v8go"
)

func main() {
	iso, _ := v8go.NewIsolate()
	global, _ := v8go.NewObjectTemplate(iso)

	if err := fetch.InjectTo(iso, global); err != nil {
		panic(err)
	}

	ctx, _ := v8go.NewContext(iso, global)

	val, err := ctx.RunScript("fetch('https://www.example.com').then(res => res.text())", "fetch.js")
	if err != nil {
		panic(err)
	}

	proms, err := val.AsPromise()
	if err != nil {
		panic(err)
	}
	done := make(chan bool, 1)

	go func() {
		for proms.State() == v8go.Pending {
			continue
		}
		done <- true
	}()

	select {
	case <-time.After(time.Second * 10):
		panic(errors.New("request timeout"))
	case <-done:
		html := proms.Result().String()
		fmt.Println(html)
	}
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].