mirror of
https://github.com/MontFerret/ferret.git
synced 2025-07-15 01:25:00 +02:00
@ -1,6 +1,10 @@
|
||||
package arrays
|
||||
|
||||
import "github.com/MontFerret/ferret/pkg/runtime/core"
|
||||
import (
|
||||
"github.com/MontFerret/ferret/pkg/runtime/collections"
|
||||
"github.com/MontFerret/ferret/pkg/runtime/core"
|
||||
"github.com/MontFerret/ferret/pkg/runtime/values"
|
||||
)
|
||||
|
||||
func NewLib() map[string]core.Function {
|
||||
return map[string]core.Function{
|
||||
@ -29,3 +33,19 @@ func NewLib() map[string]core.Function {
|
||||
"UNSHIFT": Unshift,
|
||||
}
|
||||
}
|
||||
|
||||
func toArray(iterator collections.Iterator) (core.Value, error) {
|
||||
arr := values.NewArray(10)
|
||||
|
||||
for iterator.HasNext() {
|
||||
ds, err := iterator.Next()
|
||||
|
||||
if err != nil {
|
||||
return values.None, err
|
||||
}
|
||||
|
||||
arr.Push(ds.Get(collections.DefaultValueVar))
|
||||
}
|
||||
|
||||
return arr, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user