Started writing documentation and adding examples

This commit is contained in:
Leon Mika 2023-04-24 06:09:22 +00:00
parent 7adb09d4db
commit 405bf812ee
5 changed files with 40 additions and 0 deletions

View file

@ -43,3 +43,17 @@ func TestToJSON(t *testing.T) {
})
})
}
func ExampleToJSON() {
fruits := []string{"apple", "banana", "pineapple"}
script.Slice(fruits).Filter(scriptx.ToJSON(func(fruit string) any {
return map[string]any{
"fruit": fruit,
"length": len(fruit),
}
})).Stdout()
// Output:
// {"fruit":"apple","length":5}
// {"fruit":"banana","length":6}
// {"fruit":"pineapple","length":9}
}