Collect.js dump() Method

The dump() method in collect.js is used to print the data at particular moment and then continue further executing the code.

Syntax:

collect.dump()

Parameters: It does not accept any parameters.

Return Value: It does not return any value.

Example 1:



Javascript

filter_none

edit
close

play_arrow

link
brightness_4
code

// Importing the collect.js module
const collect = require('collect.js'); 
let array = ["a", "b", "c"];
  
// Making the collection
let collection= collect(array);
  
// Using dump() method to print
// the data at this moment
collection.dump()

chevron_right


Output:

Collection { items: [ 'a', 'b', 'c' ] }

Example 2:

Javascript

filter_none

edit
close

play_arrow

link
brightness_4
code

// Importing the collect.js module.
const collect = require('collect.js');
  
let array = ["a", "b", "c", "d", "e"];
  
// Making the collection
let collection = collect(array);
  
// Using dump() method to print
// the data at this moment
collection.dump()
    .filter((v, k) => v >= "c")
    .dump()

chevron_right


Output:

Collection { items: [ 'a', 'b', 'c', 'd', 'e' ] }
Collection  { items: [ 'c', 'd', 'e' ] }

Reference: https://collect.js.org/api/dump.html

full-stack-img

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.