Files
ihrm/node_modules/collect.js/docs/api/whenNotEmpty.md
Nikhil Ravi Cybrosys e1794e7422 [UPDT]translations in the views (#4)
[UPDT]Translations in the views
[FIX]major bug fixes
2023-05-18 15:05:28 +05:30

669 B
Executable File

whenNotEmpty()

The whenNotEmpty method will execute the given callback when the collection is not empty:

const collection = collect(['Darwin Núñez']);

collection.whenNotEmpty(c => c.push('Mohamed Salah'));

collection.all();

// [
//   'Darwin Núñez',
//   'Mohamed Salah',
// ]
const collection = collect(['Darwin Núñez']);

collection.whenNotEmpty(
  c => c.push('Mohamed Salah'),
  c => c.push('Xherdan Shaqiri'),
);

collection.all();

// [
//   'Darwin Núñez',
//   'Mohamed Salah',
// ];

View source on GitHub