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

better-burying-point

v1.0.2

Published

最好的埋点解决方案,埋点业务与业务代码分离,支持框架Vue、React、Angular、小程序、原生js等项目使用

Downloads

8

Readme

项目地址

github地址

Introduction

1、埋点业务与主业务进行解耦(代码分离),依赖装饰器实现

2、支持框架Vue、React、Angular、小程序、原生js等项目使用

3、@after在主程序执行完毕后,再执行@after所装饰的函数

4、主要为埋点服务,更可应用到其他业务场景中

Installation

# for Vue Angular React

npm install better-burying-point --save-dev
import { setModule, setSeparator, before, after } from 'better-burying-point';

Usage

用法一:
// main.js
import { setModule } from 'better-burying-point';
// 设置模块
setModule({
    home: {
        homePage(item, index) {
            console.log(this); // 与handlerEvent函数内部的this指向相同
        },
        clickBtn(staticParamOne, staticParamTwo, item, index) {},
        leave(staticParamOne, staticParamTwo, item, index) {}
    }
})

// home.js
import { before, after } from 'better-burying-point';
const obj = {
    @after('home.homePage')
    handlerEvent(item, index){
        console.log(this);
    },
    @after('home.clickBtn', staticParamOne, staticParamTwo) // 此处两个静态参数会与clickBtn函数的参数进行拼装,传递到home模块下clickBtn函数内
    clickBtn(item, index){
        console.log('点击');
    },
    @before('home.leave', staticParamOne, staticParamTwo)
    goLink() {
        window.loation.href = 'https://xxx.com.cn';
    }
}
用法二:按照模块化拆分
// bury/modules/home.js
export default {
    homePage(item, index) {
        console.log(this);
    }
}
// bury/modules/detail.js
export default {
    detailPage(item, index) {
        console.log(this);
    }
}
// bury/index.js
import home from './modules/home.js';
import detail from './modules/detail.js';
export default {
    home,
    detail
}

// 入口文件处设置 main.js
import { setModule } from 'better-burying-point';
import module from './bury/index';
setModule(module);


// home页面 使用
var home = {
    @after('home.homePage')
    handlerEvent(item, index){
        console.log(this);
    }
}

Options

setModule

Type: Function[Object]
设置拆分模块的对象,为页面访问使用,函数参数为对象

setSeparator

Type: Function[String]
Default: '.'
设置对象访问分隔符,函数参数为字符串,比如:home.leave;如果设置'/',访问home/leave

before

Type: Function[arg1 , arg2, arg3, ...]
before函数返回一个装饰器函数
第一个参数:必须为字符串,模块访问顺序 第二个参数:静态参数 ... 第n个参数:静态参数
【 备注:】主程序执行之前才执行装饰函数

after

Type: Function[arg1 , arg2, arg3, ...]
after函数返回一个装饰器函数
第一个参数:必须为字符串,模块访问顺序 第二个参数:静态参数 ... 第n个参数:静态参数
【 备注:】主程序执行之后才执行装饰函数

License

MIT