/go-js

Primary LanguageGoMIT LicenseMIT

go-js

push

Deprecated in favor of go-fn which removes JavaScript specific stuff that doesn't work as nicely in Go without optional paramter handling.

Go module for functions that mimic useful JavaScript functions using Go 1.18's Generics

Install

go get github.com/frantjc/go-js

Usage

See examples.

import (
	"fmt"

	"github.com/frantjc/go-js"
)
// ...
	array := []int{1, 2, 3, 4}
	mappable := js.MappableArray[int, string](array)
	some := mappable.Map(func(a, _ int, _ []int) string {
		return fmt.Sprint(a)
	}).Some(func(b string, _ int, _ []string) bool {
		return b == "1"
	})

	fmt.Println(some)
	// true
// ...