File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,13 @@ class AddLineNumbers extends Operation {
2222 this . description = "Adds line numbers to the output." ;
2323 this . inputType = "string" ;
2424 this . outputType = "string" ;
25- this . args = [ ] ;
25+ this . args = [
26+ {
27+ "name" : "Offset" ,
28+ "type" : "number" ,
29+ "value" : 0
30+ }
31+ ] ;
2632 }
2733
2834 /**
@@ -33,10 +39,11 @@ class AddLineNumbers extends Operation {
3339 run ( input , args ) {
3440 const lines = input . split ( "\n" ) ,
3541 width = lines . length . toString ( ) . length ;
42+ const offset = args [ 0 ] ? parseInt ( args [ 0 ] , 10 ) : 0 ;
3643 let output = "" ;
3744
3845 for ( let n = 0 ; n < lines . length ; n ++ ) {
39- output += ( n + 1 ) . toString ( ) . padStart ( width , " " ) + " " + lines [ n ] + "\n" ;
46+ output += ( n + 1 + offset ) . toString ( ) . padStart ( width , " " ) + " " + lines [ n ] + "\n" ;
4047 }
4148 return output . slice ( 0 , output . length - 1 ) ;
4249 }
You can’t perform that action at this time.
0 commit comments