Files
Henry Whitaker ea5808047f Tweaked gitignore
gitignore removed all composer and npm files, so automated builds would fail
2020-04-12 21:24:03 +01:00

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',
// ];

View source on GitHub