Module Popcorn.Core


Description

Classes Summary
Extensible library class for random generators.

Objects Summary
Random generator object.

Functions Summary
generator array(function g)
Group generator results into array
any cConcat(any r, any n)
'cConcat' combinator function concatenates the results of generators executed in sequence into one array.
any cJoin(any r, any n)
'cJoin' combinator function joins the results of generators executed in sequence into one string.
generator chain(generator g, function f)
generator chain(generator[] gs, function f)
Use 'chain' to execute generators in sequence.
object[] circulate(object gen, object base, int count, object state, function result_transformer)
Same as 'permutate', 'circulate' executes the argument generator 'gen' on the default object 'base' and returns the resulting object array.
In difference to 'permutate', the results of all attribute generators are combined together.
generator current(function f)
'current' provides access to current generated object.
generator gen(any inp)
'gen' creates a generator that returns the argument value 'v' when executed on any input object.
any id(any value)
Identity
Lazy generator evaluation wrapper used for example by random generators.
generator[] mapGen(any[] vs)
'mapGen' is a helper function that converts all elements of an array to generators.
'mutate' executes generators 'gs' on the input object o.
'mutateOnAttribute' executes generators 'gs' on an object property of name 'name'.
object[] permutate(object gen, object base, int count, object state, function result_transformer)
'permutate' is one of two supported JSON object generation functions.
generator property(string name)
'property' applies generator 'g' on an object property of name 'name' and returns the resulting object.
random random(integer seed)
Creates a linear congruential random generator object using an optional 'seed' value.
any[] repeat(integer n, any v)
Repeats value 'v' 'n'-times and returns the resulting array.
'replicate' executes generator 'g' 'n'-times and combines the results using combinator function 'f'.
generator seq(generator[] gs, combinator f, any init)
'seq' executes the generators 'gs' and combines the result using combinator function 'f'.
generator setVar(string name, generator g)
'setVar' stores the result of one generator that can be used as input to another generator in same generation process.
generator[] toGenArray(value/generator/[generator] value)
Wrappes a value into generator array, the default input for 'mutate'.
Executes generators 'gs' on an input object and returns the updated object.
generator varGen(string name)
Creates a generator that returns the value of the variable 'name' when executed.
generator withState(function f)
'withState' provides access to the state object.
generator withVar(string name, function f)
'withVar' provides access to variables stored using setVar generator.
any[] args2array(arguments args)
Converts JavaScript function arguments to an array.
any[] args2range(arguments args, integer min, integer max)
Function arguments parser for 'range' functions.
any[] arrayOf(any inp)
object clone(object o)
Creates a new object with the argument objects as prototype.
date dateOf(any inp)
function functionOf(any inp)
integer intOf(any inp)
'intOf' truncates the input to an int if the input object is a number.
boolean isArray(any inp)
boolean isDate(any inp)
boolean isFunction(any inp)
boolean isInt(any inp)
boolean isNull(any inp)
boolean isNumber(any inp)
boolean isObject(any inp)
boolean isString(any inp)
boolean isUndefined(any inp)
any[] map(function f, any[] as)
Applies function 'f' on all elements of array 'as'.
object merge(object+ os)
Merges argument objects together.
number numberOf(any inp)
string stringOf(any inp)
string typeOf(any inp)
'typeOf' extends JavaScript 'typeof' operator with support for 'null', 'undefined', 'array' and 'date' types.