Page 1 of 1

how complicated can EOS get?

Posted: Sat Dec 18, 2021 7:00 am
by grelgen
I just tried to throw some array code at EOS and it seems to error out in the init. this is all I've put so far:

const Struct = (...keys) => ((...v) => keys.reduce((o, k, i) => {o[k] = v[i]; return o} , {}));
const unit = Struct('lookup1','lookup2','rank1','rank2');

I admit, there's a lot going on there. should I try to shy away from using dot notation in my arrays or should this kind of stuff work and my error is somewhere north of this?

Re: how complicated can EOS get?

Posted: Sat Dec 18, 2021 10:48 am
by edger477
Hi,

I haven't done any teases, but I work with javascript for living, so maybe I can help...

How to reproduce this? (Where you put this code? In eval block? I need steps how to repro it myself)

Also, what do you want to accomplish with this? This struct seems like a function generator, so calling it like you did creates function "unit" that produces objects like this:
unit('a', 'b', 'c', 'd')

result:

{lookup1: 'a', lookup2: 'b', rank1: 'c', rank2: 'd'}

Re: how complicated can EOS get?

Posted: Sat Dec 18, 2021 6:19 pm
by kerkersklave
EOS uses a Javascript interpreter written in Javascript for security reasons. I haven't experimented with it, but the documentation of EOS says, that it supports ECMAScript 5. Arrow-Functions have been introduced with ECMAScript 6, so they are probably just not supported. The scripts can be quite complicated, but you have to stick to ECMAScript 5. I would try using classical anonymous functions.

Re: how complicated can EOS get?

Posted: Sat Dec 18, 2021 6:22 pm
by edger477
Ok so forget about ... and =>