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 🙏

© 2026 – Pkg Stats / Ryan Hefner

s-utils-js

v1.0.1

Published

前端工具集合

Readme

s-utils-js

介绍

前端工具集合 持续迭代中...

安装

yarn add s-utils-js --save
# OR
npm install s-utils-js --save

升级

yarn upgrade s-utils-js
# OR
npm update s-utils-js

全局调用 main 文件

import * as sUtilsJs from 's-utils-js';
Vue.prototype.$sUtilsJs = sUtilsJs;

页面调用

import { getDate } from "s-utils-js";

使用

getDate()

参数

| 方法名称 | 调用名称 | 说明 | 参数 | | ---- | ---- | ---- | ---- | | 日期时间 | getDate | 获取当前时间 & 之后的时间详细 & 时间戳 | 非必填 0=当前时间 1=明天 2=后天 以此累加 | | 整数添加小数点后两位 | getFloat | 整数添加小数点后两位 | 转换的值 {Number , String} | | 截取参数 | getQueryString | 截取参数 | 参数名 {String} | | 追加url参数 | appendQuery | 追加url参数 | [地址:{String},参数名:{String},参数值:{}] | | 添加千位分隔符 | milliFormat | 添加千位分隔符 | 值 {Number} | | 动态引入js | injectScript | 动态引入js | 地址 {String} | | 根据url地址下载 | download | 根据url地址下载 | 地址 {String} | | el是否包含某个class | hasClass | el是否包含某个class | [节点 {Objct},class名称 {String}] | | el添加某个class | addClass | el添加某个class | [节点 {Objct},class名称 {String}] | | el去除某个class | removeClass | el去除某个class | [节点 {Objct},class名称 {String}] | | 获取滚动的坐标 | getScrollPosition | 获取滚动的坐标 | 节点 {Objct} | | 滚动到顶部 | scrollToTop | 滚动到顶部 | - | | el是否在视口范围内 | elementIsVisibleInViewport | el是否在视口范围内 | [节点 {Objct},视图 {Objct}] | | 洗牌算法随机 | shuffle | 洗牌算法随机 | 值{Array} | | 随机数范围 | random | 随机数范围 | [最小{Number},最大{Number}] | | 将阿拉伯数字翻译成中文的大写数字 | numberToChinese | 将阿拉伯数字翻译成中文的大写数字 | 值{Number} | | 将数字转换为大写金额 | changeToChinese | 将数字转换为大写金额 | 值{Number} | | 数组排序 | sort | 数组排序 | 值{Number}(1=从小到大,2=从大到小,3=随机) | | 数组去重 | unique | 数组去重 | 值{Array} | | 求两个集合的并集 | union | 求两个集合的并集 | [值{Array},值{Array}]| | 求两个集合的交集 | intersect | 求两个集合的交集 | [值{Array},值{Array}]| | 数组删除其中一个元素 | remove | 数组删除其中一个元素 | [值{Array},值{}]| | 将类数组转换为数组 | formArray | 将类数组转换为数组 | 值{Array} | | 去空格 | trim | 前后&所有&前&后 | [值{String},状态{Number}(1=所有空格,2=前后空格,3=前空格,4=后空格)] | | 字符串转换 | changeCase | 字符串转换 | [值{String},状态{Number}(1=首字母大写,2=首字母小写,3=大小写转换,4=全部大写,5=全部小写)] | | 在字符串中插入新字符串 | insertStr | 在字符串中插入新字符串 | [原字符串{String},索引{Number},新字符串{String}] | | 16进制颜色转RGBRGBA字符串 | colorToRGB | 16进制颜色转RGBRGBA字符串 | [16进制颜色{String},透明度{Number}] |