logo
Free, Micro AI Code Reviews That Run on Git Commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, Micro AI Code Reviews That Run on Git Commit | Product Hunt git-lrc - Free, Micro AI Code Reviews That Run on Git Commit | Product Hunt

CSAF::Util::List - (Mojo like) collection utility

Author

       •   Giuseppe Di Terlizzi <gdt@cpan.org>

Description

       CSAF::Util::List is a collection utility.

   METHODS
       TO_JSON
           Alias for "to_array".

       add Alias for "item".

       each
           Evaluate callback for each element in collection.

               foreach my $item ($c->each) {
                   [...]
               }

               my $collection = $c->each(sub {...});

               $c->each(sub {
                   my ($value, $idx) = @_;
                   [...]
               });

       first
           Get the first element of collection.

       grep
           Filter items.

               my $filtered = $c->grep(sub { $_ eq 'foo' });

       item
           Add a new item in collection.

               $c->item('foo');
               $c->item(sub {...});

       items
           Get the list of collection items.

       join
           Join elements in collection.

               $c->join(', ');

       last
           Get the last element of collection.

       map Evaluate the callback and create a new collection.

               CSAF::Util::List->new(1,2,3)->map(sub { $_ * 2 });

       new Create a new collection.

               my $c = CSAF::Util::List->new( [foo bar baz] );

       size
           Number of item elements.

       to_array
           Return the collection array.

Name

       CSAF::Util::List - (Mojo like) collection utility

Support

Bugs/FeatureRequests
       Please     report    any    bugs    or    feature    requests    through    the    issue    tracker    at
       <https://github.com/giterlizzi/perl-CSAF/issues>.  You will be notified automatically of any progress  on
       your issue.

   SourceCode
       This  is open source software.  The code repository is available for public review and contribution under
       the terms of the license.

       <https://github.com/giterlizzi/perl-CSAF>

           git clone https://github.com/giterlizzi/perl-CSAF.git

Synopsis

           use CSAF::Util::List;
           my $collection = CSAF::Util::List->new( qw[foo bar baz] );

See Also