My version of Ops.Array.Array_v2 (v2)

Initialise arrays in a variety of ways, with optional step increment

This op has three modes
Number - This fills the whole array with one number
1... - Fills array with incrementing numbers up to array length in steps of ‘Step’
normalize fills an array with values going from 0.0 to 1.0, 1.0 not included.
‘normalize reverse’ fills an array with values going from 1.0 to 0.0, 0.0 not included.

// Array initialisation tool
// op by Cristian Vogel
//

const
    inLength=op.inValueInt("Array length",10),
    modeSelect = op.inSwitch("Mode select",['Number','1...','0-1','1-0'],'Number'),
    inStep = op.inValueInt("Step", 2),
    inDefaultValue=op.inValueFloat("Start Value", 0 ),
    outArr=op.outArray("Array"),
    outArrayLength = op.outNumber("Array length out"),
    inReset = op.inTrigger("Reset");

let arr=[];
outArr.set(null);
let selectIndex = 0;
inStep.setUiAttribs( {greyout:true});

//events
inDefaultValue.onChange = inLength.onChange = () => { reset(modeSelect.get()) };
modeSelect.onChange = () => {onFilterChange(modeSelect.get())};
inStep.onChange = () => {reset(modeSelect.get())};
inReset.onTriggered = () => {reset(modeSelect.get())};

function onFilterChange( expr )
{
    switch (expr) {
        case ('Number') :
           // inDefaultValue.setUiAttribs({greyout:false});
            inStep.setUiAttribs( {greyout:true});
        break;
        case ('1...'):
            inStep.setUiAttribs( {greyout:false});
        break;
        default:
            // fall through
    }
    op.setUiAttrib({"extendTitle":modeSelect.get()});
    reset(expr);
}



function reset( expr )
{
    arr.length = 0;
    const arrLength = inLength.get();
    const startFrom = inDefaultValue.get();
    let i;
    switch (expr) {

        case ('1...'):
            //Continuous number array - increments in steps up to array length
            for(i = 0;i < arrLength; i=i+inStep.get()) { arr[i] = startFrom + i; }
            arr = removeNulls(arr);
            break;
        case ('0-1'):
            // normalised array
            for(i=0; i<arrLength; i=i+inStep.get()) { arr[i] = startFrom + (i / arrLength); }
            arr = removeNulls(arr);
             break;
        case ('1-0'):
            // reversed normalised array
            for(i=0; i<arrLength; i=i+inStep.get()) { arr[i] = (1 + startFrom) - (i / arrLength); }
            arr = removeNulls(arr);
            break;
        default:
            //mode 0 - fill all array values with one number
            for(i=0; i < arrLength; i++) { arr[i]=startFrom; }
    }

   function removeNulls( inArr ) {
            let arr = Array.from(new Set(inArr));
            const el = arr.indexOf( undefined );
            if (el!=-1) arr.splice( el, 1);
            return arr;
   }

    outArr.set(arr);
    outArrayLength.set(arr.length);
}