mirror of
https://github.com/henrywhitaker3/Speedtest-Tracker.git
synced 2025-12-25 14:59:16 +01:00
622 B
622 B
whenNotEmpty()
The whenNotEmpty method will execute the given callback when the collection is not empty:
const collection = collect(['Sadio Mané']);
collection.whenNotEmpty(c => c.push('Mohamed Salah'));
collection.all();
// [
// 'Sadio Mané',
// 'Mohamed Salah',
// ]
const collection = collect(['Sadio Mané']);
collection.whenNotEmpty(
c => c.push('Mohamed Salah'),
c => c.push('Xherdan Shaqiri'),
);
collection.all();
// [
// 'Sadio Mané',
// 'Mohamed Salah',
// ];