1.0.2 • Published 8 months ago

zhf.sleep v1.0.2

Weekly downloads
-
License
ISC
Repository
github
Last release
8 months ago

本项目是基于 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)
1.0.2

8 months ago

1.0.1

8 months ago

1.0.0

8 months ago