hyperflow icon indicating copy to clipboard operation
hyperflow copied to clipboard

Function 'ins' and 'outs' as array-like objects

Open balis opened this issue 10 years ago • 2 comments

Function ins and outs are now Array-like objects, so that you can refer to an input/ouput by its index ins[0] OR its name ins.sig1 (they refer to the same object). However, array-like behavior is still retained, e.g. ins.forEach, ins.length.

How it works example: https://github.com/dice-cyfronet/hyperflow/blob/develop/test/funcarg.js

Related commits:

  • fdfa15207ec7de986ec6273c46d828e770f47f61
  • 8d50f74d59b8b007a35131ee84a5b1038505019a

balis avatar May 27 '14 16:05 balis

@balis: Serializing ins to JSON renders invalid output. Instead Array I get:

{
    "inputs": {
        "/etc/passwd": {
            "_id": 1,
            "data": [
                "/etc/passwd"
            ],
            "name": "/etc/passwd",
            "sigIdx": 1
        },
        "0": {
            "_id": 1,
            "data": [
                "/etc/passwd"
            ],
            "name": "/etc/passwd",
            "sigIdx": 1
        },
        "length": 1
    }
}

The workaround is to use the following instead of ins => ins.map(function(id){return id}).

kfigiela avatar Dec 16 '14 11:12 kfigiela

This looks as expected - array-like object, not array. What is the context of the problem? JSON.stringify? This also works (tested): var properArray = Array.prototype.slice.call(arrayLikeObject);

balis avatar Dec 16 '14 12:12 balis