import React from 'react'
import { messages } from '@cucumber/messages'

export class EnvelopesQuery {
  private envelopes: messages.IEnvelope[] = []

  public update(envelope: messages.IEnvelope) {
    this.envelopes.push(envelope)
  }

  public find(
    callback: (envelope: messages.IEnvelope) => boolean
  ): messages.IEnvelope {
    return this.envelopes.find(callback)
  }

  public filter(
    callback: (envelope: messages.IEnvelope) => boolean
  ): messages.IEnvelope[] {
    return this.envelopes.filter(callback)
  }
}

export default React.createContext(new EnvelopesQuery())

import React from 'react'
import { messages } from '@cucumber/messages'

export class EnvelopesQuery {
  private envelopes: messages.IEnvelope[] = []

  public update(envelope: messages.IEnvelope) {
    this.envelopes.push(envelope)
  }

  public find(
    predicate: (envelope: messages.IEnvelope) => boolean
  ): messages.IEnvelope {
    return this.envelopes.find(predicate)
  }

  public filter(
    predicate: (envelope: messages.IEnvelope) => boolean
  ): messages.IEnvelope[] {
    return this.envelopes.filter(predicate)
  }
}

export default React.createContext(new EnvelopesQuery())

Rename callback to predicate to better reveal intent
Rename callback to predicate to better reveal intent
