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

@sinoui/utils

v1.0.0

Published

[![npm version](https://img.shields.io/npm/v/@sinoui/utils)](https://www.npmjs.com/package/@sinoui/utils) [![downloads](https://img.shields.io/npm/dm/@sinoui/utils)](https://www.npmjs.com/package/@sinoui/utils)

Downloads

1,277

Readme

@sinoui/utils

npm version downloads

sinoui 工具库。

API

debounce

0.1.0

防抖函数的简易实现。与 lodash/debounce 类似。

import { debounce } from '@sinoui/utils';

const callback = () => console.log('update');
const debounced = debounce(callback);

// 执行
debounced();
// 取消执行
debounced.cancel();

方法类型:

function debounce(func: Function, [wait = 166]): Function;

参数:

| 参数名称 | 说明 | | -------- | -------------------------------------- | | func | 执行的回调函数 | | wait | 等待时长。单位是毫秒。默认为 166ms。 |

返回值:

返回包装后的函数。此函数还有一个 cancel 属性,执行 cancel(),可以取消 func 的执行。

animate

0.2.0

简单的动画执行函数。

import { animate } from '@sinoui/utils';

const handleUpdate = (currentValue) => console.log(currentValue);
const cancel = animate(0, 1000, 250, handleUpdate);

// 取消动画的执行
cancel();

方法类型:

function animate(
  start: number,
  end: number,
  duration: number,
  onUpdate: (currentValue: number) => void,
  easingFunction = linear,
): () => void;

参数:

| 参数名称 | 说明 | | -------------- | ------------------------------------------------------------------------------------------------------------------------------- | | start | 开始值 | | end | 结束值 | | duration | 动画时长 | | onUpdate | 动画过程中值发生变更的回调函数 | | easingFunction | 缓动函数。默认为线性缓动函数。可以在 js-easing-functions 找到更多缓动函数。 |

返回值:

返回可以取消动画执行的函数。执行此函数,则结束动画。

本地开发

项目中有以下可用的命令。

yarn start

在开发和监听模式下启动项目。当代码发生变化时就会重新编译代码。它同时会实时地向你汇报项目中的代码错误。

yarn build

打包,并将打包文件放在dist文件夹中。使用 rollup 对代码做优化并打包成多种格式(Common JSUMDES Module)。

yarn lint

yarn lint会检查整个项目是否有代码错误、风格错误。

开启 vscode 的 eslint、prettier 插件,在使用 vscode 编码时,就会自动修正风格错误、提示语法错误。

yarn format

yarn format可以自动调整整个项目的代码风格问题。

yarn test

yarn test以监听模式启动 jest,运行单元测试。

开启 vscode 的 jest 插件,会在文件变化时自动运行单元测试。