]> git.r.bdr.sh - rbdr/dotfiles/blob
f227f239de98c93821fc0a721cdb2fb89dd9e1a2
[rbdr/dotfiles] /
1 'use strict';
2
3 var toInteger = require('../../number/to-integer')
4 , value = require('../../object/valid-value')
5 , repeat = require('./repeat')
6
7 , abs = Math.abs, max = Math.max;
8
9 module.exports = function (fill/*, length*/) {
10 var self = String(value(this))
11 , sLength = self.length
12 , length = arguments[1];
13
14 length = isNaN(length) ? 1 : toInteger(length);
15 fill = repeat.call(String(fill), abs(length));
16 if (length >= 0) return fill.slice(0, max(0, length - sLength)) + self;
17 return self + (((sLength + length) >= 0) ? '' : fill.slice(length + sLength));
18 };