npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@youngbeen/angle-ctrl

v2.0.2

Published

The controllers used in angle-FE team

Downloads

3

Readme

@youngbeen/angle-ctrl

[TOC]

timeCtrl

引用

import { timeCtrl } from '@youngbeen/angle-ctrl'

倒计时控制器 countDown

timeCtrl.countDown({
  total: 60,
  step: 1000
}, tick: <function>, end: <function>)
  • total参数可选,代表倒计时的总次数,默认60次
  • step参数可选,代表倒计时的步长(单位ms),默认1000ms
  • tick参数可选,代表每次计时触发的回调方法,默认空
  • end参数可选,代表倒计时结束触发的回调方法,默认空
timeCtrl.countDown({
  total: 30,
  step: 2000
}, tick (data) {
  console.log('ticking')
  console.log(data) // { leftCount: 30 }
}, end (data) {
  console.log('ticking end')
  console.log(data) // { leftCount: 0 }
})

正计时控制器 countUp

timeCtrl.countUp({
  start: 0,
  total: 60,
  step: 1000
}, tick: <function>, end: <function>)
  • start参数可选,代表正计时起始计数,默认0
  • total参数可选,代表正计时结束计数,默认60
  • step参数可选,代表正计时的步长(单位ms),默认1000ms
  • tick参数可选,代表每次计时触发的回调方法,默认空
  • end参数可选,代表计时结束触发的回调方法,默认空
timeCtrl.countUp({
  start: 10,
  total: 30
},tick (data) {
  console.log('counting')
  console.log(data) // { count: 10 }
}, end (data) {
  console.log('counting end')
  console.log(data) // { count: 30 }
})

debugCtrl

引用

import { debugCtrl } from '@youngbeen/angle-ctrl'

调试打印输出 log

debugCtrl.log(info, {
  isSave: false,
  line: '',
  compName: '',
  funcName: '',
  attach: ''
})
  • info参数必选,代表信息内容
  • isSave参数可选,代表是否同步记录到前端日志,默认false不记录到前端日志
  • line参数可选,代表信息来源的行数,默认空
  • compName参数可选,代表信息来源的组件名称,默认空
  • funcName参数可选,代表信息来源的方法名称,默认空
  • attach参数可选,代表信息附加的额外信息,默认空

该方法始终会在控制台打印出信息,并且当前如果开启了严格调试模式,则会使用弹框方式显示信息

debugCtrl.log('一条普通的消息,不会记录到日志中', {
  isSave: false
})
debugCtrl.log('这条信息会被记录到前端日志', {
  isSave: true,
  line: 211,
  compName: 'HelloWorld',
  funcName: 'showMsg',
  attach: 'just a tag'
})

调试打印警告 warn

debugCtrl.warn(info, {
  line: '',
  compName: '',
  funcName: '',
  attach: ''
})
  • info参数必选,代表警告信息内容
  • line参数可选,代表信息来源的行数,默认空
  • compName参数可选,代表信息来源的组件名称,默认空
  • funcName参数可选,代表信息来源的方法名称,默认空
  • attach参数可选,代表信息附加的额外信息,默认空

该方法始终会在控制台打印出警告信息,并且当前如果开启了调试模式,则会使用弹框方式显示信息。另外,该方法打印信息始终会记录到前端日志中。

debugCtrl.warn('发生了一个XXX错误')
debugCtrl.warn('这条警告包含了一些详细信息', {
  line: 211,
  compName: 'HelloWorld',
  funcName: 'showMsg',
  attach: '后台数据缺失'
})

调试打印错误 error

debugCtrl.error(info, {
  line: '',
  compName: '',
  funcName: '',
  attach: ''
})
  • info参数必选,代表错误信息内容
  • line参数可选,代表信息来源的行数,默认空
  • compName参数可选,代表信息来源的组件名称,默认空
  • funcName参数可选,代表信息来源的方法名称,默认空
  • attach参数可选,代表信息附加的额外信息,默认空

该方法始终会在控制台打印出警告信息,并且当前如果开启了调试模式,则会使用弹框方式显示信息。另外,该方法打印信息始终会记录到前端日志中,并随后上报发送所有已记录的前端日志

debugCtrl.error('发生了一个XXX严重错误')
debugCtrl.error('这条错误包含了一些详细信息', {
  line: 211,
  compName: 'HelloWorld',
  funcName: 'showMsg',
  attach: '后台无响应'
})

开启调试模式 debugOn

debugCtrl.debugOn(mode)
  • mode参数可选,代表debug模式,可选值 1 - 普通debug模式(会弹框显示warn,error的信息), 2 - 严格debug模式(会弹框显示所有log,warn,error类型消息),默认1普通debug模式
debugCtrl.debugOn() // 开启了普通debug模式
debugCtrl.debugOn(2) // 开启了严格debug模式

关闭调试模式 debugOff

debugCtrl.debugOff() // 关闭debug模式

开启错误自动上报 autoReportOn

debugCtrl.autoReportOn()

关闭错误自动上报 autoReportOff

debugCtrl.autoReportOff() // 关闭错误自动上报

获取已暂存的日志 getLog

let logs = debugCtrl.getLog()

点击触发调试 cheatDebugClick

debugCtrl.cheatDebugClick(count, interval)
  • count参数必选,代表需要连续点击多少次目标触发调试
  • interval参数可选,代表连续点击可接受的时间间隔最大值,默认1000ms
if (debugCtrl.cheatDebugClick(10)) {
  // 目标被连续点击10次触发开启调试
  debugCtrl.debugOn(2)
}
if (debugCtrl.cheatDebugClick(5, 1000)) {
  // 目标被连续点击5次触发开启调试
}

clipboard

引用

import { clipboard } from '@youngbeen/angle-ctrl'

复制内容到剪贴板 copy

clipboard.copy(content: string): boolean
  • content参数必选,代表复制的内容
clipboard.copy('hello world!')