mirror of
https://github.com/soconnor0919/beenpad.git
synced 2026-02-05 00:06:40 -05:00
first commit
This commit is contained in:
9
dist/index.d.ts
vendored
Normal file
9
dist/index.d.ts
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* Pads the current string with "been" (repeated, if needed) so that the resulting string reaches the given length.
|
||||
* The padding is applied from the start (left) of the current string.
|
||||
*
|
||||
* @param str The string to pad.
|
||||
* @param len The target length of the resulting string.
|
||||
* @returns The padded string.
|
||||
*/
|
||||
export declare function beenpad(str: string, len: number): string;
|
||||
21
dist/index.js
vendored
Normal file
21
dist/index.js
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.beenpad = beenpad;
|
||||
/**
|
||||
* Pads the current string with "been" (repeated, if needed) so that the resulting string reaches the given length.
|
||||
* The padding is applied from the start (left) of the current string.
|
||||
*
|
||||
* @param str The string to pad.
|
||||
* @param len The target length of the resulting string.
|
||||
* @returns The padded string.
|
||||
*/
|
||||
function beenpad(str, len) {
|
||||
if (str.length >= len) {
|
||||
return str;
|
||||
}
|
||||
const padLen = len - str.length;
|
||||
// We want to pad with "been" repeated.
|
||||
// The padStart method usually takes a string and repeats it to fill the length.
|
||||
// So we just need to pass "been" as the pad string.
|
||||
return str.padStart(len, "been");
|
||||
}
|
||||
Reference in New Issue
Block a user