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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@nick-wilde/jshelper

v1.2.1

Published

提供常用的JavaScript工具类和方法

Downloads

10

Readme

@nick-wilde/JSHelper

封装JavaScript中一些常见的功能,如类型判断、数据请求/下载、深浅拷贝、GUID生成等

使用

npm i @nick-wilde/jshelper

主要类说明

JSHelper

提供众多常见的静态工具方法,如数据类型判定、请求发送、数组深度检测等

MathHelper

提供常用的数学方法,例如平面几何解算、贝塞尔曲线等

Animation

基于requrstAnimationFrame的动画控制类

API

Table of Contents

JSHelper

Meta

  • author: nick

IsNumber

判断给定参数是否是数值类型

Parameters
  • obj any

Returns Boolean

IsString

判断给定参数是否是字符类型

Parameters
  • obj any

Returns Boolean

IsBoolean

判断给定参数是否是布尔类型

Parameters
  • obj any

Returns Boolean

IsObject

判断给定参数是否是Object类型

Parameters
  • obj any

Returns Boolean

IsUndefined

判断给定参数是否是undefined

Parameters
  • obj any

Returns Boolean

IsNull

判断给定参数是否是null

Parameters
  • obj any

Returns Boolean

IsFunction

判断给定参数是否是函数(不包括异步函数)

Parameters
  • obj any

Returns Boolean

IsAsyncFunction

判断给定参数是否是异步函数

Parameters
  • obj any

Returns Boolean

IsArray

判断给定参数是否是数组类型

Parameters
  • obj any

Returns Boolean

IsInteger

判断给定参数是否是整数

Parameters
  • obj any

Returns Boolean

ToRadian

将角度转换为弧度

Parameters

Returns Number

ToAngle

将弧度转换为角度

Parameters

Returns Number

ToDFM

将角度(度)拆分为度分秒

Parameters
  • angle Number
  • decimalsForSeconds Interger 秒组件保留的小数位数 (optional, default 0)

Returns Array<Number>

ToDegrees

将度分秒转换为度

Parameters
  • degrees Number
  • minutes Number
  • seconds Number
  • decimals Integer (optional, default undeifned)

Returns any

Clamp

将返回值限定在指定数值范围之内(右边界可取)

Parameters

Returns Number

RequestAsync

异步ajax请求

Parameters
  • url String http数据链接
  • method String HTTP方法,目前支持:"GET","POST"
  • responseType String 返回类型,目前支持:"", "text", "json", "document", "arraybuffer", "blob"
  • params String? POST参数,形如查询字符串参数

Returns any

DownLoadObj

将JS对象下载为文件

Parameters
  • obj any
  • fileName String 保存的文件名

GetElement

根据id或element返回html element 实例(若指定id的dom不存在,则创建)

Parameters

Returns any

DeepClone

深度拷贝对象

Parameters
  • data any 要深度拷贝的源数据
  • skipFun Boolean 标识克隆时是否跳过函数类型成员

Returns any

GenerateGUID

生成GUID

Returns String

GetArrayDepth

获取数组深度(仅检查第一项)

Parameters
  • arr Array 待检测数组
  • depth Integer? 深度起始值

Returns Integer

Defined

判定对象是否非空(undefined+null判断)

Parameters
  • value any

Returns any

GetQueryParams

从url链接获取查询参数键值对

Parameters

Returns Object

MathHelper

Meta

  • author: nick

Factorial

计算阶乘值

Parameters
  • value Interger

Returns Interger

Distance

计算两点的直线距离

Parameters

Returns Number

MidPoint

获取p1、p2中点

Parameters

Returns Array<Number>

PointOnExtendedLine

获取p1->p2延长线上点

Parameters

Returns Array<Number>

BiSectorPoint

获取角p1p3p2 的角平分线在p1-p2上的交点

Parameters

Mix

在a,b之间返回线性插值结果. 推广到二维空间就是一阶贝塞尔曲线

Parameters
  • a Number Specify the start of the range in which to interpolate.
  • b Number Specify the end of the range in which to interpolate.
  • ratio Number Specify the value to use to interpolate between x and y. 值域:[0,1]

Returns any

BesselSquarePoints

获取二阶贝塞尔曲线点集

Parameters

Returns Array<Array<Number>>

BesselCubicPoints

获取三阶贝塞尔点集

Parameters

Returns Array<Array<Number>>

BesselPoints

获取贝塞尔点集(自动适配阶数)

Parameters

Returns Array<Array<Number>>