MCPcopy
hub / github.com/Kong/insomnia / createPadding

Function createPadding

packages/insomnia/bin/yarn-standalone.js:12927–12938  ·  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

12925 * @returns {string} Returns the padding for `string`.
12926 */
12927 function createPadding(length, chars) {
12928 chars = chars === undefined ? ' ' : baseToString(chars);
12929
12930 var charsLength = chars.length;
12931 if (charsLength < 2) {
12932 return charsLength ? baseRepeat(chars, length) : chars;
12933 }
12934 var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));
12935 return hasUnicode(chars)
12936 ? castSlice(stringToArray(result), 0, length).join('')
12937 : result.slice(0, length);
12938 }
12939
12940 /**
12941 * 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