Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
New feature: string pad #226
Comments
|
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 |
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.