Skip to content

contains doesn't actually accept a callbackΒ #37

@mjsarfatti

Description

@mjsarfatti

Describe the bug

The docs state that a callback can be passed to contains, but that's not the case, and the types in fact reflect this.

Relevant code:

    contains(keyOrItem: T | keyof T | undefined, value?: any): boolean {
      if (arguments.length === 1) {
        if (keyOrItem === undefined)
          return false
        return collection.items.includes(keyOrItem as T)
      }
      return collection.items.some(item => item[keyOrItem as keyof T] === value)
    },

One solution is to edit the docs and remove references to the callback function. A better solution might be to implement this (see, for example, how collect.js does it)

Reproduction

https://I-dont-believe-its-needed.com

System Info

Not needed

Used Package Manager

npm

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions