当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript lodash.padStart函数代码示例

本文整理汇总了TypeScript中lodash.padStart函数的典型用法代码示例。如果您正苦于以下问题:TypeScript padStart函数的具体用法?TypeScript padStart怎么用?TypeScript padStart使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了padStart函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: msToTime

export function msToTime(ms: number) {
  if (isNumber(ms)) {
    const d = duration(ms);
    const h = padStart(d.hours().toString(), 2, "0");
    const m = padStart(d.minutes().toString(), 2, "0");
    return `${h}:${m}`;
  } else {
    return "00:01";
  }
}
开发者ID:FarmBot,项目名称:Farmbot-Web-API,代码行数:10,代码来源:utils.ts

示例2: handler

export async function handler(context: Context) {
  const { schemaPath } = await context.getProjectConfig()
  if (!schemaPath) {
    throw new Error('No `schemaPath` found in GraphQL config file.')
  }

  const relativeSchemaPath = relative(process.cwd(), schemaPath)

  if (!existsSync(schemaPath)) {
    console.log(
      chalk.yellow("Schema file doesn't exist at ") +
        chalk.blue(relativeSchemaPath),
    )
    return
  }

  const extensions = {
    schemaPath: relativeSchemaPath,
    ...getSchemaExtensions(schemaPath),
  }
  const maxLength = _(extensions)
    .keys()
    .map('length')
    .max()

  for (let name in extensions) {
    const padName = _.padStart(name, maxLength)
    console.log(`${padName}\t${chalk.blue(extensions[name])}`)
  }

  if (Object.keys(extensions).length === 0) {
    return
  }
}
开发者ID:koddsson,项目名称:graphql-cli,代码行数:34,代码来源:schema-status.ts

示例3: create

  static create(opts) {
    opts = opts || {};

    const x = new Notification();

    x.version = '1.0.0';
    const now = Date.now();

    x.createdOn = Math.floor(now / 1000);
    x.id = _.padStart(now.toString(), 14, '0') + _.padStart(opts.ticker || 0, 4, '0');
    x.type = opts.type || 'general';
    x.data = opts.data;
    x.walletId = opts.walletId;
    x.creatorId = opts.creatorId;

    return x;
  }
开发者ID:bitpay,项目名称:bitcore,代码行数:17,代码来源:notification.ts

示例4: Promise

  return new Promise(resolve => {
    const notes = path.resolve(__dirname, `../src/notes/${topic}`)
    const note = path.join(notes, `${dateFns.format(date, 'yyyy-MM-dd')}--${padStart(String(count), 2, '0')}`)

    fs.access(note, fs.constants.F_OK, async err => {
      if (err) return resolve(note)
      return resolve(await uniqueNote(topic, date, count + 1))
    })
  })
开发者ID:jeremyboles,项目名称:jeremyboles.com,代码行数:9,代码来源:import.ts

示例5: linewrap

 const lines = items.map(i => {
   let left = i[0]
   let right = i[1]
   if (!right) {
     return left
   }
   left = `${padStart(left, maxLength)}`
   right = linewrap(maxLength + 2, right)
   return `${left}    ${right}`
 })
开发者ID:dhruvcodeword,项目名称:prisma,代码行数:10,代码来源:Help.ts

示例6: runNumber

async function runNumber(scriptNumber: string) {
	const prefix = padStart(scriptNumber, 2, '0') + '-';
	const script = scripts.find(filename => filename.startsWith(prefix));
	if (!script) {
		throw new Error('No script found starting with ' + prefix);
	}
	await bootstrapDatabase();
	logger.info(null, '[migrate] Executing migrating script %s...', script);
	const migrate = require(resolvePath(scriptFolder, script));
	await migrate.up();
}
开发者ID:freezy,项目名称:node-vpdb,代码行数:11,代码来源:migrate.ts

示例7: padStart

export const DebugTiming = (label?: string) => (target: any, propertyKey: string, descriptor: PropertyDescriptor) => {
  const fn = descriptor.value;
  label = padStart(label ? label : getMethodName(target, propertyKey), 50);
  descriptor.value = function() {
    const start = now();
    const result = fn.apply(this, arguments);
    const delta = now() - start;
    log(`${label} ${delta} ms`);
    return result;
  };
};
开发者ID:mizzy,项目名称:deck,代码行数:11,代码来源:debug.ts

示例8: parse

  public async parse($: any): Promise<ParserResponseInterface> {
    const downloadResponse: ParserResponseInterface = { text: [] };
    downloadResponse.links = [];

    let items = $('.synopsis .syn-body');
    if (items.length === 0) {
      items = $('.musicList');
    }

    const itemsList: any[] = [];
    items.each((i, item) => {
      itemsList.push(item);
    });

    let i = 0;
    for (const item of itemsList) {
      i += 1;

      let link = $(item).find('h2 a');
      if (link.length === 0) {
        link = $(item).find('.fileTitle a');
      }

      const subtitle = $(item).find('.contextTitle');

      let title = '';
      title = $(link).text();

      if (subtitle.length) {
        title = $(subtitle).text() + ' - ' + title;
      }

      downloadResponse.links.push({
        link: $(link).attr('href'),
        number: padStart(String(i), 3, '0'),
        title,
        title_pinyin: (await pinyinConverter.toPinyin(title.split(' ')))
          .map(item => {
            if (!isChinese(item.ideogram)) {
              return item.pinyin.split('').join(String.fromCharCode(160));
            }

            const pinyinSeparated = separatePinyinInSyllables(item.pinyin);

            return pinyinSeparated.join(String.fromCharCode(160));
          })
          .join(String.fromCharCode(160)),
      });
    }

    return downloadResponse;
  }
开发者ID:pierophp,项目名称:pinyin,代码行数:52,代码来源:summary.parser.ts

示例9: getTimerBucket

export function getTimerBucket(expiration: number, length: number): string {
  const delta = expiration - Date.now();
  if (delta < 0) {
    return '00';
  }
  if (delta > length) {
    return '60';
  }

  const bucket = Math.round(delta / length * 12);

  return padStart(String(bucket * 5), 2, '0');
}
开发者ID:WhisperSystems,项目名称:Signal-Desktop,代码行数:13,代码来源:timer.ts

示例10: padStart

export const DebugTimingCumulative = (label?: string, logInterval = 5000) => (target: any, propertyKey: string, descriptor: PropertyDescriptor) => {
  const fn = descriptor.value;
  let count = 0;
  label = padStart(label ? label : getMethodName(target, propertyKey), 50);
  let cumulativeTime = 0;
  setInterval(() => log(`${label} ${padStart('' + count, 10)} calls in ${cumulativeTime} ms`), logInterval);
  descriptor.value = function() {
    count++;
    const start = now();
    const result = fn.apply(this, arguments);
    cumulativeTime += (now() - start);
    return result;
  }
};
开发者ID:jcwest,项目名称:deck,代码行数:14,代码来源:debug.ts

示例11: sample

const CONTACTS = COLORS.map((color, index) => {
  const title = `${sample(['Mr.', 'Mrs.', 'Ms.', 'Unknown'])} ${color} 🔥`;
  const key = sample(['name', 'profileName']) as string;
  const id = `+1202555${padStart(index.toString(), 4, '0')}`;

  const contact = {
    color,
    [key]: title,
    id,
    type: 'private',
  };

  return parent.ConversationController.dangerouslyCreateAndAdd(contact);
});
开发者ID:VetoPlayer,项目名称:Signal-Desktop,代码行数:14,代码来源:StyleGuideUtil.ts

示例12: padStart

  return venues.filter(([, venue]) => {
    const start = time * 100;
    const dayAvailability = venue.find((availability) => availability.day === SCHOOLDAYS[day]);
    if (!dayAvailability) return true;

    // Check that all half-hour slots within the time requested are vacant
    for (let i = 0; i < duration * 2; i++) {
      const timeString = padStart(String(start + hourDifference[i]), 4, '0');
      if (dayAvailability.availability[timeString] === OCCUPIED) {
        return false;
      }
    }

    return true;
  });
开发者ID:nusmodifications,项目名称:nusmods,代码行数:15,代码来源:venues.ts

示例13: notesDataAndKeysoundsDataForBmsonAndTiming

function notesDataAndKeysoundsDataForBmsonAndTiming(
  bmson: Bmson,
  timing: BMS.Timing
) {
  let nextKeysoundNumber = 1
  let beatForPulse = beatForPulseForBmson(bmson)
  let notes = []
  let keysounds: { [keysoundId: string]: string } = {}
  let soundChannels = soundChannelsForBmson(bmson)
  if (soundChannels) {
    for (let { name, notes: soundChannelNotes } of soundChannels) {
      let sortedNotes = _.sortBy(soundChannelNotes, 'y')
      let keysoundNumber = nextKeysoundNumber++
      let keysoundId = _.padStart('' + keysoundNumber, 4, '0')
      let slices = utils.slicesForNotesAndTiming(soundChannelNotes, timing, {
        beatForPulse: beatForPulse,
      })

      keysounds[keysoundId] = name

      for (let { x, y, l } of sortedNotes) {
        let note: BMS.BMSNote = {
          column: getColumn(x),
          beat: beatForPulse(y),
          keysound: keysoundId,
          endBeat: undefined,
        }
        if (l > 0) {
          note.endBeat = beatForPulse(y + l)
        }
        let slice = slices.get(y)
        if (slice) {
          Object.assign(note, slice)
          notes.push(note)
        }
      }
    }
  }
  return { notes, keysounds }
}
开发者ID:bemusic,项目名称:bemuse,代码行数:40,代码来源:index.ts

示例14: moment

export const getSuggestedFilename = ({
  attachment,
  timestamp,
  index,
}: {
  attachment: Attachment;
  timestamp?: number | Date;
  index?: number;
}): string => {
  if (attachment.fileName) {
    return attachment.fileName;
  }

  const prefix = 'signal-attachment';
  const suffix = timestamp
    ? moment(timestamp).format('-YYYY-MM-DD-HHmmss')
    : '';
  const fileType = getFileExtension(attachment);
  const extension = fileType ? `.${fileType}` : '';
  const indexSuffix = index ? `_${padStart(index.toString(), 3, '0')}` : '';

  return `${prefix}${suffix}${indexSuffix}${extension}`;
};
开发者ID:WhisperSystems,项目名称:Signal-Desktop,代码行数:23,代码来源:Attachment.ts

示例15: create

  static create(opts) {
    opts = opts || {};

    const x = new Email();

    x.version = 2;
    const now = Date.now();
    x.createdOn = Math.floor(now / 1000);
    x.id = _.padStart(now.toString(), 14, '0') + Uuid.v4();
    x.walletId = opts.walletId;
    x.copayerId = opts.copayerId;
    x.from = opts.from;
    x.to = opts.to;
    x.subject = opts.subject;
    x.bodyPlain = opts.bodyPlain;
    x.bodyHtml = opts.bodyHtml;
    x.status = 'pending';
    x.attempts = 0;
    x.lastAttemptOn = null;
    x.notificationId = opts.notificationId;
    x.language = opts.language || 'en';
    return x;
  }
开发者ID:bitpay,项目名称:bitcore,代码行数:23,代码来源:email.ts


注:本文中的lodash.padStart函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。