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

@chongying-star/vaptcha-typescript

v1.1.0

Published

为Vaptcha提供在TypeScript中开发的良好体验。包括类型标注、功能二次封装等。

Downloads

30

Readme

Vaptcha TypeScript

✨ 为Vaptcha提供在TypeScript中开发的良好体验。 ✨

License Typescript NPM Download GitHub star

本项目将对Vaptcha中的对象进行类型标注,并对功能进行二次封装,以提高开发体验。

什么是Vaptcha?

VAPTCHA是“Variation Analysis based Public Turing Test to Tell Computers and Humans Apart”(基于变量分析来区分人类和计算机的图灵测试程序)的缩写,又称为手势验证码, 一种基于人工智能和大数据的人机验证解决方案 。用户仅需用鼠标绘制指定轨迹即可完成人机验证。VAPTCHA能有效防止恶意密码破解、论坛灌水、垃圾邮件、撞库等。

Vaptcha官网:https://www.vaptcha.com/

如何使用

使用原始对象(仅类型标注)

你可以直接标注全局函数:

import { GlobalFunction } from '@chongying-star/vaptcha-typescript';
declare global {
  interface Window {
    vaptcha: GlobalFunction;
  }
}
window.vaptcha({
  vid: '...'
}).then((obj) => {});
import { GlobalFunction } from '@chongying-star/vaptcha-typescript';
((window as any).vaptcha as GlobalFunction)({
  vid: '...'
}).then((obj) => {});

或者使用默认导出,它仅仅只是做了转发

import vaptcha from '@chongying-star/vaptcha-typescript';
vaptcha({
  vid: '...'
}).then((obj) => {});
// vaptcha == (...args) => window.vaptcha(...args)

使用包装对象

CyVaptcha类是对官方对象的最简包装,与官方对象使用方式完全相同。它是一个ES Class,支持扩展,允许使用instanceof关键字判断继承关系。

import { createVaptcha, CyVaptcha } from '@chongying-star/vaptcha-typescript';
createVaptcha({
  vid: '...',
  mode: 'invisible',
}).then((vaptcha) => {
  vaptcha instanceof CyVaptcha; // true
});

因此,可以通过扩展CyVaptcha类来实现更多的操作。

import { createVaptcha, CyVaptcha } from '@chongying-star/vaptcha-typescript';

class MyVaptcha extends CyVaptcha {
  myMethod () {
    this.vaptcha; // this.vaptcha 是被包装的官方对象 可以通过该对象进行操作
    // ...
  }
}

createVaptcha({
  vid: '...',
  mode: 'invisible',
}, MyVaptcha).then((vaptcha) => {
  vaptcha instanceof CyVaptcha; // true
  vaptcha instanceof MyVaptcha; // true
});

Api

Type CyVaptchaConfig

配置项

属性:

  • immediateRender
    • type: boolean
    • default: true 当为true且模式为点击式和嵌入式时,自动调用render方法

Function createVaptcha

构造封装后的Vaptcha对象

参数:

  1. option Vaptcha配置项
    • type: VaptchaOption
  2. CyVaptchaType 目标类型构造函数
    • type: 构造函数
    • default: undefined 当为undefined时构造函数为CyVaptcha
  3. overwriteConfig 自定义覆盖配置