File Coverage

blib/lib/Data/Sah/Value/js/Str/repeat.pm
Criterion Covered Total %
statement 11 17 64.7
branch n/a
condition 0 4 0.0
subroutine 4 6 66.6
pod 0 2 0.0
total 15 29 51.7


line stmt bran cond sub pod time code
1             package Data::Sah::Value::js::Str::repeat;
2              
3 1     1   450218 use 5.010001;
  1         6  
4 1     1   8 use strict;
  1         3  
  1         31  
5 1     1   6 use warnings;
  1         6  
  1         71  
6              
7 1     1   599 use JSON::MaybeXS;
  1         12306  
  1         286  
8              
9             our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
10             our $DATE = '2024-01-17'; # DATE
11             our $DIST = 'Data-Sah-DefaultValue'; # DIST
12             our $VERSION = '0.005'; # VERSION
13              
14             sub meta {
15             +{
16 0     0 0   v => 1,
17             summary => 'Repeat a string a number of times',
18             prio => 50,
19             args => {
20             str => {schema=>'str*', req=>1},
21             n => {schema=>'uint*', default=>1},
22             },
23             };
24             }
25              
26             sub value {
27 0     0 0   my %cargs = @_;
28              
29 0   0       my $gen_args = $cargs{args} // {};
30 0           my $res = {};
31              
32 0   0       $res->{expr_value} = JSON::MaybeXS->new(allow_nonref=>1)->encode($gen_args->{str}) . ".repeat(" . ($gen_args->{n}//1) . ")";
33              
34 0           $res;
35             }
36              
37             1;
38             # ABSTRACT:
39              
40             __END__