8000 Auto-generated commit · stdlib-js/string-right-pad@56ef424 · GitHub
[go: up one dir, main page]

Skip to content < 10000 span data-view-component="true" class="progress-pjax-loader Progress position-fixed width-full">

Commit 56ef424

Browse files
committed
Auto-generated commit
1 parent dd229e1 commit 56ef424

File tree

4 files changed

+4
-12
lines changed

4 files changed

+4
-12
lines changed

.github/.keepalive

Lines changed: 0 additions & 1 deletion
This file was deleted.

CONTRIBUTORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Joey Reed <joeyrreed@gmail.com>
1616
Jordan-Gallivan <115050475+Jordan-Gallivan@users.noreply.github.com>
1717
Joris Labie <joris.labie1@gmail.com>
1818
Justin Dennison <justin1dennison@gmail.com>
19+
KATTA NAGA NITHIN <88046362+nithinkatta@users.noreply.github.com>
1920
Marcus <mfantham@users.noreply.github.com>
2021
Matt Cochrane <matthew.cochrane.eng@gmail.com>
2122
Milan Raj <rajsite@users.noreply.github.com>

lib/main.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@
2222

2323
var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;
2424
var isString = require( '@stdlib/assert-is-string' ).isPrimitive;
25-
var repeat = require( '@stdlib/string-repeat' );
26-
var ceil = require( '@stdlib/math-base-special-ceil' );
2725
var format = require( '@stdlib/string-format' );
2826
var FLOAT64_MAX_SAFE_INTEGER = require( '@stdlib/constants-float64-max-safe-integer' );
27+
var base = require( '@stdlib/string-base-right-pad' );
2928

3029

3130
// MAIN //
@@ -55,7 +54,6 @@ var FLOAT64_MAX_SAFE_INTEGER = require( '@stdlib/constants-float64-max-safe-inte
5554
* // returns 'beepboopboop'
5655
*/
5756
function rpad( str, len, pad ) {
58-
var n;
5957
var p;
6058
if ( !isString( str ) ) {
6159
throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) );
@@ -77,12 +75,7 @@ function rpad( str, len, pad ) {
7775
if ( len > FLOAT64_MAX_SAFE_INTEGER ) {
7876
throw new RangeError( format( 'invalid argument. Output string length exceeds maximum allowed string length. Value: `%u`.', len ) );
7977
}
80-
n = ( len - str.length ) / p.length;
81-
if ( n <= 0 ) {
82-
return str;
83-
}
84-
n = ceil( n );
85-
return str + repeat( p, n );
78+
return base( str, len, p );
8679
}
8780

8881

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,11 @@
4646
"@stdlib/cli-ctor": "^0.0.3",
4747
"@stdlib/constants-float64-max-safe-integer": "^0.0.8",
4848
"@stdlib/fs-read-file": "^0.0.8",
49-
"@stdlib/math-base-special-ceil": "^0.0.8",
5049
"@stdlib/process-read-stdin": "^0.0.7",
5150
"@stdlib/regexp-eol": "^0.0.7",
5251
"@stdlib/streams-node-stdin": "^0.0.7",
52+
"@stdlib/string-base-right-pad": "github:stdlib-js/string-base-right-pad#main",
5353
"@stdlib/string-format": "^0.0.3",
54-
"@stdlib/string-repeat": "^0.0.9",
5554
"@stdlib/utils-regexp-from-string": "^0.0.9"
5655
},
5756
"devDependencies": {

0 commit comments

Comments
 (0)
0