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

sw-utils-library

v1.0.4

Published

前端工具函数和方法

Downloads

1

Readme

sw-utils-library

前端函数工具库

工具库还在完善中……

参考资料:

  1. micell
  2. utils-pro
  3. bbo
  4. rgutil
  5. just
  6. jtools
  7. fetools

介绍

sw-utils-library 是一个函数工具,包括数组处理、时间处理、dom 处理、对象处理、常用验证等函数

文件命名规范

函数工具方法文件命名统一采用驼峰式命名

查看文档

在线

http://yaoyao1987.gitee.io/sw-utils-library-docs/

本地

yarn run docs

安装

// yarn
yarn add sw-utils-library -S

// npm
npm install sw-utils-library -S

通过<script>标签来直接使用

指定版本:

<script src="dist/sw-utils-library.min.js"></script>

ES 模块版本

<script src="dist/sw-utils-library.esm.browser.js"></script>

使用

js

import { isAndroid } from 'sw-utils-library'
const isDeviceAndroid = isAndroid()

ts

import { sortArrItem } from 'sw-utils-library'
import { objType } from 'sw-utils-library/lib/array'
const temp: objType[] = [
  { name: 'zzx', score: 90, age: 12 },
  { name: 'lyy', score: 90, age: 5 },
  { name: 'zjf', score: 50, age: 10 },
]
//根据 score 排序,score 相同时根据 age 排序
sortArrItem(sortArrItem(temp, 'age', 0), 'score', 0)

打包

| 类型 | 文件名 | 功能 | | :--: | :-------------------------- | :------------------------------------------ | | cjs | sw-utils-library.cjs.js | CommonJS,适用于 Node 和 Browserify/Webpack | | cjs | sw-utils-library.cjs.min.js | CommonJS,适用于 Node 和 Browserify/Webpack | | umd | sw-utils-library.umd.js | 通用模块定义,以 amd,cjs 和 iife 为一体 | | umd | sw-utils-library.umd.min.js | 通用模块定义,以 amd,cjs 和 iife 为一体 | | esm | sw-utils-library.esm.js | 软件包保存为 ES 模块文件 | | esm | sw-utils-library.esm.min.js | 软件包保存为 ES 模块文件 |

依赖

Rollup

| 插件名 | 来源 | 说明 | | :-: | :-: | :-- | | rollup-plugin-terser | 社区 | 采用 Terser 压缩 JavaScript | | rollup-plugin-typescript2 | 社区 | ts 转 js 的编译器 | | @rollup/plugin-replace | 官方 | 自动替换文件中的环境变量 | | @rollup/plugin-node-resolve | 官方 | 提供打包引入库的功能 | | @rollup/plugin-commonjs | 官方 | 解决 rollup.js 无法识别 CommonJS 模块 | | @rollup/plugin-json | 官方 | 提供导入 json 文件功能 | | @rollup/babel | 官方 | 用于处理 es6 代码的转换,使转换出来的代码可以用于不支持 es6 的环境使用 |

Babel

| 依赖名 | 说明 | | :-------------------------------: | :------------------------ | | @babel/core | Babel 核心依赖 | | @babel/preset-env | Babel 默认预设 | | @babel/runtime | Babel helper 辅助函数依赖 | | @babel/runtime-corejs3 | Babel polyfill 填充库 | | @babel/plugin-transform-runtime | 对 Babel 各依赖联动管理 |

游览器兼容

IE9+
Edge 12+
Chrome 41+
Firefox 40+
Opera 28+