MCPcopy Create free account
hub / github.com/zxlie/FeHelper / pad

Function pad

apps/json-format/format-lib.js:6–16  ·  view source on GitHub ↗
(source, length)

Source from the content-addressed store, hash-verified

4 */
5Date.prototype.format = function (pattern) {
6 let pad = function (source, length) {
7 let pre = "",
8 negative = (source < 0),
9 string = String(Math.abs(source));
10
11 if (string.length < length) {
12 pre = (new Array(length - string.length + 1)).join('0');
13 }
14
15 return (negative ? "-" : "") + pre + string;
16 };
17
18 if ('string' !== typeof pattern) {
19 return this.toString();

Callers 1

format-lib.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected