line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Promises::Sub; |
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:YANICK'; |
3
|
|
|
|
|
|
|
# ABSTRACT: Turns functions into promises |
4
|
|
|
|
|
|
|
$Promises::Sub::VERSION = '1.04'; |
5
|
1
|
|
|
1
|
|
1180
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
23
|
|
6
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
20
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
362
|
use Sub::Attribute; |
|
1
|
|
|
|
|
1848
|
|
|
1
|
|
|
|
|
47
|
|
9
|
1
|
|
|
1
|
|
6
|
use Carp; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
39
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
5
|
use Promises qw/ collect /; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
4
|
|
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
208
|
use parent 'Exporter'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
3
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our @EXPORT_OK = qw/ defer /; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub defer(&) { |
18
|
2
|
|
|
2
|
0
|
1160
|
my $coderef = shift; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
return sub { |
21
|
4
|
|
|
4
|
|
15
|
collect( @_ )->then( sub { $coderef->( map { @$_ } @_ ) } ); |
|
4
|
|
|
|
|
6
|
|
|
8
|
|
|
|
|
16
|
|
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
2
|
|
|
|
|
1131
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub Defer :ATTR_SUB { |
27
|
1
|
|
|
1
|
0
|
501
|
my( undef, $symbol, $referent ) = @_; |
28
|
|
|
|
|
|
|
|
29
|
1
|
50
|
|
|
|
4
|
croak "can't use attribute :Defer on an anonynous sub, use 'defer' instead" |
30
|
|
|
|
|
|
|
unless $symbol; |
31
|
|
|
|
|
|
|
|
32
|
1
|
|
|
1
|
|
154
|
no warnings 'redefine'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
52
|
|
33
|
1
|
|
|
3
|
|
5
|
$$symbol = defer { $referent->(@_) }; |
|
3
|
|
|
|
|
7
|
|
34
|
1
|
|
|
1
|
|
4
|
} |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
1; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
__END__ |