MCPcopy Index your code
hub / github.com/deployd/deployd / createPadding

Function createPadding

test-app/public/sinon.js:15905–15916  ·  view source on GitHub ↗

* Creates the padding for `string` based on `length`. The `chars` string * is truncated if the number of characters exceeds `length`. * * @private * @param {number} length The padding length. * @param {string} [chars=' '] The string used as padding.

(length, chars)

Source from the content-addressed store, hash-verified

15903 * @returns {string} Returns the padding for `string`.
15904 */
15905 function createPadding(length, chars) {
15906 chars = chars === undefined ? ' ' : baseToString(chars);
15907
15908 var charsLength = chars.length;
15909 if (charsLength < 2) {
15910 return charsLength ? baseRepeat(chars, length) : chars;
15911 }
15912 var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));
15913 return hasUnicode(chars)
15914 ? castSlice(stringToArray(result), 0, length).join('')
15915 : result.slice(0, length);
15916 }
15917
15918 /**
15919 * Creates a function that wraps `func` to invoke it with the `this` binding

Callers 3

padFunction · 0.85
padEndFunction · 0.85
padStartFunction · 0.85

Calls 6

baseToStringFunction · 0.85
baseRepeatFunction · 0.85
stringSizeFunction · 0.85
hasUnicodeFunction · 0.85
castSliceFunction · 0.85
stringToArrayFunction · 0.85

Tested by

no test coverage detected