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

@edwardxyt/gws-javascripts

v1.0.27

Published

utils function class tool

Downloads

7

Readme

Browser: @edwardxyt/gws-javascripts

用于nodejs 常用工具类。

Installation

npm install @edwardxyt/gws-javascripts

Usage

import gwsJS from "@edwardxyt/gws-javascripts";

Methods

arraySort(arr)

数组排序

Example:
import {ArraySort} from "@edwardxyt/gws-javascripts";
let {bubbleSort} = new ArraySort();

// 冒泡排序
bubbleSort([1,2,3]).then(data => {
    console.log(data)
})
Components

动态组件 具体请看 @edwardxyt/gws-components

Example:
import { Components } from '@edwardxyt/gws-javascripts';

Components.showAlert('URL中没有获取到 fincId');
Cache

简单的内存缓存

Example:

创建实例

    import { Cache } from '@edwardxyt/gws-javascripts'

    let cache = new Cache()

set get

set 通过一个key 设置value和有效期


    import { Cache } from '@edwardxyt/gws-javascripts';

    let cache = new Cache();

    cache.set('key', 'value', 10);
    // => null

    cache.get('key');
    // => 'value'

    // ... 10s 后
    cache.get('key');
    // => null
DOMReady

监听浏览器DOM加载状态, 一旦DOM加载完成, 立即执行, 跟jQuery.ready方法相同

Example:
    import { DOMReady } from '@edwardxyt/gws-javascripts'

    DOMReady(()=>{
        // 会在DOM加载完成之后再执行
        somethine()
    })
NativeBridge

当前网页嵌入到App中, 需要与app通信时, 需要调用这个方法

Example:
    import { NativeBridgeFactory } from '@edwardxyt/gws-javascripts';

    let receive_handler = function(receive_data){
        console.log(receive_data) // => {type: '', value: ''}
        // use this method receive data from App
    };

    const NativeBridge = new NativeBridgeFactory('Easyloan888');
    // 设置接受来自App的方法
    NativeBridge.onReceive(data => (){
        console.log(data)
    })

    NativeBridge.trigger('close'); // 关闭当前webview
    NativeBridge.toNative('coupon'); // 到app原生的优惠券页面
rules

正则集合

Example:
    import { rules } from '@edwardxyt/gws-javascripts'
    // ... code
    <FormItem
        {...formItemLayout}
        label="真实姓名"
    >
        {getFieldDecorator('realName', {
            initialValue: current.realName,
            rules: [
                {
                    required: true,
                    message: '必填!',
                },
                {
                    pattern: rules.realNameReg,
                    message: rules.realNameMsg,
                },
            ],
        })(<Input placeholder="请输入真实姓名!" />)}
    </FormItem>
    // ...code