zhf.sleep
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

本项目是基于 https://github.com/zhouhuafei/npm-publish-ts/tree/build-ts-use-gulp-babel 项目改造

使用案例

import { sleep } from 'zhf.sleep'

async function fn () {
  await sleep(3000) // 异步延时3秒
  console.log('3秒后会打印这条日志')
}

fn()

// 清理定时器,如此,3秒后则不会打印上述日志。
// clearTimeout(sleep.timer)
import { sleep } from 'zhf.sleep'

let timer = null
async function fn () {
  const promise = sleep(3000)
  timer = sleep.timer
  await promise // 异步延时3秒
  console.log('3秒后会打印这条日志')
}

fn()

// 清理定时器,如此,3秒后则不会打印上述日志。
// clearTimeout(timer)

Readme

Keywords

none

Package Sidebar

Install

npm i zhf.sleep

Weekly Downloads

1

Version

1.0.2

License

ISC

Unpacked Size

3.28 kB

Total Files

4

Last publish

Collaborators

  • zhouhuafei