diff --git a/pkg/html/common/lazy.go b/pkg/html/common/lazy.go
index 4727dc90..74562174 100644
--- a/pkg/html/common/lazy.go
+++ b/pkg/html/common/lazy.go
@@ -1,9 +1,10 @@
package common
import (
+ "sync"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
- "sync"
)
type (
@@ -27,10 +28,8 @@ func NewLazyValue(factory LazyFactory) *LazyValue {
return lz
}
-/*
- * Indicates whether the value is ready.
- * @returns (Boolean) - Boolean value indicating whether the value is ready.
- */
+// Ready indicates whether the value is ready.
+// @returns (Boolean) - Boolean value indicating whether the value is ready.
func (lv *LazyValue) Ready() bool {
lv.Lock()
defer lv.Unlock()
@@ -38,11 +37,9 @@ func (lv *LazyValue) Ready() bool {
return lv.ready
}
-/*
- * Returns an underlying value.
- * Not thread safe. Should not mutated.
- * @returns (Value) - Underlying value if successfully loaded, otherwise error
- */
+// Read returns an underlying value.
+// Not thread safe. Should not mutated.
+// @returns (Value) - Underlying value if successfully loaded, otherwise error
func (lv *LazyValue) Read() (core.Value, error) {
lv.Lock()
defer lv.Unlock()
@@ -54,11 +51,9 @@ func (lv *LazyValue) Read() (core.Value, error) {
return lv.value, lv.err
}
-/*
- * Safely mutates an underlying value.
- * Loads a value if it's not ready.
- * Thread safe.
- */
+// Write safely mutates an underlying value.
+// Loads a value if it's not ready.
+// Thread safe.
func (lv *LazyValue) Write(writer func(v core.Value, err error)) {
lv.Lock()
defer lv.Unlock()
@@ -70,10 +65,8 @@ func (lv *LazyValue) Write(writer func(v core.Value, err error)) {
writer(lv.value, lv.err)
}
-/*
- * Resets the storage.
- * Next call of Read will trigger the factory function again.
- */
+// Reset resets the storage.
+// Next call of Read will trigger the factory function again.
func (lv *LazyValue) Reset() {
lv.Lock()
defer lv.Unlock()
diff --git a/pkg/stdlib/arrays/append.go b/pkg/stdlib/arrays/append.go
index 821dea22..a26b9086 100644
--- a/pkg/stdlib/arrays/append.go
+++ b/pkg/stdlib/arrays/append.go
@@ -2,17 +2,16 @@ package arrays
import (
"context"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Appends a new item to an array and returns a new array with a given element.
- * If ``uniqueOnly`` is set to true, then will add the item only if it's unique.
- * @param arr (Array) - Target array.
- * @param item (Read) - Target value to add.
- * @returns arr (Array) - New array.
- */
+// Append appends a new item to an array and returns a new array with a given element.
+// If ``uniqueOnly`` is set to true, then will add the item only if it's unique.
+// @param arr (Array) - Target array.
+// @param item (Read) - Target value to add.
+// @returns arr (Array) - New array.
func Append(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 2, 3)
diff --git a/pkg/stdlib/arrays/first.go b/pkg/stdlib/arrays/first.go
index 07f4a6d5..9028676f 100644
--- a/pkg/stdlib/arrays/first.go
+++ b/pkg/stdlib/arrays/first.go
@@ -2,15 +2,14 @@ package arrays
import (
"context"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Returns a first element from a given array.
- * @param arr (Array) - Target array.
- * @returns element (Read) - First element in a given array.
- */
+// First returns a first element from a given array.
+// @param arr (Array) - Target array.
+// @returns element (Read) - First element in a given array.
func First(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 1)
diff --git a/pkg/stdlib/arrays/flatten.go b/pkg/stdlib/arrays/flatten.go
index c134e71a..267a8ef0 100644
--- a/pkg/stdlib/arrays/flatten.go
+++ b/pkg/stdlib/arrays/flatten.go
@@ -2,20 +2,19 @@ package arrays
import (
"context"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Turn an array of arrays into a flat array.
- * All array elements in array will be expanded in the result array.
- * Non-array elements are added as they are.
- * The function will recurse into sub-arrays up to the specified depth.
- * Duplicates will not be removed.
- * @param arr (Array) - Target array.
- * @param depth (Int, optional) - Depth level.
- * @returns (Array) - Flat array.
- */
+// Flatten turn an array of arrays into a flat array.
+// All array elements in array will be expanded in the result array.
+// Non-array elements are added as they are.
+// The function will recurse into sub-arrays up to the specified depth.
+// Duplicates will not be removed.
+// @param arr (Array) - Target array.
+// @param depth (Int, optional) - Depth level.
+// @returns (Array) - Flat array.
func Flatten(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 2)
diff --git a/pkg/stdlib/arrays/intersection.go b/pkg/stdlib/arrays/intersection.go
index 77a419ae..afe06826 100644
--- a/pkg/stdlib/arrays/intersection.go
+++ b/pkg/stdlib/arrays/intersection.go
@@ -2,17 +2,16 @@ package arrays
import (
"context"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Return the intersection of all arrays specified.
- * The result is an array of values that occur in all arguments.
- * @param arrays (Array, repeated) - An arbitrary number of arrays as multiple arguments (at least 2).
- * @returns (Array) - A single array with only the elements, which exist in all provided arrays.
- * The element order is random. Duplicates are removed.
- */
+// Intersection return the intersection of all arrays specified.
+// The result is an array of values that occur in all arguments.
+// @param arrays (Array, repeated) - An arbitrary number of arrays as multiple arguments (at least 2).
+// @returns (Array) - A single array with only the elements, which exist in all provided arrays.
+// The element order is random. Duplicates are removed.
func Intersection(_ context.Context, args ...core.Value) (core.Value, error) {
return sections(args, len(args))
}
diff --git a/pkg/stdlib/arrays/last.go b/pkg/stdlib/arrays/last.go
index b56c38c9..3b7dbc21 100644
--- a/pkg/stdlib/arrays/last.go
+++ b/pkg/stdlib/arrays/last.go
@@ -2,15 +2,14 @@ package arrays
import (
"context"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Returns the last element of an array.
- * @param array (Array) - The target array.
- * @returns (Read) - Last element of an array.
- */
+// Last returns the last element of an array.
+// @param array (Array) - The target array.
+// @returns (Read) - Last element of an array.
func Last(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 1)
diff --git a/pkg/stdlib/arrays/minus.go b/pkg/stdlib/arrays/minus.go
index da58f200..5344825b 100644
--- a/pkg/stdlib/arrays/minus.go
+++ b/pkg/stdlib/arrays/minus.go
@@ -2,16 +2,15 @@ package arrays
import (
"context"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Return the difference of all arrays specified.
- * @param arrays (Array, repeated) - An arbitrary number of arrays as multiple arguments (at least 2).
- * @returns array (Array) - An array of values that occur in the first array, but not in any of the subsequent arrays.
- * The order of the result array is undefined and should not be relied on. Duplicates will be removed.
- */
+// Minus return the difference of all arrays specified.
+// @param arrays (Array, repeated) - An arbitrary number of arrays as multiple arguments (at least 2).
+// @returns array (Array) - An array of values that occur in the first array, but not in any of the subsequent arrays.
+// The order of the result array is undefined and should not be relied on. Duplicates will be removed.
func Minus(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 2, core.MaxArgs)
diff --git a/pkg/stdlib/arrays/nth.go b/pkg/stdlib/arrays/nth.go
index f8cf2bbb..381856e8 100644
--- a/pkg/stdlib/arrays/nth.go
+++ b/pkg/stdlib/arrays/nth.go
@@ -2,18 +2,17 @@ package arrays
import (
"context"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Returns the element of an array at a given position.
- * It is the same as anyArray[position] for positive positions, but does not support negative positions.
- * @param array (Array) - An array with elements of arbitrary type.
- * @param index (Int) - Position of desired element in array, positions start at 0.
- * @returns (Read) - The array element at the given position.
- * If position is negative or beyond the upper bound of the array, then NONE will be returned.
- */
+// Nth returns the element of an array at a given position.
+// It is the same as anyArray[position] for positive positions, but does not support negative positions.
+// @param array (Array) - An array with elements of arbitrary type.
+// @param index (Int) - Position of desired element in array, positions start at 0.
+// @returns (Read) - The array element at the given position.
+// If position is negative or beyond the upper bound of the array, then NONE will be returned.
func Nth(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 2, 2)
diff --git a/pkg/stdlib/arrays/outersection.go b/pkg/stdlib/arrays/outersection.go
index 6e25c398..d7b2491e 100644
--- a/pkg/stdlib/arrays/outersection.go
+++ b/pkg/stdlib/arrays/outersection.go
@@ -2,15 +2,14 @@ package arrays
import (
"context"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
)
-/*
- * Return the values that occur only once across all arrays specified.
- * @param arrays (Array, repeated) - An arbitrary number of arrays as multiple arguments (at least 2).
- * @returns (Array) - A single array with only the elements that exist only once across all provided arrays.
- * The element order is random.
- */
+// Outersection return the values that occur only once across all arrays specified.
+// @param arrays (Array, repeated) - An arbitrary number of arrays as multiple arguments (at least 2).
+// @returns (Array) - A single array with only the elements that exist only once across all provided arrays.
+// The element order is random.
func Outersection(_ context.Context, args ...core.Value) (core.Value, error) {
return sections(args, 1)
}
diff --git a/pkg/stdlib/arrays/pop.go b/pkg/stdlib/arrays/pop.go
index 6329f3f2..19d598e5 100644
--- a/pkg/stdlib/arrays/pop.go
+++ b/pkg/stdlib/arrays/pop.go
@@ -2,15 +2,14 @@ package arrays
import (
"context"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Returns a new array without last element.
- * @param array (Array) - Target array.
- * @returns (Array) - Copy of an array without last element.
- */
+// Pop returns a new array without last element.
+// @param array (Array) - Target array.
+// @returns (Array) - Copy of an array without last element.
func Pop(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 1)
diff --git a/pkg/stdlib/arrays/position.go b/pkg/stdlib/arrays/position.go
index ef8c71e7..f63fa50f 100644
--- a/pkg/stdlib/arrays/position.go
+++ b/pkg/stdlib/arrays/position.go
@@ -2,16 +2,15 @@ package arrays
import (
"context"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Returns a value indicating whether an element is contained in array. Optionally returns its position.
- * @param array (Array) - The source array.
- * @param value (Read) - The target value.
- * @param returnIndex (Boolean, optional) - Read which indicates whether to return item's position.
- */
+// Position returns a value indicating whether an element is contained in array. Optionally returns its position.
+// @param array (Array) - The source array.
+// @param value (Read) - The target value.
+// @param returnIndex (Boolean, optional) - Read which indicates whether to return item's position.
func Position(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 2, 3)
diff --git a/pkg/stdlib/arrays/push.go b/pkg/stdlib/arrays/push.go
index d7f1e92c..965b5d3c 100644
--- a/pkg/stdlib/arrays/push.go
+++ b/pkg/stdlib/arrays/push.go
@@ -2,17 +2,16 @@ package arrays
import (
"context"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Create a new array with appended value.
- * @param array (Array) - Source array.
- * @param value (Read) - Target value.
- * @param unique (Boolean, optional) - Read indicating whether to do uniqueness check.
- * @returns (Array) - A new array with appended value.
- */
+// Push create a new array with appended value.
+// @param array (Array) - Source array.
+// @param value (Read) - Target value.
+// @param unique (Boolean, optional) - Read indicating whether to do uniqueness check.
+// @returns (Array) - A new array with appended value.
func Push(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 2, 3)
diff --git a/pkg/stdlib/arrays/remove_nth.go b/pkg/stdlib/arrays/remove_nth.go
index d371eae5..8ffcda22 100644
--- a/pkg/stdlib/arrays/remove_nth.go
+++ b/pkg/stdlib/arrays/remove_nth.go
@@ -2,16 +2,15 @@ package arrays
import (
"context"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Returns a new array without an element by a given position.
- * @param array (Array) - Source array.
- * @param position (Int) - Target element position.
- * @return (Array) - A new array without an element by a given position.
- */
+// RemoveNth returns a new array without an element by a given position.
+// @param array (Array) - Source array.
+// @param position (Int) - Target element position.
+// @return (Array) - A new array without an element by a given position.
func RemoveNth(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 2, 2)
diff --git a/pkg/stdlib/arrays/remove_value.go b/pkg/stdlib/arrays/remove_value.go
index 96b8f779..753593c8 100644
--- a/pkg/stdlib/arrays/remove_value.go
+++ b/pkg/stdlib/arrays/remove_value.go
@@ -2,18 +2,17 @@ package arrays
import (
"context"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Returns a new array with removed all occurrences of value in a given array.
- * Optionally with a limit to the number of removals.
- * @param array (Array) - Source array.
- * @param value (Read) - Target value.
- * @param limit (Int, optional) - A limit to the number of removals.
- * @returns (Array) - A new array with removed all occurrences of value in a given array.
- */
+// RemoveValue returns a new array with removed all occurrences of value in a given array.
+// Optionally with a limit to the number of removals.
+// @param array (Array) - Source array.
+// @param value (Read) - Target value.
+// @param limit (Int, optional) - A limit to the number of removals.
+// @returns (Array) - A new array with removed all occurrences of value in a given array.
func RemoveValue(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 2, 3)
diff --git a/pkg/stdlib/arrays/remove_values.go b/pkg/stdlib/arrays/remove_values.go
index 0e928827..6e6b46b9 100644
--- a/pkg/stdlib/arrays/remove_values.go
+++ b/pkg/stdlib/arrays/remove_values.go
@@ -2,16 +2,15 @@ package arrays
import (
"context"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Returns a new array with removed all occurrences of values in a given array.
- * @param array (Array) - Source array.
- * @param values (Array) - Target values.
- * @returns (Array) - A new array with removed all occurrences of values in a given array.
- */
+// RemoveValues returns a new array with removed all occurrences of values in a given array.
+// @param array (Array) - Source array.
+// @param values (Array) - Target values.
+// @returns (Array) - A new array with removed all occurrences of values in a given array.
func RemoveValues(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 2, 2)
diff --git a/pkg/stdlib/arrays/reverse.go b/pkg/stdlib/arrays/reverse.go
index b5fc10a2..22554094 100644
--- a/pkg/stdlib/arrays/reverse.go
+++ b/pkg/stdlib/arrays/reverse.go
@@ -2,15 +2,14 @@ package arrays
import (
"context"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Return a new array with its elements reversed.
- * @param array (Array) - Target array.
- * @returns (Array) - A new array with its elements reversed.
- */
+// Reverse return a new array with its elements reversed.
+// @param array (Array) - Target array.
+// @returns (Array) - A new array with its elements reversed.
func Reverse(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 1)
diff --git a/pkg/stdlib/arrays/shift.go b/pkg/stdlib/arrays/shift.go
index 4638eef7..fb1fd262 100644
--- a/pkg/stdlib/arrays/shift.go
+++ b/pkg/stdlib/arrays/shift.go
@@ -2,15 +2,14 @@ package arrays
import (
"context"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Returns a new array without the first element.
- * @param array (Array) - Target array.
- * @returns (Array) - Copy of an array without the first element.
- */
+// Shift returns a new array without the first element.
+// @param array (Array) - Target array.
+// @returns (Array) - Copy of an array without the first element.
func Shift(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 1)
diff --git a/pkg/stdlib/arrays/slice.go b/pkg/stdlib/arrays/slice.go
index fdda740a..26e4ab6b 100644
--- a/pkg/stdlib/arrays/slice.go
+++ b/pkg/stdlib/arrays/slice.go
@@ -2,17 +2,16 @@ package arrays
import (
"context"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Returns a new sliced array.
- * @param array (Array) - Source array.
- * @param start (Int) - Start position of extraction.
- * @param length (Int, optional) - Read indicating how many elements to extract.
- * @returns (Array) - Sliced array.
- */
+// Slice returns a new sliced array.
+// @param array (Array) - Source array.
+// @param start (Int) - Start position of extraction.
+// @param length (Int, optional) - Read indicating how many elements to extract.
+// @returns (Array) - Sliced array.
func Slice(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 2, 3)
diff --git a/pkg/stdlib/arrays/sorted.go b/pkg/stdlib/arrays/sorted.go
index b7cb1e93..f7ee67a6 100644
--- a/pkg/stdlib/arrays/sorted.go
+++ b/pkg/stdlib/arrays/sorted.go
@@ -2,17 +2,16 @@ package arrays
import (
"context"
+
"github.com/MontFerret/ferret/pkg/runtime/collections"
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Sorts all elements in anyArray.
- * The function will use the default comparison order for FQL value types.
- * @param array (Array) - Target array.
- * @returns (Array) - Sorted array.
- */
+// Sorted sorts all elements in anyArray.
+// The function will use the default comparison order for FQL value types.
+// @param array (Array) - Target array.
+// @returns (Array) - Sorted array.
func Sorted(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 1)
diff --git a/pkg/stdlib/arrays/sorted_unique.go b/pkg/stdlib/arrays/sorted_unique.go
index 748443d3..a90a96ab 100644
--- a/pkg/stdlib/arrays/sorted_unique.go
+++ b/pkg/stdlib/arrays/sorted_unique.go
@@ -2,18 +2,17 @@ package arrays
import (
"context"
+
"github.com/MontFerret/ferret/pkg/runtime/collections"
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Sorts all elements in anyArray.
- * The function will use the default comparison order for FQL value types.
- * Additionally, the values in the result array will be made unique
- * @param array (Array) - Target array.
- * @returns (Array) - Sorted array.
- */
+// SortedUnique sorts all elements in anyArray.
+// The function will use the default comparison order for FQL value types.
+// Additionally, the values in the result array will be made unique
+// @param array (Array) - Target array.
+// @returns (Array) - Sorted array.
func SortedUnique(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 1)
diff --git a/pkg/stdlib/arrays/union.go b/pkg/stdlib/arrays/union.go
index 9b2fa82c..25ecc7b8 100644
--- a/pkg/stdlib/arrays/union.go
+++ b/pkg/stdlib/arrays/union.go
@@ -2,15 +2,14 @@ package arrays
import (
"context"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Returns the union of all passed arrays.
- * @param arrays (Array, repeated) - List of arrays to combine.
- * @returns (Array) - All array elements combined in a single array, in any order.
- */
+// Union returns the union of all passed arrays.
+// @param arrays (Array, repeated) - List of arrays to combine.
+// @returns (Array) - All array elements combined in a single array, in any order.
func Union(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 2, core.MaxArgs)
diff --git a/pkg/stdlib/arrays/union_test.go b/pkg/stdlib/arrays/union_test.go
index 563e47ea..707c6f77 100644
--- a/pkg/stdlib/arrays/union_test.go
+++ b/pkg/stdlib/arrays/union_test.go
@@ -2,17 +2,16 @@ package arrays_test
import (
"context"
+ "testing"
+
"github.com/MontFerret/ferret/pkg/runtime/values"
"github.com/MontFerret/ferret/pkg/stdlib/arrays"
. "github.com/smartystreets/goconvey/convey"
- "testing"
)
-/*
- * Returns the union of distinct values of all passed arrays.
- * @param arrays (Array, repeated) - List of arrays to combine.
- * @returns (Array) - All array elements combined in a single array, without duplicates, in any order.
- */
+// TestUnion returns the union of distinct values of all passed arrays.
+// @param arrays (Array, repeated) - List of arrays to combine.
+// @returns (Array) - All array elements combined in a single array, without duplicates, in any order.
func TestUnion(t *testing.T) {
Convey("Should union all arrays", t, func() {
arr1 := values.NewArrayWith(
diff --git a/pkg/stdlib/arrays/unique.go b/pkg/stdlib/arrays/unique.go
index cda933b5..8e9808c2 100644
--- a/pkg/stdlib/arrays/unique.go
+++ b/pkg/stdlib/arrays/unique.go
@@ -2,16 +2,15 @@ package arrays
import (
"context"
+
"github.com/MontFerret/ferret/pkg/runtime/collections"
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Returns all unique elements from a given array.
- * @param array (Array) - Target array.
- * @returns (Array) - New array without duplicates.
- */
+// Unique returns all unique elements from a given array.
+// @param array (Array) - Target array.
+// @returns (Array) - New array without duplicates.
func Unique(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 1)
diff --git a/pkg/stdlib/arrays/unshift.go b/pkg/stdlib/arrays/unshift.go
index 002c48cf..51c8ade8 100644
--- a/pkg/stdlib/arrays/unshift.go
+++ b/pkg/stdlib/arrays/unshift.go
@@ -2,18 +2,17 @@ package arrays
import (
"context"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Prepends value to a given array.
- * @param array (Array) - Target array.
- * @param value (Read) - Target value to prepend.
- * @param unique (Boolean, optional) - Optional value indicating whether a value must be unique to be prepended.
- * Default is false.
- * @returns (Array) - New array with prepended value.
- */
+// Unshift prepends value to a given array.
+// @param array (Array) - Target array.
+// @param value (Read) - Target value to prepend.
+// @param unique (Boolean, optional) - Optional value indicating whether a value must be unique to be prepended.
+// Default is false.
+// @returns (Array) - New array with prepended value.
func Unshift(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 2, 3)
diff --git a/pkg/stdlib/html/blob.go b/pkg/stdlib/html/blob.go
index ea3a53fd..d4c9062c 100644
--- a/pkg/stdlib/html/blob.go
+++ b/pkg/stdlib/html/blob.go
@@ -38,18 +38,16 @@ func ValidateDocument(ctx context.Context, value core.Value) (core.Value, error)
return doc, nil
}
-/*
- * Take a screenshot of the current page.
- * @param source (Document) - Document.
- * @param params (Object) - Optional, An object containing the following properties :
- * x (Float|Int) - Optional, X position of the viewport.
- * x (Float|Int) - Optional,Y position of the viewport.
- * width (Float|Int) - Optional, Width of the viewport.
- * height (Float|Int) - Optional, Height of the viewport.
- * format (String) - Optional, Either "jpeg" or "png".
- * quality (Int) - Optional, Quality, in [0, 100], only for jpeg format.
- * @returns data (Binary) - Returns a base64 encoded string in binary format.
- */
+// Screenshot take a screenshot of the current page.
+// @param source (Document) - Document.
+// @param params (Object) - Optional, An object containing the following properties :
+// x (Float|Int) - Optional, X position of the viewport.
+// x (Float|Int) - Optional,Y position of the viewport.
+// width (Float|Int) - Optional, Width of the viewport.
+// height (Float|Int) - Optional, Height of the viewport.
+// format (String) - Optional, Either "jpeg" or "png".
+// quality (Int) - Optional, Quality, in [0, 100], only for jpeg format.
+// @returns data (Binary) - Returns a base64 encoded string in binary format.
func Screenshot(ctx context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 2)
if err != nil {
@@ -172,27 +170,25 @@ func ValidatePageRanges(pageRanges string) (bool, error) {
return match, nil
}
-/*
- * Print a PDF of the current page.
- * @param source (Document) - Document.
- * @param params (Object) - Optional, An object containing the following properties :
- * Landscape (Bool) - Paper orientation. Defaults to false.
- * DisplayHeaderFooter (Bool) - Display header and footer. Defaults to false.
- * PrintBackground (Bool) - Print background graphics. Defaults to false.
- * Scale (Float64) - Scale of the webpage rendering. Defaults to 1.
- * PaperWidth (Float64) - Paper width in inches. Defaults to 8.5 inches.
- * PaperHeight (Float64) - Paper height in inches. Defaults to 11 inches.
- * MarginTop (Float64) - Top margin in inches. Defaults to 1cm (~0.4 inches).
- * MarginBottom (Float64) - Bottom margin in inches. Defaults to 1cm (~0.4 inches).
- * MarginLeft (Float64) - Left margin in inches. Defaults to 1cm (~0.4 inches).
- * MarginRight (Float64) - Right margin in inches. Defaults to 1cm (~0.4 inches).
- * PageRanges (String) - Paper ranges to print, e.g., '1-5, 8, 11-13'. Defaults to the empty string, which means print all pages.
- * IgnoreInvalidPageRanges (Bool) - to silently ignore invalid but successfully parsed page ranges, such as '3-2'. Defaults to false.
- * HeaderTemplate (String) - HTML template for the print header. Should be valid HTML markup with following classes used to inject printing values into them: - `date`: formatted print date - `title`: document title - `url`: document location - `pageNumber`: current page number - `totalPages`: total pages in the document For example, `` would generate span containing the title.
- * FooterTemplate (String) - HTML template for the print footer. Should use the same format as the `headerTemplate`.
- * PreferCSSPageSize (Bool) - Whether or not to prefer page size as defined by css. Defaults to false, in which case the content will be scaled to fit the paper size. *
- * @returns data (Binary) - Returns a base64 encoded string in binary format.
- */
+// PDF print a PDF of the current page.
+// @param source (Document) - Document.
+// @param params (Object) - Optional, An object containing the following properties :
+// Landscape (Bool) - Paper orientation. Defaults to false.
+// DisplayHeaderFooter (Bool) - Display header and footer. Defaults to false.
+// PrintBackground (Bool) - Print background graphics. Defaults to false.
+// Scale (Float64) - Scale of the webpage rendering. Defaults to 1.
+// PaperWidth (Float64) - Paper width in inches. Defaults to 8.5 inches.
+// PaperHeight (Float64) - Paper height in inches. Defaults to 11 inches.
+// MarginTop (Float64) - Top margin in inches. Defaults to 1cm (~0.4 inches).
+// MarginBottom (Float64) - Bottom margin in inches. Defaults to 1cm (~0.4 inches).
+// MarginLeft (Float64) - Left margin in inches. Defaults to 1cm (~0.4 inches).
+// MarginRight (Float64) - Right margin in inches. Defaults to 1cm (~0.4 inches).
+// PageRanges (String) - Paper ranges to print, e.g., '1-5, 8, 11-13'. Defaults to the empty string, which means print all pages.
+// IgnoreInvalidPageRanges (Bool) - to silently ignore invalid but successfully parsed page ranges, such as '3-2'. Defaults to false.
+// HeaderTemplate (String) - HTML template for the print header. Should be valid HTML markup with following classes used to inject printing values into them: - `date`: formatted print date - `title`: document title - `url`: document location - `pageNumber`: current page number - `totalPages`: total pages in the document For example, `` would generate span containing the title.
+// FooterTemplate (String) - HTML template for the print footer. Should use the same format as the `headerTemplate`.
+// PreferCSSPageSize (Bool) - Whether or not to prefer page size as defined by css. Defaults to false, in which case the content will be scaled to fit the paper size. *
+// @returns data (Binary) - Returns a base64 encoded string in binary format.
func PDF(ctx context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 2)
if err != nil {
diff --git a/pkg/stdlib/html/click.go b/pkg/stdlib/html/click.go
index c97af7fe..d5af7a10 100644
--- a/pkg/stdlib/html/click.go
+++ b/pkg/stdlib/html/click.go
@@ -2,16 +2,15 @@ package html
import (
"context"
+
"github.com/MontFerret/ferret/pkg/html/dynamic"
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Dispatches click event on a given element
- * @param source (Document | Element) - Event source.
- * @param selector (String, optional) - Optional selector. Only used when a document instance is passed.
- */
+// Click dispatches click event on a given element
+// @param source (Document | Element) - Event source.
+// @param selector (String, optional) - Optional selector. Only used when a document instance is passed.
func Click(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 2)
diff --git a/pkg/stdlib/html/click_all.go b/pkg/stdlib/html/click_all.go
index 7499f52c..04ab04a5 100644
--- a/pkg/stdlib/html/click_all.go
+++ b/pkg/stdlib/html/click_all.go
@@ -2,17 +2,16 @@ package html
import (
"context"
+
"github.com/MontFerret/ferret/pkg/html/dynamic"
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Dispatches click event on all matched element
- * @param source (Document) - Document.
- * @param selector (String) - Selector.
- * @returns (Boolean) - Returns true if matched at least one element.
- */
+// ClickAll dispatches click event on all matched element
+// @param source (Document) - Document.
+// @param selector (String) - Selector.
+// @returns (Boolean) - Returns true if matched at least one element.
func ClickAll(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 2, 2)
diff --git a/pkg/stdlib/html/document.go b/pkg/stdlib/html/document.go
index 5dfd4002..5c95a0bc 100644
--- a/pkg/stdlib/html/document.go
+++ b/pkg/stdlib/html/document.go
@@ -2,19 +2,18 @@ package html
import (
"context"
+
"github.com/MontFerret/ferret/pkg/html"
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Loads a document by a given url.
- * By default, loads a document by http call - resulted document does not support any interactions.
- * If passed "true" as a second argument, headless browser is used for loading the document which support interactions.
- * @param url (String) - Target url string. If passed "about:blank" for dynamic document - it will open an empty page.
- * @param dynamic (Boolean) - Optional boolean value indicating whether to use dynamic document.
- * @returns (HTMLDocument) - Returns loaded HTML document.
- */
+// Document loads a document by a given url.
+// By default, loads a document by http call - resulted document does not support any interactions.
+// If passed "true" as a second argument, headless browser is used for loading the document which support interactions.
+// @param url (String) - Target url string. If passed "about:blank" for dynamic document - it will open an empty page.
+// @param dynamic (Boolean) - Optional boolean value indicating whether to use dynamic document.
+// @returns (HTMLDocument) - Returns loaded HTML document.
func Document(ctx context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 2)
diff --git a/pkg/stdlib/html/document_parse.go b/pkg/stdlib/html/document_parse.go
index e87130a8..90aaee8c 100644
--- a/pkg/stdlib/html/document_parse.go
+++ b/pkg/stdlib/html/document_parse.go
@@ -2,18 +2,17 @@ package html
import (
"context"
+
"github.com/MontFerret/ferret/pkg/html"
"github.com/MontFerret/ferret/pkg/html/static"
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Parses a given HTML string and returns a HTML document.
- * Returned HTML document is always static.
- * @param html (String) - Target HTML string.
- * @returns (HTMLDocument) - Parsed HTML static document.
- */
+// DocumentParse parses a given HTML string and returns a HTML document.
+// Returned HTML document is always static.
+// @param html (String) - Target HTML string.
+// @returns (HTMLDocument) - Parsed HTML static document.
func DocumentParse(ctx context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 1)
diff --git a/pkg/stdlib/html/element.go b/pkg/stdlib/html/element.go
index a29c99a3..e548609f 100644
--- a/pkg/stdlib/html/element.go
+++ b/pkg/stdlib/html/element.go
@@ -2,17 +2,16 @@ package html
import (
"context"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Finds an element by a given CSS selector.
- * Returns NONE if element not found.
- * @param docOrEl (HTMLDocument|HTMLElement) - Parent document or element.
- * @param selector (String) - CSS selector.
- * @returns (HTMLElement | None) - Returns an HTMLElement if found, otherwise NONE.
- */
+// Element finds an element by a given CSS selector.
+// Returns NONE if element not found.
+// @param docOrEl (HTMLDocument|HTMLElement) - Parent document or element.
+// @param selector (String) - CSS selector.
+// @returns (HTMLElement | None) - Returns an HTMLElement if found, otherwise NONE.
func Element(_ context.Context, args ...core.Value) (core.Value, error) {
el, selector, err := queryArgs(args)
diff --git a/pkg/stdlib/html/elements.go b/pkg/stdlib/html/elements.go
index 433871e7..c387f6cc 100644
--- a/pkg/stdlib/html/elements.go
+++ b/pkg/stdlib/html/elements.go
@@ -2,17 +2,16 @@ package html
import (
"context"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Finds HTML elements by a given CSS selector.
- * Returns an empty array if element not found.
- * @param docOrEl (HTMLDocument|HTMLElement) - Parent document or element.
- * @param selector (String) - CSS selector.
- * @returns (Array) - Returns an array of found HTML element.
- */
+// Elements finds HTML elements by a given CSS selector.
+// Returns an empty array if element not found.
+// @param docOrEl (HTMLDocument|HTMLElement) - Parent document or element.
+// @param selector (String) - CSS selector.
+// @returns (Array) - Returns an array of found HTML element.
func Elements(_ context.Context, args ...core.Value) (core.Value, error) {
el, selector, err := queryArgs(args)
diff --git a/pkg/stdlib/html/elements_count.go b/pkg/stdlib/html/elements_count.go
index 84cb73cd..92fe9367 100644
--- a/pkg/stdlib/html/elements_count.go
+++ b/pkg/stdlib/html/elements_count.go
@@ -2,17 +2,16 @@ package html
import (
"context"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Returns a number of found HTML elements by a given CSS selector.
- * Returns an empty array if element not found.
- * @param docOrEl (HTMLDocument|HTMLElement) - Parent document or element.
- * @param selector (String) - CSS selector.
- * @returns (Int) - A number of found HTML elements by a given CSS selector.
- */
+// ElementsCount returns a number of found HTML elements by a given CSS selector.
+// Returns an empty array if element not found.
+// @param docOrEl (HTMLDocument|HTMLElement) - Parent document or element.
+// @param selector (String) - CSS selector.
+// @returns (Int) - A number of found HTML elements by a given CSS selector.
func ElementsCount(_ context.Context, args ...core.Value) (core.Value, error) {
el, selector, err := queryArgs(args)
diff --git a/pkg/stdlib/html/inner_html.go b/pkg/stdlib/html/inner_html.go
index f093e88c..63cbf8dc 100644
--- a/pkg/stdlib/html/inner_html.go
+++ b/pkg/stdlib/html/inner_html.go
@@ -2,16 +2,15 @@ package html
import (
"context"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Returns inner HTML string of a matched element
- * @param doc (Document|Element) - Parent document or element.
- * @param selector (String) - String of CSS selector.
- * @returns (String) - Inner HTML string if an element found, otherwise empty string.
- */
+// InnerHTML Returns inner HTML string of a matched element
+// @param doc (Document|Element) - Parent document or element.
+// @param selector (String) - String of CSS selector.
+// @returns (String) - Inner HTML string if an element found, otherwise empty string.
func InnerHTML(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 2, 2)
diff --git a/pkg/stdlib/html/inner_html_all.go b/pkg/stdlib/html/inner_html_all.go
index c518930e..11ccaf28 100644
--- a/pkg/stdlib/html/inner_html_all.go
+++ b/pkg/stdlib/html/inner_html_all.go
@@ -2,16 +2,15 @@ package html
import (
"context"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Returns an array of inner HTML strings of matched elements.
- * @param doc (HTMLDocument|HTMLElement) - Parent document or element.
- * @param selector (String) - String of CSS selector.
- * @returns (String) - An array of inner HTML strings if any element found, otherwise empty array.
- */
+// InnerHTMLAll returns an array of inner HTML strings of matched elements.
+// @param doc (HTMLDocument|HTMLElement) - Parent document or element.
+// @param selector (String) - String of CSS selector.
+// @returns (String) - An array of inner HTML strings if any element found, otherwise empty array.
func InnerHTMLAll(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 2, 2)
diff --git a/pkg/stdlib/html/inner_text.go b/pkg/stdlib/html/inner_text.go
index 9eea1831..ea6aaa83 100644
--- a/pkg/stdlib/html/inner_text.go
+++ b/pkg/stdlib/html/inner_text.go
@@ -2,16 +2,15 @@ package html
import (
"context"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Returns inner text of a matched element
- * @param doc (HTMLDocument|HTMLElement) - Parent document or element.
- * @param selector (String) - String of CSS selector.
- * @returns (String) - Inner text if an element found, otherwise empty string.
- */
+// InnerText returns inner text of a matched element
+// @param doc (HTMLDocument|HTMLElement) - Parent document or element.
+// @param selector (String) - String of CSS selector.
+// @returns (String) - Inner text if an element found, otherwise empty string.
func InnerText(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 2, 2)
diff --git a/pkg/stdlib/html/inner_text_all.go b/pkg/stdlib/html/inner_text_all.go
index 040a362e..2d8bea91 100644
--- a/pkg/stdlib/html/inner_text_all.go
+++ b/pkg/stdlib/html/inner_text_all.go
@@ -2,16 +2,15 @@ package html
import (
"context"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Returns an array of inner text of matched elements.
- * @param doc (HTMLDocument|HTMLElement) - Parent document or element.
- * @param selector (String) - String of CSS selector.
- * @returns (String) - An array of inner text if any element found, otherwise empty array.
- */
+// InnerTextAll returns an array of inner text of matched elements.
+// @param doc (HTMLDocument|HTMLElement) - Parent document or element.
+// @param selector (String) - String of CSS selector.
+// @returns (String) - An array of inner text if any element found, otherwise empty array.
func InnerTextAll(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 2, 2)
diff --git a/pkg/stdlib/html/input.go b/pkg/stdlib/html/input.go
index 401361c6..7dd30caa 100644
--- a/pkg/stdlib/html/input.go
+++ b/pkg/stdlib/html/input.go
@@ -8,14 +8,12 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Types a value to an underlying input element.
- * @param source (Document | Element) - Event target.
- * @param valueOrSelector (String) - Selector or a value.
- * @param value (String) - Target value.
- * @param delay (Int, optional) - Waits delay milliseconds between keystrokes
- * @returns (Boolean) - Returns true if an element was found.
- */
+// Input types a value to an underlying input element.
+// @param source (Document | Element) - Event target.
+// @param valueOrSelector (String) - Selector or a value.
+// @param value (String) - Target value.
+// @param delay (Int, optional) - Waits delay milliseconds between keystrokes
+// @returns (Boolean) - Returns true if an element was found.
func Input(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 2, 4)
diff --git a/pkg/stdlib/html/navigate.go b/pkg/stdlib/html/navigate.go
index a523a82b..0c8a5ca5 100644
--- a/pkg/stdlib/html/navigate.go
+++ b/pkg/stdlib/html/navigate.go
@@ -2,19 +2,18 @@ package html
import (
"context"
+
"github.com/MontFerret/ferret/pkg/html/dynamic"
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Navigates a document to a new resource.
- * The operation blocks the execution until the page gets loaded.
- * Which means there is no need in WAIT_NAVIGATION function.
- * @param doc (Document) - Target document.
- * @param url (String) - Target url to navigate.
- * @param timeout (Int, optional) - Optional timeout. Default is 5000.
- */
+// Navigate navigates a document to a new resource.
+// The operation blocks the execution until the page gets loaded.
+// Which means there is no need in WAIT_NAVIGATION function.
+// @param doc (Document) - Target document.
+// @param url (String) - Target url to navigate.
+// @param timeout (Int, optional) - Optional timeout. Default is 5000.
func Navigate(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 2, 3)
diff --git a/pkg/stdlib/html/navigate_back.go b/pkg/stdlib/html/navigate_back.go
index 919c6b70..736e6643 100644
--- a/pkg/stdlib/html/navigate_back.go
+++ b/pkg/stdlib/html/navigate_back.go
@@ -2,20 +2,19 @@ package html
import (
"context"
+
"github.com/MontFerret/ferret/pkg/html/dynamic"
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Navigates a document back within its navigation history.
- * The operation blocks the execution until the page gets loaded.
- * If the history is empty, the function returns FALSE.
- * @param doc (Document) - Target document.
- * @param entry (Int, optional) - Optional value indicating how many pages to skip. Default 1.
- * @param timeout (Int, optional) - Optional timeout. Default is 5000.
- * @returns (Boolean) - Returns TRUE if history exists and the operation succeeded, otherwise FALSE.
- */
+// NavigateBack navigates a document back within its navigation history.
+// The operation blocks the execution until the page gets loaded.
+// If the history is empty, the function returns FALSE.
+// @param doc (Document) - Target document.
+// @param entry (Int, optional) - Optional value indicating how many pages to skip. Default 1.
+// @param timeout (Int, optional) - Optional timeout. Default is 5000.
+// @returns (Boolean) - Returns TRUE if history exists and the operation succeeded, otherwise FALSE.
func NavigateBack(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 3)
diff --git a/pkg/stdlib/html/navigate_forward.go b/pkg/stdlib/html/navigate_forward.go
index 56a2e85f..51863909 100644
--- a/pkg/stdlib/html/navigate_forward.go
+++ b/pkg/stdlib/html/navigate_forward.go
@@ -2,20 +2,19 @@ package html
import (
"context"
+
"github.com/MontFerret/ferret/pkg/html/dynamic"
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Navigates a document forward within its navigation history.
- * The operation blocks the execution until the page gets loaded.
- * If the history is empty, the function returns FALSE.
- * @param doc (Document) - Target document.
- * @param entry (Int, optional) - Optional value indicating how many pages to skip. Default 1.
- * @param timeout (Int, optional) - Optional timeout. Default is 5000.
- * @returns (Boolean) - Returns TRUE if history exists and the operation succeeded, otherwise FALSE.
- */
+// NavigateForward navigates a document forward within its navigation history.
+// The operation blocks the execution until the page gets loaded.
+// If the history is empty, the function returns FALSE.
+// @param doc (Document) - Target document.
+// @param entry (Int, optional) - Optional value indicating how many pages to skip. Default 1.
+// @param timeout (Int, optional) - Optional timeout. Default is 5000.
+// @returns (Boolean) - Returns TRUE if history exists and the operation succeeded, otherwise FALSE.
func NavigateForward(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 3)
diff --git a/pkg/stdlib/html/wait_class.go b/pkg/stdlib/html/wait_class.go
index bd54d02f..699901a2 100644
--- a/pkg/stdlib/html/wait_class.go
+++ b/pkg/stdlib/html/wait_class.go
@@ -2,22 +2,21 @@ package html
import (
"context"
+
"github.com/MontFerret/ferret/pkg/html/dynamic"
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Waits for a class to appear on a given element.
- * Stops the execution until the navigation ends or operation times out.
- * @param docOrEl (HTMLDocument|HTMLElement) - Target document or element.
- * @param selectorOrClass (String) - If document is passed, this param must represent an element selector.
- * Otherwise target class.
- * @param classOrTimeout (String|Int, optional) - If document is passed, this param must represent target class name.
- * Otherwise timeout.
- * @param timeout (Int, optional) - If document is passed, this param must represent timeout.
- * Otherwise not passed.
- */
+// WaitClass waits for a class to appear on a given element.
+// Stops the execution until the navigation ends or operation times out.
+// @param docOrEl (HTMLDocument|HTMLElement) - Target document or element.
+// @param selectorOrClass (String) - If document is passed, this param must represent an element selector.
+// Otherwise target class.
+// @param classOrTimeout (String|Int, optional) - If document is passed, this param must represent target class name.
+// Otherwise timeout.
+// @param timeout (Int, optional) - If document is passed, this param must represent timeout.
+// Otherwise not passed.
func WaitClass(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 2, 4)
diff --git a/pkg/stdlib/html/wait_class_all.go b/pkg/stdlib/html/wait_class_all.go
index 30cf1b2a..be1f60ae 100644
--- a/pkg/stdlib/html/wait_class_all.go
+++ b/pkg/stdlib/html/wait_class_all.go
@@ -2,19 +2,18 @@ package html
import (
"context"
+
"github.com/MontFerret/ferret/pkg/html/dynamic"
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Waits for a class to appear on all matched elements.
- * Stops the execution until the navigation ends or operation times out.
- * @param doc (HTMLDocument) - Parent document.
- * @param selector (String) - String of CSS selector.
- * @param class (String) - String of target CSS class.
- * @param timeout (Int, optional) - Optional timeout.
- */
+// WaitClassAll waits for a class to appear on all matched elements.
+// Stops the execution until the navigation ends or operation times out.
+// @param doc (HTMLDocument) - Parent document.
+// @param selector (String) - String of CSS selector.
+// @param class (String) - String of target CSS class.
+// @param timeout (Int, optional) - Optional timeout.
func WaitClassAll(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 3, 4)
diff --git a/pkg/stdlib/html/wait_element.go b/pkg/stdlib/html/wait_element.go
index 9fb43f51..27270d71 100644
--- a/pkg/stdlib/html/wait_element.go
+++ b/pkg/stdlib/html/wait_element.go
@@ -2,18 +2,17 @@ package html
import (
"context"
+
"github.com/MontFerret/ferret/pkg/html/dynamic"
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Waits for element to appear in the DOM.
- * Stops the execution until it finds an element or operation times out.
- * @param doc (HTMLDocument) - Dynamic HTMLDocument.
- * @param selector (String) - Target element's selector.
- * @param timeout (Int, optional) - Optional timeout. Default 5000 ms.
- */
+// WaitElement waits for element to appear in the DOM.
+// Stops the execution until it finds an element or operation times out.
+// @param doc (HTMLDocument) - Dynamic HTMLDocument.
+// @param selector (String) - Target element's selector.
+// @param timeout (Int, optional) - Optional timeout. Default 5000 ms.
func WaitElement(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 2, 3)
diff --git a/pkg/stdlib/html/wait_navigation.go b/pkg/stdlib/html/wait_navigation.go
index 7c1756cc..30f6e99a 100644
--- a/pkg/stdlib/html/wait_navigation.go
+++ b/pkg/stdlib/html/wait_navigation.go
@@ -2,17 +2,16 @@ package html
import (
"context"
+
"github.com/MontFerret/ferret/pkg/html/dynamic"
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Waits for document to navigate to a new url.
- * Stops the execution until the navigation ends or operation times out.
- * @param doc (HTMLDocument) - Dynamic HTMLDocument.
- * @param timeout (Int, optional) - Optional timeout. Default 5000 ms.
- */
+// WaitNavigation waits for document to navigate to a new url.
+// Stops the execution until the navigation ends or operation times out.
+// @param doc (HTMLDocument) - Dynamic HTMLDocument.
+// @param timeout (Int, optional) - Optional timeout. Default 5000 ms.
func WaitNavigation(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 2)
diff --git a/pkg/stdlib/math/abs.go b/pkg/stdlib/math/abs.go
index 69890cd8..fda5d74c 100644
--- a/pkg/stdlib/math/abs.go
+++ b/pkg/stdlib/math/abs.go
@@ -2,16 +2,15 @@ package math
import (
"context"
+ "math"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
- "math"
)
-/*
- * Returns the absolute value of a given number.
- * @param number (Int|Float) - Input number.
- * @returns (Float) - The absolute value of a given number.
- */
+// Abs returns the absolute value of a given number.
+// @param number (Int|Float) - Input number.
+// @returns (Float) - The absolute value of a given number.
func Abs(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 1)
diff --git a/pkg/stdlib/math/acos.go b/pkg/stdlib/math/acos.go
index abcc24bb..30d2deb2 100644
--- a/pkg/stdlib/math/acos.go
+++ b/pkg/stdlib/math/acos.go
@@ -2,16 +2,15 @@ package math
import (
"context"
+ "math"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
- "math"
)
-/*
- * Returns the arccosine, in radians, of a given number.
- * @param number (Int|Float) - Input number.
- * @returns (Float) - The arccosine, in radians, of a given number.
- */
+// Acos returns the arccosine, in radians, of a given number.
+// @param number (Int|Float) - Input number.
+// @returns (Float) - The arccosine, in radians, of a given number.
func Acos(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 1)
diff --git a/pkg/stdlib/math/asin.go b/pkg/stdlib/math/asin.go
index 1744bde5..5498f5ba 100644
--- a/pkg/stdlib/math/asin.go
+++ b/pkg/stdlib/math/asin.go
@@ -2,16 +2,15 @@ package math
import (
"context"
+ "math"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
- "math"
)
-/*
- * Returns the arcsine, in radians, of a given number.
- * @param number (Int|Float) - Input number.
- * @returns (Float) - The arcsine, in radians, of a given number.
- */
+// Asin returns the arcsine, in radians, of a given number.
+// @param number (Int|Float) - Input number.
+// @returns (Float) - The arcsine, in radians, of a given number.
func Asin(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 1)
diff --git a/pkg/stdlib/math/atan.go b/pkg/stdlib/math/atan.go
index 3364c46e..6db5ad73 100644
--- a/pkg/stdlib/math/atan.go
+++ b/pkg/stdlib/math/atan.go
@@ -2,16 +2,15 @@ package math
import (
"context"
+ "math"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
- "math"
)
-/*
- * Returns the arctangent, in radians, of a given number.
- * @param number (Int|Float) - Input number.
- * @returns (Float) - The arctangent, in radians, of a given number.
- */
+// Atan returns the arctangent, in radians, of a given number.
+// @param number (Int|Float) - Input number.
+// @returns (Float) - The arctangent, in radians, of a given number.
func Atan(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 1)
diff --git a/pkg/stdlib/math/atan2.go b/pkg/stdlib/math/atan2.go
index ac19d27f..5475ae4f 100644
--- a/pkg/stdlib/math/atan2.go
+++ b/pkg/stdlib/math/atan2.go
@@ -2,17 +2,16 @@ package math
import (
"context"
+ "math"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
- "math"
)
-/*
- * Returns the arc tangent of y/x, using the signs of the two to determine the quadrant of the return value.
- * @param number1 (Int|Float) - Input number.
- * @param number2 (Int|Float) - Input number.
- * @returns (Float) - The arc tangent of y/x, using the signs of the two to determine the quadrant of the return value.
- */
+// Atan2 returns the arc tangent of y/x, using the signs of the two to determine the quadrant of the return value.
+// @param number1 (Int|Float) - Input number.
+// @param number2 (Int|Float) - Input number.
+// @returns (Float) - The arc tangent of y/x, using the signs of the two to determine the quadrant of the return value.
func Atan2(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 2, 2)
diff --git a/pkg/stdlib/math/average.go b/pkg/stdlib/math/average.go
index 50e3df58..2034bdd8 100644
--- a/pkg/stdlib/math/average.go
+++ b/pkg/stdlib/math/average.go
@@ -2,15 +2,14 @@ package math
import (
"context"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Returns the average (arithmetic mean) of the values in array.
- * @param array (Array) - Array of numbers.
- * @returns (Float) - The average of the values in array.
- */
+// Average Returns the average (arithmetic mean) of the values in array.
+// @param array (Array) - Array of numbers.
+// @returns (Float) - The average of the values in array.
func Average(_ context.Context, args ...core.Value) (core.Value, error) {
var err error
err = core.ValidateArgs(args, 1, 1)
diff --git a/pkg/stdlib/math/ceil.go b/pkg/stdlib/math/ceil.go
index a088e3b7..3d0cac0a 100644
--- a/pkg/stdlib/math/ceil.go
+++ b/pkg/stdlib/math/ceil.go
@@ -2,16 +2,15 @@ package math
import (
"context"
+ "math"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
- "math"
)
-/*
- * Returns the least integer value greater than or equal to a given value.
- * @param number (Int|Float) - Input number.
- * @returns (Int) - The least integer value greater than or equal to a given value.
- */
+// Ceil returns the least integer value greater than or equal to a given value.
+// @param number (Int|Float) - Input number.
+// @returns (Int) - The least integer value greater than or equal to a given value.
func Ceil(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 1)
diff --git a/pkg/stdlib/math/cos.go b/pkg/stdlib/math/cos.go
index 401de986..1f000aa0 100644
--- a/pkg/stdlib/math/cos.go
+++ b/pkg/stdlib/math/cos.go
@@ -2,16 +2,15 @@ package math
import (
"context"
+ "math"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
- "math"
)
-/*
- * Returns the cosine of a given number.
- * @param number (Int|Float) - Input number.
- * @returns (Float) - The cosine of a given number.
- */
+// Cos returns the cosine of a given number.
+// @param number (Int|Float) - Input number.
+// @returns (Float) - The cosine of a given number.
func Cos(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 1)
diff --git a/pkg/stdlib/math/degrees.go b/pkg/stdlib/math/degrees.go
index 82816dc8..99debe6d 100644
--- a/pkg/stdlib/math/degrees.go
+++ b/pkg/stdlib/math/degrees.go
@@ -2,15 +2,14 @@ package math
import (
"context"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Returns the angle converted from radians to degrees.
- * @param number (Float|Int) - The input number.
- * @returns (Float) - The angle in degrees.
- */
+// Degrees returns the angle converted from radians to degrees.
+// @param number (Float|Int) - The input number.
+// @returns (Float) - The angle in degrees.l
func Degrees(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 1)
diff --git a/pkg/stdlib/math/exp.go b/pkg/stdlib/math/exp.go
index c6b8308f..fac9a05a 100644
--- a/pkg/stdlib/math/exp.go
+++ b/pkg/stdlib/math/exp.go
@@ -2,16 +2,15 @@ package math
import (
"context"
+ "math"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
- "math"
)
-/*
- * Returns Euler's constant (2.71828...) raised to the power of value.
- * @param number (Int|Float) - Input number.
- * @returns (Float) - Euler's constant raised to the power of value.
- */
+// Exp returns Euler's constant (2.71828...) raised to the power of value.
+// @param number (Int|Float) - Input number.
+// @returns (Float) - Euler's constant raised to the power of value.
func Exp(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 1)
diff --git a/pkg/stdlib/math/exp2.go b/pkg/stdlib/math/exp2.go
index fa681913..85fff327 100644
--- a/pkg/stdlib/math/exp2.go
+++ b/pkg/stdlib/math/exp2.go
@@ -2,16 +2,15 @@ package math
import (
"context"
+ "math"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
- "math"
)
-/*
- * Returns 2 raised to the power of value.
- * @param number (Int|Float) - Input number.
- * @returns (Float) - 2 raised to the power of value.
- */
+// Exp2 returns 2 raised to the power of value.
+// @param number (Int|Float) - Input number.
+// @returns (Float) - 2 raised to the power of value.
func Exp2(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 1)
diff --git a/pkg/stdlib/math/floor.go b/pkg/stdlib/math/floor.go
index 5601f493..28dc34e9 100644
--- a/pkg/stdlib/math/floor.go
+++ b/pkg/stdlib/math/floor.go
@@ -2,16 +2,15 @@ package math
import (
"context"
+ "math"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
- "math"
)
-/*
- * Returns the greatest integer value less than or equal to a given value.
- * @param number (Int|Float) - Input number.
- * @returns (Int) - The greatest integer value less than or equal to a given value.
- */
+// Floor returns the greatest integer value less than or equal to a given value.
+// @param number (Int|Float) - Input number.
+// @returns (Int) - The greatest integer value less than or equal to a given value.
func Floor(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 1)
diff --git a/pkg/stdlib/math/log.go b/pkg/stdlib/math/log.go
index b9d84208..c37bff77 100644
--- a/pkg/stdlib/math/log.go
+++ b/pkg/stdlib/math/log.go
@@ -2,16 +2,15 @@ package math
import (
"context"
+ "math"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
- "math"
)
-/*
- * Returns the natural logarithm of a given value.
- * @param number (Int|Float) - Input number.
- * @returns (Float) - The natural logarithm of a given value.
- */
+// Log returns the natural logarithm of a given value.
+// @param number (Int|Float) - Input number.
+// @returns (Float) - The natural logarithm of a given value.
func Log(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 1)
diff --git a/pkg/stdlib/math/log10.go b/pkg/stdlib/math/log10.go
index 5619b5d2..dba695df 100644
--- a/pkg/stdlib/math/log10.go
+++ b/pkg/stdlib/math/log10.go
@@ -2,16 +2,15 @@ package math
import (
"context"
+ "math"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
- "math"
)
-/*
- * Returns the decimal logarithm of a given value.
- * @param number (Int|Float) - Input number.
- * @returns (Float) - The decimal logarithm of a given value.
- */
+// Log10 returns the decimal logarithm of a given value.
+// @param number (Int|Float) - Input number.
+// @returns (Float) - The decimal logarithm of a given value.
func Log10(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 1)
diff --git a/pkg/stdlib/math/log2.go b/pkg/stdlib/math/log2.go
index b0f93afd..bdca6f14 100644
--- a/pkg/stdlib/math/log2.go
+++ b/pkg/stdlib/math/log2.go
@@ -2,16 +2,15 @@ package math
import (
"context"
+ "math"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
- "math"
)
-/*
- * Returns the binary logarithm of a given value.
- * @param number (Int|Float) - Input number.
- * @returns (Float) - The binary logarithm of a given value.
- */
+// Log2 returns the binary logarithm of a given value.
+// @param number (Int|Float) - Input number.
+// @returns (Float) - The binary logarithm of a given value.
func Log2(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 1)
diff --git a/pkg/stdlib/math/max.go b/pkg/stdlib/math/max.go
index 48a61135..77ed55a9 100644
--- a/pkg/stdlib/math/max.go
+++ b/pkg/stdlib/math/max.go
@@ -2,15 +2,14 @@ package math
import (
"context"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Returns the greatest (arithmetic mean) of the values in array.
- * @param array (Array) - Array of numbers.
- * @returns (Float) - The greatest of the values in array.
- */
+// Max returns the greatest (arithmetic mean) of the values in array.
+// @param array (Array) - Array of numbers.
+// @returns (Float) - The greatest of the values in array.
func Max(_ context.Context, args ...core.Value) (core.Value, error) {
var err error
err = core.ValidateArgs(args, 1, 1)
diff --git a/pkg/stdlib/math/median.go b/pkg/stdlib/math/median.go
index ccd64bd1..da2bb7f9 100644
--- a/pkg/stdlib/math/median.go
+++ b/pkg/stdlib/math/median.go
@@ -2,16 +2,15 @@ package math
import (
"context"
+ "math"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
- "math"
)
-/*
- * Returns the median of the values in array.
- * @param array (Array) - Array of numbers.
- * @returns (Float) - The median of the values in array.
- */
+// Median returns the median of the values in array.
+// @param array (Array) - Array of numbers.
+// @returns (Float) - The median of the values in array.
func Median(_ context.Context, args ...core.Value) (core.Value, error) {
var err error
err = core.ValidateArgs(args, 1, 1)
diff --git a/pkg/stdlib/math/min.go b/pkg/stdlib/math/min.go
index 900d114c..ba3980c4 100644
--- a/pkg/stdlib/math/min.go
+++ b/pkg/stdlib/math/min.go
@@ -2,15 +2,14 @@ package math
import (
"context"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Returns the smallest (arithmetic mean) of the values in array.
- * @param array (Array) - Array of numbers.
- * @returns (Float) - The smallest of the values in array.
- */
+// Min returns the smallest (arithmetic mean) of the values in array.
+// @param array (Array) - Array of numbers.
+// @returns (Float) - The smallest of the values in array.
func Min(_ context.Context, args ...core.Value) (core.Value, error) {
var err error
err = core.ValidateArgs(args, 1, 1)
diff --git a/pkg/stdlib/math/percentile.go b/pkg/stdlib/math/percentile.go
index 35b92c87..4b047bb9 100644
--- a/pkg/stdlib/math/percentile.go
+++ b/pkg/stdlib/math/percentile.go
@@ -2,19 +2,18 @@ package math
import (
"context"
+ "math"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
"github.com/pkg/errors"
- "math"
)
-/*
- * Returns the nth percentile of the values in a given array.
- * @param array (Array) - Array of numbers.
- * @param numb (Int) - A number which must be between 0 (excluded) and 100 (included).
- * @param method (String, optional) - "rank" (default) or "interpolation".
- * @returns (Float) - The nth percentile, or null if the array is empty or only null values are contained in it or the percentile cannot be calculated.
- */
+// Percentile returns the nth percentile of the values in a given array.
+// @param array (Array) - Array of numbers.
+// @param numb (Int) - A number which must be between 0 (excluded) and 100 (included).
+// @param method (String, optional) - "rank" (default) or "interpolation".
+// @returns (Float) - The nth percentile, or null if the array is empty or only null values are contained in it or the percentile cannot be calculated.
func Percentile(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 2, 3)
diff --git a/pkg/stdlib/math/pi.go b/pkg/stdlib/math/pi.go
index 101209fe..fb04582f 100644
--- a/pkg/stdlib/math/pi.go
+++ b/pkg/stdlib/math/pi.go
@@ -2,15 +2,14 @@ package math
import (
"context"
+ "math"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
- "math"
)
-/*
- * Returns Pi value.
- * @returns (Float) - Pi value.
- */
+// Pi returns Pi value.
+// @returns (Float) - Pi value.
func Pi(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 0, 0)
diff --git a/pkg/stdlib/math/pow.go b/pkg/stdlib/math/pow.go
index bd3df379..588daf5f 100644
--- a/pkg/stdlib/math/pow.go
+++ b/pkg/stdlib/math/pow.go
@@ -2,17 +2,16 @@ package math
import (
"context"
+ "math"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
- "math"
)
-/*
- * Returns the base to the exponent value.
- * @param base (Int|Float) - The base value.
- * @param exp (Int|Float) - The exponent value.
- * @returns (Float) - The exponentiated value.
- */
+// Pow returns the base to the exponent value.
+// @param base (Int|Float) - The base value.
+// @param exp (Int|Float) - The exponent value.
+// @returns (Float) - The exponentiated value.
func Pow(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 2, 2)
diff --git a/pkg/stdlib/math/radians.go b/pkg/stdlib/math/radians.go
index b033d572..058392a2 100644
--- a/pkg/stdlib/math/radians.go
+++ b/pkg/stdlib/math/radians.go
@@ -2,15 +2,14 @@ package math
import (
"context"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Returns the angle converted from degrees to radians.
- * @param number (Float|Int) - The input number.
- * @returns (Float) - The angle in radians.
- */
+// Radians returns the angle converted from degrees to radians.
+// @param number (Float|Int) - The input number.
+// @returns (Float) - The angle in radians.
func Radians(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 1)
diff --git a/pkg/stdlib/math/rand.go b/pkg/stdlib/math/rand.go
index 45fd6202..c5fb31f7 100644
--- a/pkg/stdlib/math/rand.go
+++ b/pkg/stdlib/math/rand.go
@@ -2,15 +2,14 @@ package math
import (
"context"
+ "math/rand"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
- "math/rand"
)
-/*
- * Return a pseudo-random number between 0 and 1.
- * @returns (Float) - A number greater than 0 and less than 1.
- */
+// Rand return a pseudo-random number between 0 and 1.
+// @returns (Float) - A number greater than 0 and less than 1.
func Rand(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 0, 0)
diff --git a/pkg/stdlib/math/range.go b/pkg/stdlib/math/range.go
index 86833911..a895f53a 100644
--- a/pkg/stdlib/math/range.go
+++ b/pkg/stdlib/math/range.go
@@ -2,16 +2,15 @@ package math
import (
"context"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Returns an array of numbers in the specified range, optionally with increments other than 1.
- * @param start (Int|Float) - The value to start the range at (inclusive).
- * @param end (Int|Float) - The value to end the range with (inclusive).
- * @param step (Int|Float, optional) - How much to increment in every step, the default is 1.0.
- */
+// Range returns an array of numbers in the specified range, optionally with increments other than 1.
+// @param start (Int|Float) - The value to start the range at (inclusive).
+// @param end (Int|Float) - The value to end the range with (inclusive).
+// @param step (Int|Float, optional) - How much to increment in every step, the default is 1.0.
func Range(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 2, 3)
diff --git a/pkg/stdlib/math/round.go b/pkg/stdlib/math/round.go
index 8f2a3b63..b7bfbebb 100644
--- a/pkg/stdlib/math/round.go
+++ b/pkg/stdlib/math/round.go
@@ -2,16 +2,15 @@ package math
import (
"context"
+ "math"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
- "math"
)
-/*
- * Returns the nearest integer, rounding half away from zero.
- * @param number (Int|Float) - Input number.
- * @returns (Int) - The nearest integer, rounding half away from zero.
- */
+// Round returns the nearest integer, rounding half away from zero.
+// @param number (Int|Float) - Input number.
+// @returns (Int) - The nearest integer, rounding half away from zero.
func Round(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 1)
diff --git a/pkg/stdlib/math/sin.go b/pkg/stdlib/math/sin.go
index 7906da3f..577803fe 100644
--- a/pkg/stdlib/math/sin.go
+++ b/pkg/stdlib/math/sin.go
@@ -2,16 +2,15 @@ package math
import (
"context"
+ "math"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
- "math"
)
-/*
- * Returns the sine of the radian argument.
- * @param number (Int|Float) - Input number.
- * @returns (Float) - The sin, in radians, of a given number.
- */
+// Sin returns the sine of the radian argument.
+// @param number (Int|Float) - Input number.
+// @returns (Float) - The sin, in radians, of a given number.
func Sin(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 1)
diff --git a/pkg/stdlib/math/sqrt.go b/pkg/stdlib/math/sqrt.go
index f55bdb1f..f7bf3559 100644
--- a/pkg/stdlib/math/sqrt.go
+++ b/pkg/stdlib/math/sqrt.go
@@ -2,16 +2,15 @@ package math
import (
"context"
+ "math"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
- "math"
)
-/*
- * Returns the square root of a given number.
- * @param value (Int|Float) - A number.
- * @returns (Float) - The square root.
- */
+// Sqrt returns the square root of a given number.
+// @param value (Int|Float) - A number.
+// @returns (Float) - The square root.
func Sqrt(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 1)
diff --git a/pkg/stdlib/math/stddev_population.go b/pkg/stdlib/math/stddev_population.go
index f67aa41e..51904d5c 100644
--- a/pkg/stdlib/math/stddev_population.go
+++ b/pkg/stdlib/math/stddev_population.go
@@ -2,16 +2,15 @@ package math
import (
"context"
+ "math"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
- "math"
)
-/*
- * Returns the population standard deviation of the values in a given array.
- * @params (Array) - Array of numbers.
- * @returns (Float) - The population standard deviation.
- */
+// StandardDeviationPopulation returns the population standard deviation of the values in a given array.
+// @params (Array) - Array of numbers.
+// @returns (Float) - The population standard deviation.
func StandardDeviationPopulation(_ context.Context, args ...core.Value) (core.Value, error) {
var err error
err = core.ValidateArgs(args, 1, 1)
diff --git a/pkg/stdlib/math/stddev_sample.go b/pkg/stdlib/math/stddev_sample.go
index afdbe7f5..4436f241 100644
--- a/pkg/stdlib/math/stddev_sample.go
+++ b/pkg/stdlib/math/stddev_sample.go
@@ -2,16 +2,15 @@ package math
import (
"context"
+ "math"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
- "math"
)
-/*
- * Returns the sample standard deviation of the values in a given array.
- * @params (Array) - Array of numbers.
- * @returns (Float) - The sample standard deviation.
- */
+// StandardDeviationSample returns the sample standard deviation of the values in a given array.
+// @params (Array) - Array of numbers.
+// @returns (Float) - The sample standard deviation.
func StandardDeviationSample(_ context.Context, args ...core.Value) (core.Value, error) {
var err error
err = core.ValidateArgs(args, 1, 1)
diff --git a/pkg/stdlib/math/sum.go b/pkg/stdlib/math/sum.go
index 20ce0a19..2df47a67 100644
--- a/pkg/stdlib/math/sum.go
+++ b/pkg/stdlib/math/sum.go
@@ -2,15 +2,14 @@ package math
import (
"context"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Returns the sum of the values in a given array.
- * @param array (Array) - Array of numbers.
- * @returns (Float) - The sum of the values.
- */
+// Sum returns the sum of the values in a given array.
+// @param array (Array) - Array of numbers.
+// @returns (Float) - The sum of the values.
func Sum(_ context.Context, args ...core.Value) (core.Value, error) {
var err error
err = core.ValidateArgs(args, 1, 1)
diff --git a/pkg/stdlib/math/tan.go b/pkg/stdlib/math/tan.go
index 7568fd96..e5e7258b 100644
--- a/pkg/stdlib/math/tan.go
+++ b/pkg/stdlib/math/tan.go
@@ -2,16 +2,15 @@ package math
import (
"context"
+ "math"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
- "math"
)
-/*
- * Returns the tangent of a given number.
- * @param value (Int|Float) - A number.
- * @returns (Float) - The tangent.
- */
+// Tan returns the tangent of a given number.
+// @param value (Int|Float) - A number.
+// @returns (Float) - The tangent.
func Tan(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 1)
diff --git a/pkg/stdlib/math/variance_population.go b/pkg/stdlib/math/variance_population.go
index 61ec7a85..5c60065d 100644
--- a/pkg/stdlib/math/variance_population.go
+++ b/pkg/stdlib/math/variance_population.go
@@ -2,16 +2,15 @@ package math
import (
"context"
+ "math"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
- "math"
)
-/*
- * Returns the population variance of the values in a given array.
- * @params (Array) - Array of numbers.
- * @returns (Float) - The population variance.
- */
+// PopulationVariance returns the population variance of the values in a given array.
+// @params (Array) - Array of numbers.
+// @returns (Float) - The population variance.
func PopulationVariance(_ context.Context, args ...core.Value) (core.Value, error) {
var err error
err = core.ValidateArgs(args, 1, 1)
diff --git a/pkg/stdlib/math/variance_sample.go b/pkg/stdlib/math/variance_sample.go
index e4265226..e764df42 100644
--- a/pkg/stdlib/math/variance_sample.go
+++ b/pkg/stdlib/math/variance_sample.go
@@ -2,16 +2,15 @@ package math
import (
"context"
+ "math"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
- "math"
)
-/*
- * Returns the sample variance of the values in a given array.
- * @params (Array) - Array of numbers.
- * @returns (Float) - The sample variance.
- */
+// SampleVariance returns the sample variance of the values in a given array.
+// @params (Array) - Array of numbers.
+// @returns (Float) - The sample variance.
func SampleVariance(_ context.Context, args ...core.Value) (core.Value, error) {
var err error
err = core.ValidateArgs(args, 1, 1)
diff --git a/pkg/stdlib/objects/has.go b/pkg/stdlib/objects/has.go
index 98c97f26..39c09f34 100644
--- a/pkg/stdlib/objects/has.go
+++ b/pkg/stdlib/objects/has.go
@@ -7,11 +7,9 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Returns the value stored by the given key.
- * @params (String) - The key name string.
- * @returns (Boolean) - True if the key exists else false.
- */
+// Has returns the value stored by the given key.
+// @params (String) - The key name string.
+// @returns (Boolean) - True if the key exists else false.
func Has(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 2, 2)
diff --git a/pkg/stdlib/objects/keep.go b/pkg/stdlib/objects/keep.go
index f5ec181b..45e3734c 100644
--- a/pkg/stdlib/objects/keep.go
+++ b/pkg/stdlib/objects/keep.go
@@ -7,12 +7,10 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Returns a new object with only given keys.
- * @params src (Object) - source object.
- * @params keys (Array Of String OR Strings) - keys that need to be keeped.
- * @returns (Object) - New Object with only given keys.
- */
+// Keep returns a new object with only given keys.
+// @params src (Object) - source object.
+// @params keys (Array Of String OR Strings) - keys that need to be keeped.
+// @returns (Object) - New Object with only given keys.
func Keep(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 2, core.MaxArgs)
diff --git a/pkg/stdlib/objects/keys.go b/pkg/stdlib/objects/keys.go
index 5e1b8656..b304e6b9 100644
--- a/pkg/stdlib/objects/keys.go
+++ b/pkg/stdlib/objects/keys.go
@@ -8,12 +8,10 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Returns string array of object's keys
- * @params obj (Object) - The object whose keys you want to extract
- * @params sort (Boolean, optional) - If sort is true, then the returned keys will be sorted.
- * @returns (Array of String) - Array that contains object keys.
- */
+// Keys returns string array of object's keys
+// @params obj (Object) - The object whose keys you want to extract
+// @params sort (Boolean, optional) - If sort is true, then the returned keys will be sorted.
+// @returns (Array of String) - Array that contains object keys.
func Keys(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 2)
if err != nil {
diff --git a/pkg/stdlib/objects/merge.go b/pkg/stdlib/objects/merge.go
index 5884cbf3..2dc8dca0 100644
--- a/pkg/stdlib/objects/merge.go
+++ b/pkg/stdlib/objects/merge.go
@@ -7,11 +7,9 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Merge the given objects into a single object.
- * @params objs (Array Of Object OR Objects) - objects to merge.
- * @returns (Object) - Object created by merging.
- */
+// Merge merge the given objects into a single object.
+// @params objs (Array Of Object OR Objects) - objects to merge.
+// @returns (Object) - Object created by merging.
func Merge(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, core.MaxArgs)
diff --git a/pkg/stdlib/objects/zip.go b/pkg/stdlib/objects/zip.go
index 8918e3d9..c39de632 100644
--- a/pkg/stdlib/objects/zip.go
+++ b/pkg/stdlib/objects/zip.go
@@ -9,13 +9,11 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Returns an object assembled from the separate parameters keys and values.
- * Keys and values must be arrays and have the same length.
- * @params keys (Array of Strings) - an array of strings, to be used as key names in the result.
- * @params values (Array of Objects) - an array of core.Value, to be used as key values.
- * @returns (Object) - an object with the keys and values assembled.
- */
+// Zip returns an object assembled from the separate parameters keys and values.
+// Keys and values must be arrays and have the same length.
+// @params keys (Array of Strings) - an array of strings, to be used as key names in the result.
+// @params values (Array of Objects) - an array of core.Value, to be used as key values.
+// @returns (Object) - an object with the keys and values assembled.
func Zip(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 2, 2)
if err != nil {
diff --git a/pkg/stdlib/strings/case.go b/pkg/stdlib/strings/case.go
index a5dc13cc..63a43d96 100644
--- a/pkg/stdlib/strings/case.go
+++ b/pkg/stdlib/strings/case.go
@@ -2,16 +2,15 @@ package strings
import (
"context"
+ "strings"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
- "strings"
)
-/*
- * Converts strings to their lower-case counterparts. All other characters are returned unchanged.
- * @param src (String) - The source string.
- * @returns (String) - THis string in lower case.
- */
+// Lower converts strings to their lower-case counterparts. All other characters are returned unchanged.
+// @param src (String) - The source string.
+// @returns (String) - THis string in lower case.
func Lower(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 1)
@@ -24,11 +23,9 @@ func Lower(_ context.Context, args ...core.Value) (core.Value, error) {
return values.NewString(text), nil
}
-/*
- * Converts strings to their upper-case counterparts. All other characters are returned unchanged.
- * @param src (String) - The source string.
- * @returns (String) - THis string in upper case.
- */
+// Upper converts strings to their upper-case counterparts. All other characters are returned unchanged.
+// @param src (String) - The source string.
+// @returns (String) - THis string in upper case.
func Upper(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 1)
diff --git a/pkg/stdlib/strings/concat.go b/pkg/stdlib/strings/concat.go
index 71782734..170708e2 100644
--- a/pkg/stdlib/strings/concat.go
+++ b/pkg/stdlib/strings/concat.go
@@ -2,15 +2,14 @@ package strings
import (
"context"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Concatenates one or more instances of Read, or an Array.
- * @params src (String...|Array) - The source string / array.
- * @returns String
- */
+// Concat concatenates one or more instances of Read, or an Array.
+// @params src (String...|Array) - The source string / array.
+// @returns String
func Concat(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, core.MaxArgs)
@@ -41,12 +40,10 @@ func Concat(_ context.Context, args ...core.Value) (core.Value, error) {
return res, nil
}
-/*
- * Concatenates one or more instances of Read, or an Array with a given separator.
- * @params separator (string) - The separator string.
- * @params src (string...|array) - The source string / array.
- * @returns string
- */
+// ConcatWithSeparator concatenates one or more instances of Read, or an Array with a given separator.
+// @params separator (string) - The separator string.
+// @params src (string...|array) - The source string / array.
+// @returns string
func ConcatWithSeparator(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 2, core.MaxArgs)
diff --git a/pkg/stdlib/strings/contains.go b/pkg/stdlib/strings/contains.go
index 5e4b96ea..2e100fb0 100644
--- a/pkg/stdlib/strings/contains.go
+++ b/pkg/stdlib/strings/contains.go
@@ -2,18 +2,17 @@ package strings
import (
"context"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Returns a value indicating whether a specified substring occurs within a string.
- * @param src (String) - The source string.
- * @param search (String) - The string to seek.
- * @param returnIndex (Boolean) - Values which indicates whether to return the character position of the match is returned instead of a boolean.
- * The default is false.
- * @returns (Boolean|Int)
- */
+// Contains returns a value indicating whether a specified substring occurs within a string.
+// @param src (String) - The source string.
+// @param search (String) - The string to seek.
+// @param returnIndex (Boolean) - Values which indicates whether to return the character position of the match is returned instead of a boolean.
+// The default is false.
+// @returns (Boolean|Int)
func Contains(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 2, 3)
diff --git a/pkg/stdlib/strings/encode.go b/pkg/stdlib/strings/encode.go
index b54e93c6..ddac8d3f 100644
--- a/pkg/stdlib/strings/encode.go
+++ b/pkg/stdlib/strings/encode.go
@@ -6,16 +6,15 @@ import (
"crypto/sha1"
"crypto/sha512"
"encoding/base64"
+ "net/url"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
- "net/url"
)
-/*
- * Returns the encoded String of uri.
- * @param (String) - Uri to encode.
- * @returns String - Encoded string.
- */
+// EncodeURIComponent returns the encoded String of uri.
+// @param (String) - Uri to encode.
+// @returns String - Encoded string.
func EncodeURIComponent(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 1)
@@ -28,11 +27,9 @@ func EncodeURIComponent(_ context.Context, args ...core.Value) (core.Value, erro
return values.NewString(str), nil
}
-/*
- * Calculates the MD5 checksum for text and return it in a hexadecimal string representation.
- * @param text (String) - The string to do calculations against to.
- * @return (String) - MD5 checksum as hex string.
- */
+// Md5 calculates the MD5 checksum for text and return it in a hexadecimal string representation.
+// @param text (String) - The string to do calculations against to.
+// @return (String) - MD5 checksum as hex string.
func Md5(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 1)
@@ -46,11 +43,9 @@ func Md5(_ context.Context, args ...core.Value) (core.Value, error) {
return values.NewString(string(res[:])), nil
}
-/*
- * Calculates the SHA1 checksum for text and returns it in a hexadecimal string representation.
- * @param text (String) - The string to do calculations against to.
- * @return (String) - Sha1 checksum as hex string.
- */
+// Sha1 calculates the SHA1 checksum for text and returns it in a hexadecimal string representation.
+// @param text (String) - The string to do calculations against to.
+// @return (String) - Sha1 checksum as hex string.
func Sha1(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 1)
@@ -64,11 +59,9 @@ func Sha1(_ context.Context, args ...core.Value) (core.Value, error) {
return values.NewString(string(res[:])), nil
}
-/*
- * Calculates the SHA512 checksum for text and returns it in a hexadecimal string representation.
- * @param text (String) - The string to do calculations against to.
- * @return (String) - SHA512 checksum as hex string.
- */
+// Sha512 calculates the SHA512 checksum for text and returns it in a hexadecimal string representation.
+// @param text (String) - The string to do calculations against to.
+// @return (String) - SHA512 checksum as hex string.
func Sha512(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 1)
@@ -82,11 +75,9 @@ func Sha512(_ context.Context, args ...core.Value) (core.Value, error) {
return values.NewString(string(res[:])), nil
}
-/*
- * Returns the base64 representation of value.
- * @param value (string) - The string to encode.
- * @returns toBase64String (String) - A base64 representation of the string.
- */
+// ToBase64 returns the base64 representation of value.
+// @param value (string) - The string to encode.
+// @returns toBase64String (String) - A base64 representation of the string.
func ToBase64(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 1)
diff --git a/pkg/stdlib/strings/find.go b/pkg/stdlib/strings/find.go
index 8b56fb92..aa495dd3 100644
--- a/pkg/stdlib/strings/find.go
+++ b/pkg/stdlib/strings/find.go
@@ -2,20 +2,19 @@ package strings
import (
"context"
+ "strings"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
- "strings"
)
-/*
- * Returns the position of the first occurrence of the string search inside the string text. Positions start at 0.
- * @param src (String) - The source string.
- * @param search (String) - The string to seek.
- * @param start (Int, optional) - Limit the search to a subset of the text, beginning at start.
- * @param end (Int, optional) - Limit the search to a subset of the text, ending at end
- * @returns (Int) - The character position of the match.
- * If search is not contained in text, -1 is returned. If search is empty, start is returned.
- */
+// FindFirst returns the position of the first occurrence of the string search inside the string text. Positions start at 0.
+// @param src (String) - The source string.
+// @param search (String) - The string to seek.
+// @param start (Int, optional) - Limit the search to a subset of the text, beginning at start.
+// @param end (Int, optional) - Limit the search to a subset of the text, ending at end
+// @returns (Int) - The character position of the match.
+// If search is not contained in text, -1 is returned. If search is empty, start is returned.
func FindFirst(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 2, 4)
@@ -56,15 +55,13 @@ func FindFirst(_ context.Context, args ...core.Value) (core.Value, error) {
return values.NewInt(found), nil
}
-/*
- * Returns the position of the last occurrence of the string search inside the string text. Positions start at 0.
- * @param src (String) - The source string.
- * @param search (String) - The string to seek.
- * @param start (Int, optional) - Limit the search to a subset of the text, beginning at start.
- * @param end (Int, optional) - Limit the search to a subset of the text, ending at end
- * @returns (Int) - The character position of the match.
- * If search is not contained in text, -1 is returned. If search is empty, start is returned.
- */
+// FindLast returns the position of the last occurrence of the string search inside the string text. Positions start at 0.
+// @param src (String) - The source string.
+// @param search (String) - The string to seek.
+// @param start (Int, optional) - Limit the search to a subset of the text, beginning at start.
+// @param end (Int, optional) - Limit the search to a subset of the text, ending at end
+// @returns (Int) - The character position of the match.
+// If search is not contained in text, -1 is returned. If search is empty, start is returned.
func FindLast(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 2, 4)
diff --git a/pkg/stdlib/strings/json.go b/pkg/stdlib/strings/json.go
index 512f82a4..da60a04a 100644
--- a/pkg/stdlib/strings/json.go
+++ b/pkg/stdlib/strings/json.go
@@ -3,15 +3,14 @@ package strings
import (
"context"
"encoding/json"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Returns a FQL value described by the JSON-encoded input string.
- * @params text (String) - The string to parse as JSON.
- * @returns FQL value (Read)
- */
+// JSONParse returns a FQL value described by the JSON-encoded input string.
+// @params text (String) - The string to parse as JSON.
+// @returns FQL value (Read)
func JSONParse(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 1)
@@ -30,11 +29,9 @@ func JSONParse(_ context.Context, args ...core.Value) (core.Value, error) {
return values.Parse(val), nil
}
-/*
- * Returns a JSON string representation of the input value.
- * @params value (Read) - The input value to serialize.
- * @returns json (String)
- */
+// JSONStringify returns a JSON string representation of the input value.
+// @params value (Read) - The input value to serialize.
+// @returns json (String)
func JSONStringify(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 1)
diff --git a/pkg/stdlib/strings/like.go b/pkg/stdlib/strings/like.go
index b0463196..53c16808 100644
--- a/pkg/stdlib/strings/like.go
+++ b/pkg/stdlib/strings/like.go
@@ -8,13 +8,11 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Checks whether the pattern search is contained in the string text, using wildcard matching.
- * @param text (String) - The string to search in.
- * @param search (String) - A search pattern that can contain the wildcard characters.
- * @param caseInsensitive (Boolean) - If set to true, the matching will be case-insensitive. The default is false.
- * @return (Boolean) - Returns true if the pattern is contained in text, and false otherwise.
- */
+// Like checks whether the pattern search is contained in the string text, using wildcard matching.
+// @param text (String) - The string to search in.
+// @param search (String) - A search pattern that can contain the wildcard characters.
+// @param caseInsensitive (Boolean) - If set to true, the matching will be case-insensitive. The default is false.
+// @return (Boolean) - Returns true if the pattern is contained in text, and false otherwise.
func Like(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 2, 3)
diff --git a/pkg/stdlib/strings/random.go b/pkg/stdlib/strings/random.go
index 783e1621..9c6bf9f3 100644
--- a/pkg/stdlib/strings/random.go
+++ b/pkg/stdlib/strings/random.go
@@ -2,10 +2,11 @@ package strings
import (
"context"
- "github.com/MontFerret/ferret/pkg/runtime/core"
- "github.com/MontFerret/ferret/pkg/runtime/values"
"math/rand"
"time"
+
+ "github.com/MontFerret/ferret/pkg/runtime/core"
+ "github.com/MontFerret/ferret/pkg/runtime/values"
)
const (
@@ -15,11 +16,9 @@ const (
letterIdxMax = 63 / letterIdxBits // # of letter indices fitting in 63 bits
)
-/*
- * Generates a pseudo-random token string with the specified length. The algorithm for token generation should be treated as opaque.
- * @param length (Int) - The desired string length for the token. It must be greater than 0 and at most 65536.
- * @return (String) - A generated token consisting of lowercase letters, uppercase letters and numbers.
- */
+// RandomToken generates a pseudo-random token string with the specified length. The algorithm for token generation should be treated as opaque.
+// @param length (Int) - The desired string length for the token. It must be greater than 0 and at most 65536.
+// @return (String) - A generated token consisting of lowercase letters, uppercase letters and numbers.
func RandomToken(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 1)
diff --git a/pkg/stdlib/strings/regex.go b/pkg/stdlib/strings/regex.go
index b785e314..e161b7b2 100644
--- a/pkg/stdlib/strings/regex.go
+++ b/pkg/stdlib/strings/regex.go
@@ -2,18 +2,17 @@ package strings
import (
"context"
+ "regexp"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
- "regexp"
)
-/*
- * Returns the matches in the given string text, using the regex.
- * @param text (String) - The string to search in.
- * @param regex (String) - A regular expression to use for matching the text.
- * @param caseInsensitive (Boolean) - If set to true, the matching will be case-insensitive. The default is false.
- * @return (Array) - An array of strings containing the matches.
- */
+// RegexMatch returns the matches in the given string text, using the regex.
+// @param text (String) - The string to search in.
+// @param regex (String) - A regular expression to use for matching the text.
+// @param caseInsensitive (Boolean) - If set to true, the matching will be case-insensitive. The default is false.
+// @return (Array) - An array of strings containing the matches.
func RegexMatch(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 2, 3)
@@ -50,14 +49,12 @@ func RegexMatch(_ context.Context, args ...core.Value) (core.Value, error) {
return res, nil
}
-/*
- * Splits the given string text into a list of strings, using the separator.
- * @param text (String) - The string to split.
- * @param regex (String) - A regular expression to use for splitting the text.
- * @param caseInsensitive (Boolean) - If set to true, the matching will be case-insensitive. The default is false.
- * @param limit (Int) - Limit the number of split values in the result. If no limit is given, the number of splits returned is not bounded.
- * @return (Array) - An array of strings splited by teh expression.
- */
+// RegexSplit splits the given string text into a list of strings, using the separator.
+// @param text (String) - The string to split.
+// @param regex (String) - A regular expression to use for splitting the text.
+// @param caseInsensitive (Boolean) - If set to true, the matching will be case-insensitive. The default is false.
+// @param limit (Int) - Limit the number of split values in the result. If no limit is given, the number of splits returned is not bounded.
+// @return (Array) - An array of strings splited by teh expression.
func RegexSplit(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 2, 4)
@@ -95,13 +92,11 @@ func RegexSplit(_ context.Context, args ...core.Value) (core.Value, error) {
return res, nil
}
-/*
- * Test wether the regexp has at least one match in the given text.
- * @param text (String) - The string to split.
- * @param regex (String) - A regular expression to use for splitting the text.
- * @param caseInsensitive (Boolean) - If set to true, the matching will be case-insensitive. The default is false.
- * @return (Boolean) - Returns true if the pattern is contained in text, and false otherwise.
- */
+// RegexTest test wether the regexp has at least one match in the given text.
+// @param text (String) - The string to split.
+// @param regex (String) - A regular expression to use for splitting the text.
+// @param caseInsensitive (Boolean) - If set to true, the matching will be case-insensitive. The default is false.
+// @return (Boolean) - Returns true if the pattern is contained in text, and false otherwise.
func RegexTest(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 2, 3)
@@ -129,14 +124,12 @@ func RegexTest(_ context.Context, args ...core.Value) (core.Value, error) {
return values.NewBoolean(matches), nil
}
-/*
- * Replace every substring matched with the regexp with a given string.
- * @param text (String) - The string to split.
- * @param regex (String) - A regular expression search pattern.
- * @param replacement (String) - The string to replace the search pattern with
- * @param caseInsensitive (Boolean) - If set to true, the matching will be case-insensitive. The default is false.
- * @return (String) - Returns the string text with the search regex pattern replaced with the replacement string wherever the pattern exists in text
- */
+// RegexReplace replace every substring matched with the regexp with a given string.
+// @param text (String) - The string to split.
+// @param regex (String) - A regular expression search pattern.
+// @param replacement (String) - The string to replace the search pattern with
+// @param caseInsensitive (Boolean) - If set to true, the matching will be case-insensitive. The default is false.
+// @return (String) - Returns the string text with the search regex pattern replaced with the replacement string wherever the pattern exists in text
func RegexReplace(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 3, 4)
diff --git a/pkg/stdlib/strings/reverse.go b/pkg/stdlib/strings/reverse.go
index 646a66c4..78509bc7 100644
--- a/pkg/stdlib/strings/reverse.go
+++ b/pkg/stdlib/strings/reverse.go
@@ -2,15 +2,14 @@ package strings
import (
"context"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Returns the reverse of the string value.
- * @param text (String) - The string to revers
- * @returns (String) - Returns a reversed version of the string.
- */
+// Reverse returns the reverse of the string value.
+// @param text (String) - The string to revers
+// @returns (String) - Returns a reversed version of the string.
func Reverse(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 1)
diff --git a/pkg/stdlib/strings/split.go b/pkg/stdlib/strings/split.go
index 4e85f862..bfedd270 100644
--- a/pkg/stdlib/strings/split.go
+++ b/pkg/stdlib/strings/split.go
@@ -2,18 +2,17 @@ package strings
import (
"context"
+ "strings"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
- "strings"
)
-/*
- * Splits the given string value into a list of strings, using the separator.
- * @params text (String) - The string to split.
- * @params separator (String) - The sperator.
- * @params limit (Int) - Limit the number of split values in the result. If no limit is given, the number of splits returned is not bounded.
- * @returns strings (Array) - Array of strings.
- */
+// Split splits the given string value into a list of strings, using the separator.
+// @params text (String) - The string to split.
+// @params separator (String) - The sperator.
+// @params limit (Int) - Limit the number of split values in the result. If no limit is given, the number of splits returned is not bounded.
+// @returns strings (Array) - Array of strings.
func Split(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 2, 3)
diff --git a/pkg/stdlib/strings/substitute.go b/pkg/stdlib/strings/substitute.go
index d5a3f1c3..aa2b0a93 100644
--- a/pkg/stdlib/strings/substitute.go
+++ b/pkg/stdlib/strings/substitute.go
@@ -2,19 +2,18 @@ package strings
import (
"context"
+ "strings"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
- "strings"
)
-/*
- * Replaces search values in the string value.
- * @params text (String) - The string to modify
- * @params search (String) - The string representing a search pattern
- * @params replace (String) - The string representing a replace value
- * @param limit (Int) - The cap the number of replacements to this value.
- * @return (String) - Returns a string with replace substring.
- */
+// Substitute replaces search values in the string value.
+// @params text (String) - The string to modify
+// @params search (String) - The string representing a search pattern
+// @params replace (String) - The string representing a replace value
+// @param limit (Int) - The cap the number of replacements to this value.
+// @return (String) - Returns a string with replace substring.
func Substitute(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 2, 4)
diff --git a/pkg/stdlib/strings/substr.go b/pkg/stdlib/strings/substr.go
index 6e4af170..fc7d252b 100644
--- a/pkg/stdlib/strings/substr.go
+++ b/pkg/stdlib/strings/substr.go
@@ -2,17 +2,16 @@ package strings
import (
"context"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Returns a substring of value.
- * @params value (String) - The source string.
- * @param offset (Int) - Start at offset, offsets start at position 0.
- * @param length (Int, optional) - At most length characters, omit to get the substring from offset to the end of the string. Optional.
- * @returns substring (String) - A substring of value.
- */
+// Substring returns a substring of value.
+// @params value (String) - The source string.
+// @param offset (Int) - Start at offset, offsets start at position 0.
+// @param length (Int, optional) - At most length characters, omit to get the substring from offset to the end of the string. Optional.
+// @returns substring (String) - A substring of value.
func Substring(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 2, 3)
@@ -55,12 +54,10 @@ func Substring(_ context.Context, args ...core.Value) (core.Value, error) {
return values.NewStringFromRunes(substr), nil
}
-/*
- * Returns the leftmost characters of the string value by index.
- * @param src (String) - The source string.
- * @params length (Int) - The amount of characters to return.
- * @returns substr (String)
- */
+// Left returns the leftmost characters of the string value by index.
+// @param src (String) - The source string.
+// @params length (Int) - The amount of characters to return.
+// @returns substr (String)
func Left(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 2, 2)
@@ -84,12 +81,10 @@ func Left(_ context.Context, args ...core.Value) (core.Value, error) {
return values.NewStringFromRunes(runes[0:pos]), nil
}
-/*
- * Returns the rightmost characters of the string value.
- * @param src (String) - The source string.
- * @params length (Int) - The amount of characters to return.
- * @returns substr (String)
- */
+// Right returns the rightmost characters of the string value.
+// @param src (String) - The source string.
+// @params length (Int) - The amount of characters to return.
+// @returns substr (String)
func Right(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 2, 2)
diff --git a/pkg/stdlib/strings/trim.go b/pkg/stdlib/strings/trim.go
index 81dc2821..c9a15be7 100644
--- a/pkg/stdlib/strings/trim.go
+++ b/pkg/stdlib/strings/trim.go
@@ -2,17 +2,16 @@ package strings
import (
"context"
+ "strings"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
- "strings"
)
-/*
- * Returns the string value with whitespace stripped from the start and/or end.
- * @param value (String) - The string.
- * @param chars (String) - Overrides the characters that should be removed from the string. It defaults to \r\n \t.
- * @returns (String) - The string without chars on both sides.
- */
+// Trim returns the string value with whitespace stripped from the start and/or end.
+// @param value (String) - The string.
+// @param chars (String) - Overrides the characters that should be removed from the string. It defaults to \r\n \t.
+// @returns (String) - The string without chars on both sides.
func Trim(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 2)
@@ -29,12 +28,10 @@ func Trim(_ context.Context, args ...core.Value) (core.Value, error) {
return values.NewString(strings.TrimSpace(text)), nil
}
-/*
- * Returns the string value with whitespace stripped from the start only.
- * @param value (String) - The string.
- * @param chars (String) - Overrides the characters that should be removed from the string. It defaults to \r\n \t.
- * @returns (String) - The string without chars at the left-hand side.
- */
+// LTrim returns the string value with whitespace stripped from the start only.
+// @param value (String) - The string.
+// @param chars (String) - Overrides the characters that should be removed from the string. It defaults to \r\n \t.
+// @returns (String) - The string without chars at the left-hand side.
func LTrim(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 2)
@@ -52,12 +49,10 @@ func LTrim(_ context.Context, args ...core.Value) (core.Value, error) {
return values.NewString(strings.TrimLeft(text, chars)), nil
}
-/*
- * Returns the string value with whitespace stripped from the end only.
- * @param value (String) - The string.
- * @param chars (String) - Overrides the characters that should be removed from the string. It defaults to \r\n \t.
- * @returns (String) - The string without chars at the right-hand side.
- */
+// RTrim returns the string value with whitespace stripped from the end only.
+// @param value (String) - The string.
+// @param chars (String) - Overrides the characters that should be removed from the string. It defaults to \r\n \t.
+// @returns (String) - The string without chars at the right-hand side.
func RTrim(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 2)
diff --git a/pkg/stdlib/types/is_array.go b/pkg/stdlib/types/is_array.go
index 7248efda..66ea3a28 100644
--- a/pkg/stdlib/types/is_array.go
+++ b/pkg/stdlib/types/is_array.go
@@ -2,15 +2,14 @@ package types
import (
"context"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Checks whether value is an array value.
- * @param value (Value) - Input value of arbitrary type.
- * @returns (Boolean) - Returns true if value is array, otherwise false.
- */
+// IsArray checks whether value is an array value.
+// @param value (Value) - Input value of arbitrary type.
+// @returns (Boolean) - Returns true if value is array, otherwise false.
func IsArray(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 1)
diff --git a/pkg/stdlib/types/is_binary.go b/pkg/stdlib/types/is_binary.go
index 9a2c044d..fcc0b11d 100644
--- a/pkg/stdlib/types/is_binary.go
+++ b/pkg/stdlib/types/is_binary.go
@@ -2,15 +2,14 @@ package types
import (
"context"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Checks whether value is a binary value.
- * @param value (Value) - Input value of arbitrary type.
- * @returns (Boolean) - Returns true if value is binary, otherwise false.
- */
+// IsBinary checks whether value is a binary value.
+// @param value (Value) - Input value of arbitrary type.
+// @returns (Boolean) - Returns true if value is binary, otherwise false.
func IsBinary(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 1)
diff --git a/pkg/stdlib/types/is_boolean.go b/pkg/stdlib/types/is_boolean.go
index 75c6c8b5..81f2e87e 100644
--- a/pkg/stdlib/types/is_boolean.go
+++ b/pkg/stdlib/types/is_boolean.go
@@ -2,15 +2,14 @@ package types
import (
"context"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Checks whether value is a boolean value.
- * @param value (Value) - Input value of arbitrary type.
- * @returns (Boolean) - Returns true if value is boolean, otherwise false.
- */
+// IsBool checks whether value is a boolean value.
+// @param value (Value) - Input value of arbitrary type.
+// @returns (Boolean) - Returns true if value is boolean, otherwise false.
func IsBool(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 1)
diff --git a/pkg/stdlib/types/is_date_time.go b/pkg/stdlib/types/is_date_time.go
index efc87e6e..23e45330 100644
--- a/pkg/stdlib/types/is_date_time.go
+++ b/pkg/stdlib/types/is_date_time.go
@@ -2,15 +2,14 @@ package types
import (
"context"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Checks whether value is a date time value.
- * @param value (Value) - Input value of arbitrary type.
- * @returns (Boolean) - Returns true if value is date time, otherwise false.
- */
+// IsDateTime checks whether value is a date time value.
+// @param value (Value) - Input value of arbitrary type.
+// @returns (Boolean) - Returns true if value is date time, otherwise false.
func IsDateTime(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 1)
diff --git a/pkg/stdlib/types/is_float.go b/pkg/stdlib/types/is_float.go
index 8d834907..08c5355c 100644
--- a/pkg/stdlib/types/is_float.go
+++ b/pkg/stdlib/types/is_float.go
@@ -2,15 +2,14 @@ package types
import (
"context"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Checks whether value is a float value.
- * @param value (Value) - Input value of arbitrary type.
- * @returns (Boolean) - Returns true if value is float, otherwise false.
- */
+// IsFloat checks whether value is a float value.
+// @param value (Value) - Input value of arbitrary type.
+// @returns (Boolean) - Returns true if value is float, otherwise false.
func IsFloat(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 1)
diff --git a/pkg/stdlib/types/is_html_document.go b/pkg/stdlib/types/is_html_document.go
index b8a91ff1..6b6f764a 100644
--- a/pkg/stdlib/types/is_html_document.go
+++ b/pkg/stdlib/types/is_html_document.go
@@ -2,15 +2,14 @@ package types
import (
"context"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Checks whether value is a HTMLDocument value.
- * @param value (Value) - Input value of arbitrary type.
- * @returns (Boolean) - Returns true if value is HTMLDocument, otherwise false.
- */
+// IsHTMLDocument checks whether value is a HTMLDocument value.
+// @param value (Value) - Input value of arbitrary type.
+// @returns (Boolean) - Returns true if value is HTMLDocument, otherwise false.
func IsHTMLDocument(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 1)
diff --git a/pkg/stdlib/types/is_html_element.go b/pkg/stdlib/types/is_html_element.go
index 7a182a15..d2e6e82c 100644
--- a/pkg/stdlib/types/is_html_element.go
+++ b/pkg/stdlib/types/is_html_element.go
@@ -2,15 +2,14 @@ package types
import (
"context"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Checks whether value is a HTMLElement value.
- * @param value (Value) - Input value of arbitrary type.
- * @returns (Boolean) - Returns true if value is HTMLElement, otherwise false.
- */
+// IsHTMLElement checks whether value is a HTMLElement value.
+// @param value (Value) - Input value of arbitrary type.
+// @returns (Boolean) - Returns true if value is HTMLElement, otherwise false.
func IsHTMLElement(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 1)
diff --git a/pkg/stdlib/types/is_int.go b/pkg/stdlib/types/is_int.go
index f55da825..7b9420cb 100644
--- a/pkg/stdlib/types/is_int.go
+++ b/pkg/stdlib/types/is_int.go
@@ -2,15 +2,14 @@ package types
import (
"context"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Checks whether value is a int value.
- * @param value (Value) - Input value of arbitrary type.
- * @returns (Boolean) - Returns true if value is int, otherwise false.
- */
+// IsInt checks whether value is a int value.
+// @param value (Value) - Input value of arbitrary type.
+// @returns (Boolean) - Returns true if value is int, otherwise false.
func IsInt(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 1)
diff --git a/pkg/stdlib/types/is_nan.go b/pkg/stdlib/types/is_nan.go
index 5097f7e7..e8582b2a 100644
--- a/pkg/stdlib/types/is_nan.go
+++ b/pkg/stdlib/types/is_nan.go
@@ -2,15 +2,14 @@ package types
import (
"context"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Checks whether value is NaN.
- * @param value (Value) - Input value of arbitrary type.
- * @returns (Boolean) - Returns true if value is NaN, otherwise false.
- */
+// IsNaN checks whether value is NaN.
+// @param value (Value) - Input value of arbitrary type.
+// @returns (Boolean) - Returns true if value is NaN, otherwise false.
func IsNaN(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 1)
diff --git a/pkg/stdlib/types/is_none.go b/pkg/stdlib/types/is_none.go
index 7a80fe61..fa04bf97 100644
--- a/pkg/stdlib/types/is_none.go
+++ b/pkg/stdlib/types/is_none.go
@@ -2,15 +2,14 @@ package types
import (
"context"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Checks whether value is a none value.
- * @param value (Value) - Input value of arbitrary type.
- * @returns (Boolean) - Returns true if value is none, otherwise false.
- */
+// IsNone checks whether value is a none value.
+// @param value (Value) - Input value of arbitrary type.
+// @returns (Boolean) - Returns true if value is none, otherwise false.
func IsNone(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 1)
diff --git a/pkg/stdlib/types/is_object.go b/pkg/stdlib/types/is_object.go
index 8d8d84a9..de13cc8e 100644
--- a/pkg/stdlib/types/is_object.go
+++ b/pkg/stdlib/types/is_object.go
@@ -2,15 +2,14 @@ package types
import (
"context"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Checks whether value is an object value.
- * @param value (Value) - Input value of arbitrary type.
- * @returns (Boolean) - Returns true if value is object, otherwise false.
- */
+// IsObject checks whether value is an object value.
+// @param value (Value) - Input value of arbitrary type.
+// @returns (Boolean) - Returns true if value is object, otherwise false.
func IsObject(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 1)
diff --git a/pkg/stdlib/types/is_string.go b/pkg/stdlib/types/is_string.go
index 11b767d4..b5be6091 100644
--- a/pkg/stdlib/types/is_string.go
+++ b/pkg/stdlib/types/is_string.go
@@ -2,15 +2,14 @@ package types
import (
"context"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Checks whether value is a string value.
- * @param value (Value) - Input value of arbitrary type.
- * @returns (Boolean) - Returns true if value is string, otherwise false.
- */
+// IsString checks whether value is a string value.
+// @param value (Value) - Input value of arbitrary type.
+// @returns (Boolean) - Returns true if value is string, otherwise false.
func IsString(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 1)
diff --git a/pkg/stdlib/types/to_array.go b/pkg/stdlib/types/to_array.go
index ca91dc79..81c37ff4 100644
--- a/pkg/stdlib/types/to_array.go
+++ b/pkg/stdlib/types/to_array.go
@@ -2,20 +2,19 @@ package types
import (
"context"
+
"github.com/MontFerret/ferret/pkg/runtime/collections"
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Takes an input value of any type and convert it into an array value.
- * @param (Value) - Input value of arbitrary type.
- * @returns (Array)
- * None is converted to an empty array
- * Boolean values, numbers and strings are converted to an array containing the original value as its single element
- * Arrays keep their original value
- * Objects / HTML nodes are converted to an array containing their attribute values as array elements.
- */
+// ToArray takes an input value of any type and convert it into an array value.
+// @param (Value) - Input value of arbitrary type.
+// @returns (Array)
+// None is converted to an empty array
+// Boolean values, numbers and strings are converted to an array containing the original value as its single element
+// Arrays keep their original value
+// Objects / HTML nodes are converted to an array containing their attribute values as array elements.
func ToArray(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 1)
diff --git a/pkg/stdlib/types/to_boolean.go b/pkg/stdlib/types/to_boolean.go
index 6dbb6289..e706eecc 100644
--- a/pkg/stdlib/types/to_boolean.go
+++ b/pkg/stdlib/types/to_boolean.go
@@ -2,21 +2,20 @@ package types
import (
"context"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Takes an input value of any type and converts it into the appropriate boolean value.
- * @param value (Value) - Input value of arbitrary type.
- * @returns (Boolean) -
- * None is converted to false
- * Numbers are converted to true, except for 0, which is converted to false
- * Strings are converted to true if they are non-empty, and to false otherwise
- * Dates are converted to true if they are not zero, and to false otherwise
- * Arrays are always converted to true (even if empty)
- * Objects / HtmlNodes / Binary are always converted to true
- */
+// ToBool takes an input value of any type and converts it into the appropriate boolean value.
+// @param value (Value) - Input value of arbitrary type.
+// @returns (Boolean) -
+// None is converted to false
+// Numbers are converted to true, except for 0, which is converted to false
+// Strings are converted to true if they are non-empty, and to false otherwise
+// Dates are converted to true if they are not zero, and to false otherwise
+// Arrays are always converted to true (even if empty)
+// Objects / HtmlNodes / Binary are always converted to true
func ToBool(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 1)
diff --git a/pkg/stdlib/types/to_date_time.go b/pkg/stdlib/types/to_date_time.go
index 9554c3b5..fd31489d 100644
--- a/pkg/stdlib/types/to_date_time.go
+++ b/pkg/stdlib/types/to_date_time.go
@@ -2,15 +2,14 @@ package types
import (
"context"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Takes an input value of any type and converts it into the appropriate date time value.
- * @param value (Value) - Input value of arbitrary type.
- * @returns (DateTime) - Parsed date time.
- */
+// ToDateTime takes an input value of any type and converts it into the appropriate date time value.
+// @param value (Value) - Input value of arbitrary type.
+// @returns (DateTime) - Parsed date time.
func ToDateTime(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 1)
diff --git a/pkg/stdlib/types/to_float.go b/pkg/stdlib/types/to_float.go
index bdb275de..9f1b72b6 100644
--- a/pkg/stdlib/types/to_float.go
+++ b/pkg/stdlib/types/to_float.go
@@ -2,24 +2,23 @@ package types
import (
"context"
+ "strconv"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
- "strconv"
)
-/*
- * Takes an input value of any type and convert it into a float value.
- * @param value (Value) - Input value of arbitrary type.
- * @returns (Float) -
- * None and false are converted to the value 0
- * true is converted to 1
- * Numbers keep their original value
- * Strings are converted to their numeric equivalent if the string contains a valid representation of a number.
- * String values that do not contain any valid representation of a number will be converted to the number 0.
- * An empty array is converted to 0, an array with one member is converted into the result of TO_NUMBER() for its sole member.
- * An array with two or more members is converted to the number 0.
- * An object / HTML node is converted to the number 0.
- */
+// ToFloat takes an input value of any type and convert it into a float value.
+// @param value (Value) - Input value of arbitrary type.
+// @returns (Float) -
+// None and false are converted to the value 0
+// true is converted to 1
+// Numbers keep their original value
+// Strings are converted to their numeric equivalent if the string contains a valid representation of a number.
+// String values that do not contain any valid representation of a number will be converted to the number 0.
+// An empty array is converted to 0, an array with one member is converted into the result of TO_NUMBER() for its sole member.
+// An array with two or more members is converted to the number 0.
+// An object / HTML node is converted to the number 0.
func ToFloat(ctx context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 1)
diff --git a/pkg/stdlib/types/to_int.go b/pkg/stdlib/types/to_int.go
index 75667dfb..e0857fde 100644
--- a/pkg/stdlib/types/to_int.go
+++ b/pkg/stdlib/types/to_int.go
@@ -2,24 +2,23 @@ package types
import (
"context"
+ "strconv"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
- "strconv"
)
-/*
- * Takes an input value of any type and convert it into an integer value.
- * @param value (Value) - Input value of arbitrary type.
- * @returns (Int) -
- * None and false are converted to the value 0
- * true is converted to 1
- * Numbers keep their original value
- * Strings are converted to their numeric equivalent if the string contains a valid representation of a number.
- * String values that do not contain any valid representation of a number will be converted to the number 0.
- * An empty array is converted to 0, an array with one member is converted into the result of TO_NUMBER() for its sole member.
- * An array with two or more members is converted to the number 0.
- * An object / HTML node is converted to the number 0.
- */
+// ToInt takes an input value of any type and convert it into an integer value.
+// @param value (Value) - Input value of arbitrary type.
+// @returns (Int) -
+// None and false are converted to the value 0
+// true is converted to 1
+// Numbers keep their original value
+// Strings are converted to their numeric equivalent if the string contains a valid representation of a number.
+// String values that do not contain any valid representation of a number will be converted to the number 0.
+// An empty array is converted to 0, an array with one member is converted into the result of TO_NUMBER() for its sole member.
+// An array with two or more members is converted to the number 0.
+// An object / HTML node is converted to the number 0.
func ToInt(ctx context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 1)
diff --git a/pkg/stdlib/types/to_string.go b/pkg/stdlib/types/to_string.go
index eba82095..9d91acd8 100644
--- a/pkg/stdlib/types/to_string.go
+++ b/pkg/stdlib/types/to_string.go
@@ -2,15 +2,14 @@ package types
import (
"context"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Takes an input value of any type and convert it into a string value.
- * @param value (Value) - Input value of arbitrary type.
- * @return (String) - String representation of a given value.
- */
+// ToString takes an input value of any type and convert it into a string value.
+// @param value (Value) - Input value of arbitrary type.
+// @return (String) - String representation of a given value.
func ToString(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 1)
diff --git a/pkg/stdlib/types/type_name.go b/pkg/stdlib/types/type_name.go
index 4b82a001..40aae45a 100644
--- a/pkg/stdlib/types/type_name.go
+++ b/pkg/stdlib/types/type_name.go
@@ -2,15 +2,14 @@ package types
import (
"context"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Returns the data type name of value.
- * @param value (Value) - Input value of arbitrary type.
- * @returns (Boolean) - Returns string representation of a type.
- */
+// TypeName returns the data type name of value.
+// @param value (Value) - Input value of arbitrary type.
+// @returns (Boolean) - Returns string representation of a type.
func TypeName(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 1)
diff --git a/pkg/stdlib/utils/log.go b/pkg/stdlib/utils/log.go
index e34cb131..8b152bc6 100644
--- a/pkg/stdlib/utils/log.go
+++ b/pkg/stdlib/utils/log.go
@@ -2,14 +2,13 @@ package utils
import (
"context"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/logging"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
-/*
- * Writes messages into the system log.
- */
+// Log writes messages into the system log.
func Log(ctx context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, core.MaxArgs)
diff --git a/pkg/stdlib/utils/wait.go b/pkg/stdlib/utils/wait.go
index e38a81a6..f007516e 100644
--- a/pkg/stdlib/utils/wait.go
+++ b/pkg/stdlib/utils/wait.go
@@ -2,15 +2,14 @@ package utils
import (
"context"
+ "time"
+
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
- "time"
)
-/*
- * Pauses the execution for a given period.
- * @param timeout (Int) - Integer value indication for how long to pause.
- */
+// Wait pauses the execution for a given period.
+// @param timeout (Int) - Integer value indication for how long to pause.
func Wait(_ context.Context, inputs ...core.Value) (core.Value, error) {
err := core.ValidateArgs(inputs, 1, 1)