octoblu/nanocyte-component-pass-through-if-length-greater-than-min

View on GitHub
src/pass-through-if-length-greater-than-min.coffee

Summary

Maintainability
Test Coverage
ReturnValue = require 'nanocyte-component-return-value'
_ = require 'lodash'

class PassThroughIfLengthGreaterThanMin extends ReturnValue
  onEnvelope: (envelope) =>
    {message,config} = envelope

    return unless _.isArray message
    return if message.length < config.min
    return envelope.message

module.exports = PassThroughIfLengthGreaterThanMin