web 3d图形渲染器
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

16 lines
582 B

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