21 lines
595 B
JavaScript
21 lines
595 B
JavaScript
|
"use strict";
|
||
|
function padString(input) {
|
||
|
var segmentLength = 4;
|
||
|
var stringLength = input.length;
|
||
|
var diff = stringLength % segmentLength;
|
||
|
if (!diff) {
|
||
|
return input;
|
||
|
}
|
||
|
var position = stringLength;
|
||
|
var padLength = segmentLength - diff;
|
||
|
var paddedStringLength = stringLength + padLength;
|
||
|
var buffer = new Buffer(paddedStringLength);
|
||
|
buffer.write(input);
|
||
|
while (padLength--) {
|
||
|
buffer.write("=", position++);
|
||
|
}
|
||
|
return buffer.toString();
|
||
|
}
|
||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||
|
exports.default = padString;
|