expr-data-story Pub

Data transformation examples and tests

CSV

send::  msg ctx.csv  (list:Array=[{a:1,b:2}..., separator=","=",")

expect::  (payload is array)
expect::  (payload[="0"=0] contains ",")
expect::  (payload[="2"=2] contains "3")

mkString

send::  msg ctx.set  (payload:Array=["a","b","...)

send::  msg ctx.mkString  (separator=","=",")

expect::  (payload contains "a,b,c")

Empty and accessors

send::  msg ctx.set  (a:Undefined=null)

expect::  (a is undefined)
send::  msg ctx.set  (a18=a)

expect::  (a18 is undefined)
send::  msg ctx.set  (a20=a[="5"=5])

expect::  (a20 is undefined)
send::  msg ctx.set  (a22=a[="name"]...)

expect::  (a22 is undefined)

send::  msg diesel.try 

send::  msg ctx.set  (b="")

send::  msg ctx.set  (b20=b[="5"=5])

send::  msg ctx.set  (b30=b[="name"])

send::  msg ctx.set  (j:JSON={})

send::  msg ctx.set  (b32=j[="name"])

send::  msg ctx.set  (b33=j[="name"=...)

send::  msg diesel.catch 

expect::  (b is defined)
expect::  (b20 is undefined)
expect::  (b30 is undefined)
expect::  (b32 is undefined)
expect::  (b33 is undefined)

Callingl messages without declaration

send::  msg ctx.set  (z44:Array=([1,2,3] f...)

expect::  (z44 is [2,3])

Folds and reduce

send::  msg ctx.set  (payload:Number=0=0)

send::  msg ctx.set  (z51:Array=([1,2,3,4]...)

expect::  (z51 is 10)

Math functions

send::  msg ctx.set  (arr:Array=[1,2,3,4])

send::  msg ctx.set  (x=math.min(a...)

expect::  (x is 1)
send::  msg ctx.set  (x=math.max(a...)

expect::  (x is 4)
send::  msg ctx.set  (x=math.sum(a...)

expect::  (x is 10)
send::  msg ctx.set  (x=math.avera...)

expect::  (x is 2.5)

send::  msg ctx.set  (x:Number=(1.0 as in...)

expect::  ( (( (x as string) ) is "1"))
send::  msg ctx.set  (x:Number=(1.0 as fl...)

expect::  ( (( (x as string) ) is "1.0"))


Was this useful?    

By: Razie | 2020-09-17 | Tags: story , dsl


Viewed 178 times ( | History | Print ) this page.

You need to log in to post a comment!

© Copyright DieselApps, 2012-2022, all rights reserved.