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

wtils

v0.2.0

Published

utils classes

Downloads

3

Readme

wtils

Introduction

常用的js工具类

Install

yarn add wtils

Usage

const wtils = require('wtils');
const platform = wtils.getOS();
console.log(platform);  // 获取平台

API

transFirstLetterToUpper

将传入的字符串首字母转换为大写。

|参数|描述| |---|---| |str|需要处理的字符串|

|返回值|描述| |---|---| |str|处理后的字符串|

使用:

wtils.transFirstLetterToUpper('index')  // Index

formatPrice

将传入的价格(字符串或数值)转换为字符串形式的两位小数。

|参数|描述| |---|---| |price|需要处理的价格值|

|返回值|描述| |---|---| |priceStr|格式化后的字符串|

使用:

wtils.formatPrice('22.3')   // '22.30'

showShareHints

展示引导点击右上角微信分享弹窗。

使用:

wtils.showShareHints()

isAfterNow

比较传入的时间是否晚于当前时间。

参数:无

|返回值|描述| |---|---| |isAfterNow| true - 晚于当前时间, false - 不晚于当前时间 |

返回值:true | false

sliceStrUntilDivider

从字符串开始到传入的分隔符剪切传入的字符串。

|参数|描述| |---|---| |str|字符串| |divider|分隔符|

|返回值|描述| |---|---| |str|剪切后的字符串, string|

getOS

判断当前浏览器运行环境。

|参数|描述| |---|---| |appSign|app标识|

|返回值|描述| |---|---| |str|当前浏览器运行环境, 'android'-安卓 'iOS'-iOS null-其他|

pumpFieldFromList

遍历数组,获取数组元素的某个属性,返回一个新数组。

|参数|描述| |---|---| |list|数组, Array| |field|需要抽取的字段名, string|

|返回值|描述| |---|---| |list|重新组装后的新数组, Array|

transParams

转换JSON格式字符串为url拼接字符串。

|参数|描述| |---|---| |params|json字符串格式参数|

|返回值|描述| |---|---| |paramStr|拼装后的参数字符串,可用于链接拼接, string|

verifyEleInArr

查找某个元素或值是否在数组中存在,如果存在则删除,否则push。

|参数|描述| |---|---| |list|数组| |value|查找的值| |field|用于比较的元素属性,如果不传则是直接比较数组item|

|返回值|描述| |arr|处理后的数组|

更新日志

点此前往

TODO

点此前往