Sha256: cfdfbc8704ca75a5cdd762757a645a0110134c0c98b4f706493871692b689bd0

Contents?: true

Size: 763 Bytes

Versions: 2

Compression:

Stored size: 763 Bytes

Contents

const AbstractHandler = require('./AbstractHandler')

class ArrayGetSizeHandler extends AbstractHandler {
    requiredParametersCount = 1

    constructor() {
        super()
    }

    process(command) {
        try {
            if (command.payload.length < this.requiredParametersCount) {
                throw new Error('Array Get Size parameters mismatch')
            }
            let array = command.payload[0]
            let size = 1
            while (Array.isArray(array)) {
                size = size * array.length
                array = array[0]
            }

            return size
        } catch (error) {
            throw this.process_stack_trace(error, this.constructor.name)
        }
    }
}

module.exports = new ArrayGetSizeHandler()

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
javonet-ruby-sdk-2.5.10 lib/javonet-ruby-sdk/Binaries/Nodejs/lib/core/handler/ArrayGetSizeHandler.js
javonet-ruby-sdk-2.5.9 lib/javonet-ruby-sdk/Binaries/Nodejs/lib/core/handler/ArrayGetSizeHandler.js