Skip to content

Instantly share code, notes, and snippets.

@erikjung
Last active March 24, 2016 19:12
Show Gist options
  • Select an option

  • Save erikjung/d2e6dc2c33c61b0ccfde to your computer and use it in GitHub Desktop.

Select an option

Save erikjung/d2e6dc2c33c61b0ccfde to your computer and use it in GitHub Desktop.

Revisions

  1. erikjung revised this gist Mar 24, 2016. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions left-pad.js
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    module.exports = function leftpad (str, len, ch) {
    const val = `${str}`;
    const pad = ch === undefined ? ' ' : `${ch}`;
    const val = String(str);
    const pad = ch === undefined ? ' ' : String(ch);
    return pad.repeat(Math.max(0, len - val.length), pad) + val;
    };
  2. erikjung revised this gist Mar 24, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion left-pad.js
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    module.exports = function leftpad (str, len, ch) {
    const val = `${str}`;
    const pad = `${ch}`;
    const pad = ch === undefined ? ' ' : `${ch}`;
    return pad.repeat(Math.max(0, len - val.length), pad) + val;
    };
  3. erikjung revised this gist Mar 24, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion left-pad.js
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    module.exports = function leftpad (str, len, ch = ' ') {
    module.exports = function leftpad (str, len, ch) {
    const val = `${str}`;
    const pad = `${ch}`;
    return pad.repeat(Math.max(0, len - val.length), pad) + val;
  4. erikjung revised this gist Mar 24, 2016. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions left-pad.js
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    module.exports = function leftpad (str, len, ch = ' ') {
    const val = `${str}`
    const pad = `${ch}`
    const val = `${str}`;
    const pad = `${ch}`;
    return pad.repeat(Math.max(0, len - val.length), pad) + val;
    };
  5. erikjung revised this gist Mar 24, 2016. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions left-pad.js
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    module.exports = function (str, len, ch) {
    return ch.repeat(len) + str;
    module.exports = function leftpad (str, len, ch = ' ') {
    const val = `${str}`
    const pad = `${ch}`
    return pad.repeat(Math.max(0, len - val.length), pad) + val;
    };
  6. erikjung revised this gist Mar 24, 2016. 2 changed files with 1 addition and 1 deletion.
    File renamed without changes.
    2 changes: 1 addition & 1 deletion package.json
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    {
    "name": "left-pad",
    "main": "index.css",
    "main": "left-pad.js",
    "version": "0.0.1"
    }
  7. erikjung revised this gist Mar 24, 2016. 3 changed files with 8 additions and 3 deletions.
    3 changes: 3 additions & 0 deletions index.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    module.exports = function (str, len, ch) {
    return ch.repeat(len) + str;
    };
    3 changes: 0 additions & 3 deletions leftpad.js
    Original file line number Diff line number Diff line change
    @@ -1,3 +0,0 @@
    module.exports = function leftpad (str, len, ch) {
    return ch.repeat(len) + str;
    };
    5 changes: 5 additions & 0 deletions package.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    {
    "name": "left-pad",
    "main": "index.css",
    "version": "0.0.1"
    }
  8. erikjung created this gist Mar 24, 2016.
    3 changes: 3 additions & 0 deletions leftpad.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    module.exports = function leftpad (str, len, ch) {
    return ch.repeat(len) + str;
    };