3 var toInteger = require('../../number/to-integer')
4 , value = require('../../object/valid-value')
5 , repeat = require('./repeat')
7 , abs = Math.abs, max = Math.max;
9 module.exports = function (fill/*, length*/) {
10 var self = String(value(this))
11 , sLength = self.length
12 , length = arguments[1];
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));