MCPcopy Index your code
hub / github.com/vercel/hyper / createPadding

Function createPadding

bin/yarn-standalone.js:13016–13027  ·  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. * @returns {string}

(length, chars)

Source from the content-addressed store, hash-verified

13014 * @returns {string} Returns the padding for `string`.
13015 */
13016 function createPadding(length, chars) {
13017 chars = chars === undefined ? ' ' : baseToString(chars);
13018
13019 var charsLength = chars.length;
13020 if (charsLength < 2) {
13021 return charsLength ? baseRepeat(chars, length) : chars;
13022 }
13023 var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));
13024 return hasUnicode(chars)
13025 ? castSlice(stringToArray(result), 0, length).join('')
13026 : result.slice(0, length);
13027 }
13028
13029 /**
13030 * 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