UNPKG

@stdlib/esm

Version:

ES module distribution for Stdlib, a standard library for JavaScript and Node.js.

3 lines 1.08 kB
// This file is a part of stdlib. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 import e from"./../assert/is-nonnegative-integer.js";import r from"./../assert/is-string.js";import t from"./repeat.js";import n from"./../math/base/special/ceil.js";import i from"./../constants/math/float64-max-safe-integer.js";var a=e.isPrimitive,m=r.isPrimitive,s=t,o=n,g=i;function u(e,r,t){var n,i;if(!m(e))throw new TypeError("invalid argument. First argument must be a string. Value: `"+e+"`.");if(!a(r))throw new TypeError("invalid argument. Second argument must be a nonnegative integer. Value: `"+r+"`.");if(arguments.length>2){if(!m(i=t))throw new TypeError("invalid argument. Third argument must be a string. Value: `"+i+"`.");if(0===i.length)throw new RangeError("invalid argument. Third argument must not be an empty string.")}else i=" ";if(r>g)throw new RangeError("invalid argument. Output string length exceeds maximum allowed string length.");return(n=(r-e.length)/i.length)<=0?e:(n=o(n),s(i,n)+e)}var l=u;export default l; //# sourceMappingURL=left-pad.js.map