line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojo::Promise::Role::None; |
2
|
1
|
|
|
1
|
|
849
|
use Mojo::Base '-role'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
11
|
|
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
468
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
211
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '1.002'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=encoding utf8 |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Mojo::Promise::Role::Any - Fulfill when all of the promises are rejected |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 SYNOPSIS |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
use Mojo::Promise; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my $none_promise = Mojo::Promise |
19
|
|
|
|
|
|
|
->with_roles( '+None' ) |
20
|
|
|
|
|
|
|
->none( @promises ); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 DESCRIPTION |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
Make a new promise that fulfills when all promises are rejected, and |
25
|
|
|
|
|
|
|
rejects otherwise. |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=over 4 |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=item none( @promises ) |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
Takes a lists of promises (or thenables) and returns another promise |
32
|
|
|
|
|
|
|
that fulfills when all of the promises are rejected. |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
If none of the promises reject, the none promise rejects. If all of the |
35
|
|
|
|
|
|
|
promises resolve then this is rejected. |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
If you pass no promises, the none promise fulfills. |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=cut |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub none { |
42
|
3
|
|
|
3
|
1
|
14367
|
my( $self, @promises ) = @_; |
43
|
3
|
|
|
|
|
13
|
my $none = $self->new; |
44
|
|
|
|
|
|
|
|
45
|
3
|
|
|
|
|
20
|
my $count = 0; |
46
|
|
|
|
|
|
|
$_->then( |
47
|
1
|
|
|
1
|
|
612
|
sub { $none->reject( @_ ) }, |
48
|
6
|
100
|
|
6
|
|
1474
|
sub { $count++; $none->resolve if $count == @promises } |
|
6
|
|
|
|
|
26
|
|
49
|
3
|
|
|
|
|
21
|
) foreach @promises; |
50
|
|
|
|
|
|
|
|
51
|
3
|
100
|
|
|
|
453
|
return @promises ? $none : $none->resolve; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=back |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 SEE ALSO |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
L, L, L |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 SOURCE AVAILABILITY |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
This source is in Github: |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
https://github.com/briandfoy/mojo-promise-role-higherorder |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 AUTHOR |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
brian d foy, C<< >> |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Copyright (c) 2018, brian d foy, All Rights Reserved. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
You may redistribute this under the terms of the Artistic License 2.0. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=cut |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
1; |