MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / createPadding

Function createPadding

lib/web/jshint.js:5081–5091  ·  view source on GitHub ↗

* Creates the padding required for `string` based on the given `length`. * The `chars` string is truncated if the number of characters exceeds `length`. * * @private * @param {string} string The string to create padding for. * @param {number} [length=0] The padding length.

(string, length, chars)

Source from the content-addressed store, hash-verified

5079 * @returns {string} Returns the pad for `string`.
5080 */
5081 function createPadding(string, length, chars) {
5082 var strLength = string.length;
5083 length = +length;
5084
5085 if (strLength >= length || !nativeIsFinite(length)) {
5086 return '';
5087 }
5088 var padLength = length - strLength;
5089 chars = chars == null ? ' ' : (chars + '');
5090 return repeat(chars, ceil(padLength / chars.length)).slice(0, padLength);
5091 }
5092
5093 /**
5094 * Creates a function that wraps `func` and invokes it with the optional `this`

Callers 2

createPadDirFunction · 0.85
padFunction · 0.85

Calls 1

repeatFunction · 0.85

Tested by

no test coverage detected