1.0.0 • Published 3 years ago

@ricokahler/jsonmatch-js v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

JSONMatch JS

The following code was compiled from go-jsonmatch using gopherjs 1.17

Note: this package is was created primarily for use with jsonmatch-patch

Disclaimer: the bundle is huge. A pure JS implementation would be much much better.

The following entry point was used:

package main

import "github.com/gopherjs/gopherjs/js"
import "github.com/sanity-io/go-jsonmatch"

func MatchWrapper(path string, data interface{}, set interface{}) interface{}  {
	match, err1 := jsonmatch.Match(path, data)
	if (err1 != nil) {
		return nil
	}
	result, err2 := match.Set(set)
	if (err2 != nil) {
		return nil
	}
	return result
}


func main() {
	js.Module.Set("exports", map[string]interface{}{
		"JSONMatch": MatchWrapper,
	})
}