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

@hyhello/utils

v1.12.5

Published

前端常用工具函数库

Downloads

201

Readme

@hyhello/utils

介绍

前端常用工具函数库。查看在线文档

安装教程

npm install @hyhello/utils

Note: add --save if you are using npm < 5.0.0

使用说明

Use in a browser(CDN):

<!-- 引入库 -->
<script src="https://cdn.jsdelivr.net/npm/@hyhello/utils/lib/index.min.js"></script>
or
<script src="https://unpkg.com/@hyhello/utils/lib/index.min.js"></script>

Use In Node.js:

// Load the full build.
var utils = require('@hyhello/utils');

// Load method categories.
var isArray = require('@hyhello/utils/lib/isArray');
or
var { isArray } = require('@hyhello/utils');

Use In ES6:

// Load the full build.
import utils from '@hyhello/utils';

// Load method categories.
import isArray from '@hyhello/utils/lib/isArray';
or
import { isArray } from '@hyhello/utils';

按需引入

[!TIP] 从 V1.12.0 版本开始,如果您使用的构建工具支持 Tree shaking,您在使用 @hyhello/utils 库时将能够实现按需加载,无需进行任何额外配置。

Usage in babel

npm install babel-plugin-import --save-dev

Via .babelrc or babel-loader.

{
  "plugins": [["import", options]]
}

options can be object.

{
  "libraryName": "@hyhello/utils",
  "camel2DashComponentName": false,  // default: true
}

Usage in vite

npm install vite-plugin-imp --save-dev

Via vite.config.js.

import vitePluginImp from 'vite-plugin-img';

export default defineConfig({
    plugins: [vitePluginImp(options)]
});

options can be object.

{
  "libName": "@hyhello/utils",
  "libDirectory": "lib",
  "camel2DashComponentName": false
}

For example, the default behavior

import { isArray } from '@hyhello/utils';
↓ ↓ ↓ ↓ ↓ ↓
var isArray = require('@hyhello/utils/lib/isArray');

支持情况

Tested in Chrome 74-75, Firefox 66-67, IE 9, Edge 18, Safari 11-12.

注:采用 jest + jsdom 进行单元测试,报告如下:

  • Statements:98.96%
  • Branches:97.22%
  • Functions: 99.28%
  • Lines: 99.02%