mirror of
https://github.com/MontFerret/ferret.git
synced 2025-03-17 21:18:37 +02:00
Rewrite comments, closing #118
This commit is contained in:
parent
5db8df55db
commit
6df08a60cb
@ -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()
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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))
|
||||
}
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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(
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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, `<span class=title></span>` 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, `<span class=title></span>` 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 {
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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<String>) - 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<String>) - Array of strings.
|
||||
func Split(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 2, 3)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user