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

util-list

v0.0.4

Published

Several util modules to optimise your project

Downloads

9

Readme

utilList

Several util modules to optimise your project

Author:Alan Chen

E-mail: [email protected]

version: 0.0.4

date: 2018/12/25

Feature

  • 包含DateFormat、EventBus、ArrayDel、Equal和InjectVue五个方法。
  • DateFormat是个极简的用于日期对象格式化字符串工具,如果需要Date原型链扩展请使用moment.js
  • EventBus是只适用于vue插件的工具,简化了官网推荐的event bus,用于跨组件传递事件。
  • ArrayDel扩展了Array原生的splice,更加符合大部分删除数组元素的使用场景。
  • Equal是个极简的用于判断变量是否严格相等工具,如果需要全数据类型比较,请使用lodash
  • 提供一个InjectVue工具,可以快速包装原生js方法,转换成vue插件的对象。

Component doc

Usage

  • yarn add util-list or npm install util-list --save 安装npm包
  • import引入
        import utilList from 'util-list' // 全部引入
        import { DateFormat, EventBus, ArrayDel, Equal, InjectVue } from 'util-list' // 单个引入
    
        DateFormat() // 原生js方法使用
    
        import Vue from 'vue' // 作为vue插件使用
        const DateUtil = InjectVue(DateFormat)
        Vue.use(DateUtil)
  • InjectVue方法提供第2个参数可选,默认为空,当提供第二个参数时,挂在vue.prototype上的方法名会被重置。例如:
        // main.js
        import Vue from 'vue'
    
        import { DateFormat, InjectVue } from 'util-list' 
        const DateUtil = InjectVue(DateFormat, 'format')
        Vue.use(DateUtil)
    
        // example.vue
        export default {
            created() {
                this.$_format('yy-MM-dd') // 方法名被重置为$_format
            }
        }

Attentions

  1. 模块导出的均为原生js方法(除EventBus以外),如果想在vue中Vue.use()使用,必须先用InjectVue()
  2. EventBus是vue插件,只能在vue中Vue.use()使用。