Files
rspade_system/node_modules/collect.js/docs/api/only.md
root f6fac6c4bc Fix bin/publish: copy docs.dist from project root
Fix bin/publish: use correct .env path for rspade_system
Fix bin/publish script: prevent grep exit code 1 from terminating script

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-21 02:08:33 +00:00

540 B
Executable File

only()

The only method returns the items in the collection with the specified keys:

const collection = collect({
  id: 12,
  name: 'John Doe',
  email: 'john@doe.com',
  active: true,
});

const filtered = collection.only(['name', 'email']);

filtered.all();

// { name: 'John Doe', email: 'john@doe.com' }
collect([1, 2, 3, 4])
  .only([2, 12])
  .all();

// [2]

For the inverse of only, see the except method.

View source on GitHub