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

@dsh-prose/utils

v0.0.7

Published

js utils

Downloads

2

Readme

原生 js 工具包

dom 文件

  1. classListAdd SVG 元素添加类名

    function classListAdd(dom: SVGElement, className: string): void;
  2. findParentNode 找到子节点对应的父节点并返回

    function findParentNode(currentTarget: HTMLElement | null, parentClassName: string): HTMLElement | null;
  3. 引入

    import { classListAdd } from '@dsh-prose/utils/lib/dom';

slideTo 文件

  1. easeInOutCubic ease-in-out 贝塞尔曲线

    function easeInOutCubic(t: number, b: number, c:  number, d: number): number;
  2. slideTo ease-in-out 动画

    type SetPrevent = () => void; // 停止继续执行回调
    interface SlideToProps {
      movingTime?: number; // 移动时间
      startPos: number; // 开始位置
      endPos: number; // 结束位置
      chunkCallback?: (nextScrollTop: number) => void; // 单次移动的回调
      completeCallback?: (endPos: number) => void; // 移动完成的回调
    }
    function slideTo(props: SlideToProps): SetPrevent;
  3. 引入

    import { slideTo } from '@dsh-prose/utils/lib/slideTo';

utils 文件

  1. r2a 弧度转角度

    function r2a(r: number): number;
  2. inclinedAngle 计算两点形成的直线与水平线的夹角

    interface Doc { // 点的信息
      x: number
      y: number
    }
    function inclinedAngle(start: Doc, end: Doc): number;
  3. exclude 排除对象中指定的值

    function exclude(object: AnyObject, excludeKey: string[] | string): AnyObject;
  4. preventDefault 阻止默认事件

    function preventDefault(event: TouchEvent | MouseEvent): boolean;
  5. getLastClientPos 获取鼠标/当前元素最后一根手指的位置

    function getLastClientPos(event: TouchEvent | MouseEvent): { clientX: number, clientY: number };
  6. getLastEventId 获取鼠标/当前元素最后一根手指的 id

    function getLastEventId(event: TouchEvent | MouseEvent): number;
  7. withinRange 将数字控制在范围内,超过取最大值,小于取最小值,如果传入的最大值小于最小值则不作计算,直接返回原始值

    function withinRange(number: number, min: number, max: number): number;
  8. getFractionalPart 拿出指定位数的小数

    function getFractionalPart(number: number, decimals?: number): string;
  9. getBrowserVersion 浏览器版本

    function getBrowserVersion(): 'IE' | null;
  10. isPC 是否为 PC 端

    function isPC(): boolean;
  11. 引入

    import { r2a } from '@dsh-prose/utils/lib/utils';