padStart

This tag by default zero pads a string, it also splits on comma to pad multiple strings.

Created by: hackvertor
Installed 1 times

Category: String

Created on: Tuesday, October 15, 2024 at 6:52:28 PM

Updated on: Tuesday, October 15, 2024 at 6:52:28 PM

This is a built in tag
Tag arguments
[
   {
      "type": "number",
      "help": "This controls the amount of padding",
      "defaultValue": "2"
   },
   {
      "type": "string",
      "help": "This is the padding character",
      "defaultValue": "0"
   }
]
Code
class padStart {
  encode(input, len, padCharacter) {
    return input
      .split(",")
      .map((chr) => chr.padStart(len, padCharacter))
      .join(",");
  }
}