Namespace Popcorn.Common


namespace Popcorn.Common
A collection of most common generators.
Authors:
Adam Smyczek

Function Summary
generator append(any inp)
generator append(any[] ar)
Appends a value to the attribute value of the base object.
generator[string] concat([generator/primitives] value)
Concats arguments (primitives single result generators) into one string.
generator date(milisec from, milisec to, string format)
Generates a random date
generator join(any+ args)
Joins arguments together.
generator[any] list(any+ args)
Converts input arguments into a generator array [gen(arguments[i])].
generator now(string format)
A convenience function that creates a generator for current date/time.
generator prepend(any inp)
generator prepend(any[] ar)
Prepends a value to the attribute value of the base object.
generator[int] range(integer max)
generator[int] range(integer min, integer max)
'range' generator creates a list of integer generators in the range from min to max.

Function Details

function append

generator append(any inp)
generator append(any[] ar)
generator append(generator gen)
Appends a value to the attribute value of the base object. See prepend for details.
Parameters:
Value
inp - the value to append.
Array
ar - the values to append. The resulting array contains one object for every array element.
generator
gen - the generator of which result is appended to the base object value.
Defined in Popcorn.Common

function concat

generator[string] concat([generator/primitives] value)
Concats arguments (primitives single result generators) into one string.
Parameters:
value - single value generators or primitives to concatenate.
Defined in Popcorn.Common

function date

generator date(milisec from, milisec to, string format)
Generates a random date
Parameters:
from - from date
to - to date
format - the output format, possible values are: date, hours, minutes, seconds, time, gmt. By default data prints the local time string.
Defined in Popcorn.Common

function join

generator join(any+ args)
Joins arguments together. Generator arguments are evaluated and array arguments join recursive.
Parameters:
args - values, arrays or generators.
Defined in Popcorn.Common

function list

generator[any] list(any+ args)
Converts input arguments into a generator array [gen(arguments[i])].
For example:
   var o = { name : 'Woody' }
   var gen = { name : list('Buzz', 'Slinky');
   generate(gen, o) will return:
   [{ name : 'Buzz' }, { name : 'Slinky' }]
 
Parameters:
args - the values to generate.
Defined in Popcorn.Common

function now

generator now(string format)
A convenience function that creates a generator for current date/time.
Parameters:
format - the output format, possible values are: date, hours, minutes, seconds, time, gmt. By default data prints the local time string.
Defined in Popcorn.Common

function prepend

generator prepend(any inp)
generator prepend(any[] ar)
generator prepend(generator gen)
Prepends a value to the attribute value of the base object. Prepend takes a value, an array or a generator as argument.
For example:
   var o = { name : 'Head' }
   generate({ name : prepend('Mr. Potato ') }, o) will generate:
   [{ name : 'Mr. Potato Head' }]
 
Parameters:
Value
inp - the value to prepend.
Array
ar - the values to prepend. The resulting array contains one object for every array element.
generator
gen - the generator of which result is prepended to the base object value.
Defined in Popcorn.Common

function range

generator[int] range()
generator[int] range(integer max)
generator[int] range(integer min, integer max)
'range' generator creates a list of integer generators in the range from min to max. This is a range function and accepts no arguments, or one or two integer arguments. For example:
   var o = { int : 0 }
   var gen = { int : range(1, 3);
   generate(gen, o) will return:
   [{ int : 1 }, { int : 2 }, { int : 3 }]
 
Parameters:
No arguments - generates a range from 0 to 100.
One int argument - generates a range from 0 to max.
max - range max value.
two int arguments - from-to range.
min - from integer
max - to integer
Defined in Popcorn.Common