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

wt-utils

v1.4.1

Published

> npm i wt-utils -S > or > yarn add wt-utils

Downloads

9

Readme

前端工具库 wt-utils

安装 install

npm i wt-utils -S
or
yarn add wt-utils

使用 use

// all methods
import { $, wt, utils } from 'wt-utils'

// 模块化导入 以减少体积
import $, { css, val } from 'wt-utils/src/dom'
$.use({ css, val })

import wt, { set, values, keys } from 'wt-utils/src/data'
wt.use({ set, values, keys })

import { WStore, url, date, cookie } from 'wt-utils/src/utils'

所有的方法都可以单独导出 tree shaking,用最少的体积做事

$ 是一个轻量的前端 dom 操作库,10k 不到的体积,能够用类似 jq 的方法方便地开发小型页面

wt 是一个轻量级的数据处理库,你可以像这样调用 wt([1, 2, 3, 1, 2]).set(),也可以像这样调用方法 wt([1, 2, 3, 1, 2]).pipe('set'),pipe 方法可以传 n 个参数,每个参数为一个字符串表示已有的方法名,或者为一个回调函数,此回调函数返回一个当前对象的上下文,你可以在里面调用高阶函数。

METHODS 方法

  1. add
  1. set
  1. map
  1. extend
  1. copy
  1. use
  1. each
  1. pipe
  1. serialize
  1. dataReset
  1. keys
  1. values
  1. merge
  1. from
  1. json
  1. repeat
  1. replace
  1. isArr
  1. isObj
  1. isFunc
  1. isStr
  1. isNum
  1. isBoll
import { wt } from 'wt-utils'

const json = {
  id: 1, id: 2, id: 3,  id: 4, id: 1, id: 5
}

wt(json).pipe('values', 'set', ctx => ctx.map(v => v + 100))
// 先调用原型上的values方法得到[1, 2, 3, 4, 1, 5]
// 调用原型上的set方法得到[1, 2, 3, 4, 5]
// 传入一个回调函数将每个项加上100最终得到[101, 102, 103, 104, 105]

工具 utils

工具是一组工具的集合包括 cookie 的控制,date 日期格式化,具有兼容性的 promise,可以操作 sessionStorage 和 localStorage 的 WStore,可以操作 Url 的 url 等

import { WStore, url, date, cookie } from 'wt-utils/src/utils'
const myStore = new WStore('session')
myStore.set('a', {name: '张三'})
// localstorage中存入了 'a': "{"name", "张三"}"

尝试

如有时间,请下载本项目,然后运行 package.json 里面的'dev'脚本自行尝试