<commit_before>package json

import "github.com/gopherjs/gopherjs/js"

func Encode(v interface{}) string {
	run := true
	return js.Global.Get("JSON").Call("stringify", v, func(key, value *js.Object) *js.Object {
		if run {
			run = false
			filter(js.InternalObject(v).Get("constructor"), value)
		}
		return value
	}).String()
}

const (
	arrayKind  = 17
	mapKind    = 21
	ptrKind    = 22
	sliceKind  = 23
	structKind = 25
)

func filter(t, value *js.Object) {
	switch t.Get("kind").Int() {
	case arrayKind, sliceKind:
		len := value.Length()
		for i := 0; i < len; i++ {
			filter(t.Get("elem"), value.Index(i))<commit_msg>renamed Encoder->Marshal and modified func signature to match stdlib json package<commit_after>package json

import "github.com/gopherjs/gopherjs/js"

func Marshal(v interface{}) ([]byte, error) {
	run := true
	return []byte(js.Global.Get("JSON").Call("stringify", v, func(key, value *js.Object) *js.Object {
		if run {
			run = false
			filter(js.InternalObject(v).Get("constructor"), value)
		}
		return value
	}).String()), nil
}

const (
	arrayKind  = 17
	mapKind    = 21
	ptrKind    = 22
	sliceKind  = 23
	structKind = 25
)

func filter(t, value *js.Object) {
	switch t.Get("kind").Int() {
	case arrayKind, sliceKind:
		len := value.Length()
		for i := 0; i < len; i++ {
			filter(t.Get("elem"), value.Index(i))
{'fraction_non_alphanumeric': 0.16405667412378822, 'fraction_numerical': 0.01640566741237882, 'mean_word_length': 3.7588652482269502, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1251596', 'n_tokens_mistral': 528, 'n_tokens_neox': 483, 'n_words': 123}