Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

615 B
Raw Blame
import { Scope } from '../../scope'
import { Pattern } from '../predicate'
import { Expr } from './base'
import { FilterExpr } from './filter'

export class RejectExpr extends FilterExpr {
    constructor(from: Expr, where: Pattern | null, ifEmpty: Expr | null) {
        super(from, where, ifEmpty)
    }
    eval(scope: Scope): unknown {
        const arr = this.from.eval(scope)
        if (!Array.isArray(arr)) {
            return this.onNotArray(scope)
        }
        const result = this.where ? arr.filter((item) => !this.where!.matches(item)) : arr
        return this.withIfEmpty(result, scope)
    }
}