Open TheoryOfNekomata opened 8 years ago
i'll take a crack at this. @Temoto-kun, how were you envisioning this working? for a one-directional pad, we can just say "take this string and put zeros at the end until the total length is 10." there's not such a clear path on a center-pad. would you specify a total length and then pad either side until it matched? would you specify a number of characters to be appended to both sides? how would you deal with cases where you'd wind up with an uneven number of pad characters?
probably i would be inclined to specify a target string length and pad either side progressively until we reach it. if we hit length
and there's an uneven number of pad characters, it'll knock one off the too-long side. this could result in a string being shorter than specified, but i think it'll preserve aesthetic appeal.
if we hit length and there's an uneven number of pad characters, it'll knock one off the too-long side.
Or it can have the option of bias, whether to allow more pad characters to the left or right. In that case, I'm thinking it could have separate filters for the one-directional and the bi-directional pad so as not to put too many args on a single pad function. You could dismiss that notion, but I'm just giving a suggestion on how it should be implemented.
Self-explanatory. But instead of the default left and right pad filters, there's a center pad.