Skip to content

Latest commit

 

History

History
74 lines (59 loc) · 829 Bytes

.verb.md

File metadata and controls

74 lines (59 loc) · 829 Bytes

Usage

object

pad({
  a: 'b', 
  c: 'dddddd', 
  e: 'fff', 
  g: 'hhhhh'
});

Results in:

{
  a: 'b     ',
  c: 'dddddd',
  e: 'fff   ',
  g: 'hhhhh ',
};

Specific property in object of objects

pad('foo', {
  a: {
    foo: 'a',
    bar: 'z'
  },
  b: {
    foo: 'aaaaaaa',
    bar: 'z'
  },
  c: {
    foo: 'aaa',
    bar: 'z'
  }
});

Results in:

{ a: { foo: 'a      ', bar: 'z' },
  b: { foo: 'aaaaaaa', bar: 'z' },
  c: { foo: 'aaa    ', bar: 'z' } }

array of objects

Pass an array and specify the property with the value to pad:

var pad = require('{%= name %}');

var arr = [{a: 'b'}, {a: 'bb'}, {a: 'bbbb'}, {a: 'bbb'}, {a: 'bb'}];
pad(arr, 'a');

Results in:

[
  {a: 'b   '},
  {a: 'bb  '},
  {a: 'bbbb'},
  {a: 'bbb '},
  {a: 'bb  '}
];