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

@fishx/utils

v5.0.10

Published

- dateUtils - isNil - isString

Downloads

401

Readme

fishx 工具类

  • dateUtils
  • isNil
  • isString

dateUtils

日期格式化工具

使用方法

import { dateUtils } from '@fishx/utils';
dateUtils.format(new Date(), 'yyyy-mm-dd');  // -》2019-01-02
dateUtils.parse('2019-01-02','yyyy-mm-dd');  // -》Date

格式字符串定义

yyyy : 4位数年份
yy : 2位数年份
MM : 月份全拼(英文),例如:January、March
M :月份缩写(英文),3个字母
mm : 月份,2位,小于10时前面补零
m : 月份,小于10时前面不补零
dd : 一个月中的第几天,小于10时前面补零
d : 一个月中的第几天,小于10时前面不补零
HH : 小时,2位,小于10时前面补零---12小时制
H : 小时,小于10时前面不补零---12小时制
hh : 小时,2位,小于10时前面补零---24小时制
h : 小时,小于10时前面不补零---24小时制
ii : 分钟,2位,小于10时前面补零
i : 分钟,小于10时前面不补零
ss :秒,2位,小于10时前面补零
s : 秒,小于10前面不补0
p : 上午还是下午,小写字母 ('am' 或 'pm')

方法

| 方法名 | 参数 | 返回值 | 备注 | | ---- | ---- | ----| ---- | | addYears | ( date, years ) | Date | 在指定的时间点上加上指定的年数 | | addMonths | ( date, months ) | Date | 在指定的时间点上加上指定的月数 | | addDays | ( date, days ) | Date | 在指定的时间点上加上指定的天数 | | addHours | ( date, hours ) | Date | 在指定的时间点上加上指定的小时数 | | addMinutes | ( date, minutes ) | Date | 在指定的时间点上加上指定的分钟数 | | format | ( date, format ) | String | 日期格式化 | | parse | ( date, format ) | Date | 日期解析 | | getDaysInMonth | ( year, month ) | Number | 返回指定年月中的天数 | | getStartOfDay | ( date) | Date | 获取一天的起始时间点 | | getEndOfDay | ( date) | Date | 获取一天的结束时间点 | | diffYears | (date1, date2) | Number | 返回两个日期相差的年数 | | diffMonths | (date1, date2) | Number | 返回两个日期相差的月数 | | diffDays | (date1, date2) | Number | 返回两个日期相差的日数 |

isNil

判断是否是null或者undefine isNil(null); => ture isNil(undefined); => ture

isString

判断是否是字符串 isString("abc"); => ture

cookieUtils

cookie操作工具

使用方法

import { cookieUtils } from '@fishx/utils';

cookieUtils.setCookie('fishx', 'thank you', 'd5') // 把fishx存入cookie,5天后过期
cookieUtils.setCookie('fishx', 'thank you', 'h5') // 把fishx存入cookie,5小时后过期
cookieUtils.setCookie('fishx', 'thank you', 's5') // 把fishx存入cookie,5秒后过期
cookieUtils.getCookie('fishx') // 从cookie中获取fishx的值
cookieUtils.delCookie('fishx') // 删除指定的cookie值

方法

| 方法名 | 参数 | 返回值 | 备注 | | ---- | ---- | ----| ---- | | setCookie | ( name, value, time ) | undefined | 设置cooke, time类型的单位有三种s、h、d,分别表示秒、小时和天 | | getCookie | ( name ) | string | 获取指定cookie的值 | | delCookie | ( name ) | undefined | 删除指定的cookie |