stdlib

package
v1.24.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 26, 2019 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BuiltinModules = map[string]map[string]objects.Object{
	"math":  mathModule,
	"os":    osModule,
	"text":  textModule,
	"times": timesModule,
	"rand":  randModule,
	"fmt":   fmtModule,
	"json":  jsonModule,
}

BuiltinModules are builtin type standard library modules.

View Source
var SourceModules = map[string]string{
	"enum": "is_enumerable := func(x) {\n  return is_array(x) || is_map(x) || is_immutable_array(x) || is_immutable_map(x)\n}\n\nis_array_like := func(x) {\n  return is_array(x) || is_immutable_array(x)\n}\n\nexport {\n  // all returns true if the given function `fn` evaluates to a truthy value on\n  // all of the items in `x`. It returns undefined if `x` is not enumerable.\n  all: func(x, fn) {\n    if !is_enumerable(x) { return undefined }\n\n    for k, v in x {\n      if !fn(k, v) { return false }\n    }\n\n    return true\n  },\n  // any returns true if the given function `fn` evaluates to a truthy value on\n  // any of the items in `x`. It returns undefined if `x` is not enumerable.\n  any: func(x, fn) {\n    if !is_enumerable(x) { return undefined }\n\n    for k, v in x {\n      if fn(k, v) { return true }\n    }\n\n    return false\n  },\n  // chunk returns an array of elements split into groups the length of size.\n  // If `x` can't be split evenly, the final chunk will be the remaining elements.\n  // It returns undefined if `x` is not array.\n  chunk: func(x, size) {\n    if !is_array_like(x) || !size { return undefined }\n\n    numElements := len(x)\n    if !numElements { return [] }\n\n    res := []\n    idx := 0\n    for idx < numElements {\n      res = append(res, x[idx:idx+size])\n      idx += size\n    }\n\n    return res\n  },\n  // at returns an element at the given index (if `x` is array) or\n  // key (if `x` is map). It returns undefined if `x` is not enumerable.\n  at: func(x, key) {\n    if !is_enumerable(x) { return undefined }\n\n    if is_array_like(x) {\n        if !is_int(key) { return undefined }\n    } else {\n        if !is_string(key) { return undefined }\n    }\n\n    return x[key]\n  },\n  // each iterates over elements of `x` and invokes `fn` for each element. `fn` is\n  // invoked with two arguments: `key` and `value`. `key` is an int index\n  // if `x` is array. `key` is a string key if `x` is map. It does not iterate\n  // and returns undefined if `x` is not enumerable.\n  each: func(x, fn) {\n    if !is_enumerable(x) { return undefined }\n\n    for k, v in x {\n      fn(k, v)\n    }\n  },\n  // filter iterates over elements of `x`, returning an array of all elements `fn`\n  // returns truthy for. `fn` is invoked with two arguments: `key` and `value`.\n  // `key` is an int index if `x` is array. `key` is a string key if `x` is map.\n  // It returns undefined if `x` is not enumerable.\n  filter: func(x, fn) {\n    if !is_array_like(x) { return undefined }\n\n    dst := []\n    for k, v in x {\n      if fn(k, v) { dst = append(dst, v) }\n    }\n\n    return dst\n  },\n  // find iterates over elements of `x`, returning value of the first element `fn`\n  // returns truthy for. `fn` is invoked with two arguments: `key` and `value`.\n  // `key` is an int index if `x` is array. `key` is a string key if `x` is map.\n  // It returns undefined if `x` is not enumerable.\n  find: func(x, fn) {\n    if !is_enumerable(x) { return undefined }\n\n    for k, v in x {\n      if fn(k, v) { return v }\n    }\n  },\n  // find_key iterates over elements of `x`, returning key or index of the first\n  // element `fn` returns truthy for. `fn` is invoked with two arguments: `key`\n  // and `value`. `key` is an int index if `x` is array. `key` is a string key if\n  // `x` is map. It returns undefined if `x` is not enumerable.\n  find_key: func(x, fn) {\n    if !is_enumerable(x) { return undefined }\n\n    for k, v in x {\n      if fn(k, v) { return k }\n    }\n  },\n  // map creates an array of values by running each element in `x` through `fn`.\n  // `fn` is invoked with two arguments: `key` and `value`. `key` is an int index\n  // if `x` is array. `key` is a string key if `x` is map. It returns undefined\n  // if `x` is not enumerable.\n  map: func(x, fn) {\n    if !is_enumerable(x) { return undefined }\n\n    dst := []\n    for k, v in x {\n      dst = append(dst, fn(k, v))\n    }\n\n    return dst\n  },\n  // key returns the first argument.\n  key: func(k, _) { return k },\n  // value returns the second argument.\n  value: func(_, v) { return v }\n}\n",
}

SourceModules are source type standard library modules.

Functions

func AllModuleNames added in v1.10.1

func AllModuleNames() []string

AllModuleNames returns a list of all default module names.

func FuncAFFRF

func FuncAFFRF(fn func(float64, float64) float64) objects.CallableFunc

FuncAFFRF transform a function of 'func(float64, float64) float64' signature into CallableFunc type.

func FuncAFIRB

func FuncAFIRB(fn func(float64, int) bool) objects.CallableFunc

FuncAFIRB transform a function of 'func(float64, int) bool' signature into CallableFunc type.

func FuncAFIRF

func FuncAFIRF(fn func(float64, int) float64) objects.CallableFunc

FuncAFIRF transform a function of 'func(float64, int) float64' signature into CallableFunc type.

func FuncAFRB

func FuncAFRB(fn func(float64) bool) objects.CallableFunc

FuncAFRB transform a function of 'func(float64) bool' signature into CallableFunc type.

func FuncAFRF

func FuncAFRF(fn func(float64) float64) objects.CallableFunc

FuncAFRF transform a function of 'func(float64) float64' signature into CallableFunc type.

func FuncAFRI

func FuncAFRI(fn func(float64) int) objects.CallableFunc

FuncAFRI transform a function of 'func(float64) int' signature into CallableFunc type.

func FuncAI64R

func FuncAI64R(fn func(int64)) objects.CallableFunc

FuncAI64R transform a function of 'func(int64)' signature into CallableFunc type.

func FuncAI64RI64

func FuncAI64RI64(fn func(int64) int64) objects.CallableFunc

FuncAI64RI64 transform a function of 'func(int64) int64' signature into CallableFunc type.

func FuncAIFRF

func FuncAIFRF(fn func(int, float64) float64) objects.CallableFunc

FuncAIFRF transform a function of 'func(int, float64) float64' signature into CallableFunc type.

func FuncAIIRE

func FuncAIIRE(fn func(int, int) error) objects.CallableFunc

FuncAIIRE transform a function of 'func(int, int) error' signature into CallableFunc type.

func FuncAIR

func FuncAIR(fn func(int)) objects.CallableFunc

FuncAIR transform a function of 'func(int)' signature into CallableFunc type.

func FuncAIRF

func FuncAIRF(fn func(int) float64) objects.CallableFunc

FuncAIRF transform a function of 'func(int) float64' signature into CallableFunc type.

func FuncAIRIs

func FuncAIRIs(fn func(int) []int) objects.CallableFunc

FuncAIRIs transform a function of 'func(int) []int' signature into CallableFunc type.

func FuncAIRS

func FuncAIRS(fn func(int) string) objects.CallableFunc

FuncAIRS transform a function of 'func(int) string' signature into CallableFunc type.

func FuncAIRSsE

func FuncAIRSsE(fn func(int) ([]string, error)) objects.CallableFunc

FuncAIRSsE transform a function of 'func(int) ([]string, error)' signature into CallableFunc type.

func FuncAR

func FuncAR(fn func()) objects.CallableFunc

FuncAR transform a function of 'func()' signature into CallableFunc type.

func FuncARB

func FuncARB(fn func() bool) objects.CallableFunc

FuncARB transform a function of 'func() bool' signature into CallableFunc type.

func FuncARE

func FuncARE(fn func() error) objects.CallableFunc

FuncARE transform a function of 'func() error' signature into CallableFunc type.

func FuncARF

func FuncARF(fn func() float64) objects.CallableFunc

FuncARF transform a function of 'func() float64' signature into CallableFunc type.

func FuncARI

func FuncARI(fn func() int) objects.CallableFunc

FuncARI transform a function of 'func() int' signature into CallableFunc type.

func FuncARI64

func FuncARI64(fn func() int64) objects.CallableFunc

FuncARI64 transform a function of 'func() int64' signature into CallableFunc type.

func FuncARIsE

func FuncARIsE(fn func() ([]int, error)) objects.CallableFunc

FuncARIsE transform a function of 'func() ([]int, error)' signature into CallableFunc type.

func FuncARS

func FuncARS(fn func() string) objects.CallableFunc

FuncARS transform a function of 'func() string' signature into CallableFunc type.

func FuncARSE

func FuncARSE(fn func() (string, error)) objects.CallableFunc

FuncARSE transform a function of 'func() (string, error)' signature into CallableFunc type.

func FuncARSs

func FuncARSs(fn func() []string) objects.CallableFunc

FuncARSs transform a function of 'func() []string' signature into CallableFunc type.

func FuncARYE

func FuncARYE(fn func() ([]byte, error)) objects.CallableFunc

FuncARYE transform a function of 'func() ([]byte, error)' signature into CallableFunc type.

func FuncASI64RE

func FuncASI64RE(fn func(string, int64) error) objects.CallableFunc

FuncASI64RE transform a function of 'func(string, int64) error' signature into CallableFunc type.

func FuncASIIRE

func FuncASIIRE(fn func(string, int, int) error) objects.CallableFunc

FuncASIIRE transform a function of 'func(string, int, int) error' signature into CallableFunc type.

func FuncASIRS

func FuncASIRS(fn func(string, int) string) objects.CallableFunc

FuncASIRS transform a function of 'func(string, int) string' signature into CallableFunc type.

func FuncASRE

func FuncASRE(fn func(string) error) objects.CallableFunc

FuncASRE transform a function of 'func(string) error' signature into CallableFunc type. User function will return 'true' if underlying native function returns nil.

func FuncASRIE

func FuncASRIE(fn func(string) (int, error)) objects.CallableFunc

FuncASRIE transform a function of 'func(string) (int, error)' signature into CallableFunc type.

func FuncASRS

func FuncASRS(fn func(string) string) objects.CallableFunc

FuncASRS transform a function of 'func(string) string' signature into CallableFunc type. User function will return 'true' if underlying native function returns nil.

func FuncASRSE

func FuncASRSE(fn func(string) (string, error)) objects.CallableFunc

FuncASRSE transform a function of 'func(string) (string, error)' signature into CallableFunc type. User function will return 'true' if underlying native function returns nil.

func FuncASRSs

func FuncASRSs(fn func(string) []string) objects.CallableFunc

FuncASRSs transform a function of 'func(string) []string' signature into CallableFunc type.

func FuncASSIRSs

func FuncASSIRSs(fn func(string, string, int) []string) objects.CallableFunc

FuncASSIRSs transform a function of 'func(string, string, int) []string' signature into CallableFunc type.

func FuncASSRB

func FuncASSRB(fn func(string, string) bool) objects.CallableFunc

FuncASSRB transform a function of 'func(string, string) bool' signature into CallableFunc type.

func FuncASSRE

func FuncASSRE(fn func(string, string) error) objects.CallableFunc

FuncASSRE transform a function of 'func(string, string) error' signature into CallableFunc type. User function will return 'true' if underlying native function returns nil.

func FuncASSRI

func FuncASSRI(fn func(string, string) int) objects.CallableFunc

FuncASSRI transform a function of 'func(string, string) int' signature into CallableFunc type.

func FuncASSRS

func FuncASSRS(fn func(string, string) string) objects.CallableFunc

FuncASSRS transform a function of 'func(string, string) string' signature into CallableFunc type.

func FuncASSRSs

func FuncASSRSs(fn func(string, string) []string) objects.CallableFunc

FuncASSRSs transform a function of 'func(string, string) []string' signature into CallableFunc type.

func FuncASsSRS

func FuncASsSRS(fn func([]string, string) string) objects.CallableFunc

FuncASsSRS transform a function of 'func([]string, string) string' signature into CallableFunc type.

func FuncAYRIE

func FuncAYRIE(fn func([]byte) (int, error)) objects.CallableFunc

FuncAYRIE transform a function of 'func([]byte) (int, error)' signature into CallableFunc type.

func GetModuleMap added in v1.18.0

func GetModuleMap(names ...string) *objects.ModuleMap

GetModuleMap returns the module map that includes all modules for the given module names.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL