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

wucpeng-tools

v1.0.12

Published

time date holiday lunar

Downloads

36

Readme

wucpeng-tools

一些编程小工具 时间控制

Installation

$ npm install wucpeng-tools

Enjoy yourself!

Feature holiday

holiday 判断假期 需要每年添加 供当前公司场景使用

const tools = require('wucpeng-tools');

const holiday = tools.holiday;

let time = new Date();

console.log(holiday.isHolidayDate(time));

Feature calendar

const tools = require('wucpeng-tools');

const calendar = tools.calendar;

let time = new Date();

console.log(calendar.solar2lunarDate(time));

    {
      lYear: 1986,
      lMonth: 1,
      lDay: 27,
      Animal: '虎',
      IMonthCn: '正月',
      IDayCn: '廿七',
      cYear: 1986,
      cMonth: 3,
      cDay: 7,
      gzYear: '丙寅',
      gzMonth: '辛卯',
      gzDay: '庚戌',
      isToday: false,
      isLeap: false,
      nWeek: 5,
      ncWeek: '星期五',
      isTerm: false,
      Term: null,
      astro: '双鱼座'
    }

Feature identificationCheck

const tools = require('wucpeng-tools');
const identificationCheck = tools.identificationCheck;
console.log('cert', identificationCheck.certificateNoParse('310109201509160514'));
cert { areaCode: '310109',
      sex: '男',
      gender: 2,
      birthday: '2015-09-16',
      age: 3 }
console.log('cert', identificationCheck.certificateNoParse('372901860127283'));
cert { areaCode: '372901',
  sex: '男',
  gender: 2,
  birthday: '1986-01-27',
  age: 32 }

Feature passwdCode

const tools = require('wucpeng-tools');
const passwdCode = tools.passwdCode;

功能 | 变量 | 参数 | 返回值 -----|------|-----|----- 生成6位数字密码 | createPasswd | | string 生成多维复杂密码 | generatePassword | | string 计算密码复杂度 | passwordStringMode | string | number 计算唯一随机字符串 | getUuid | | string 获取随机数 | getRandomInt | min max | number 从begin 到 end的一个随机数,不包括end | randomByRange | number 限制最大数字 | limitMax | number, max | number 限制数字范围 | clamp | number, min, max | number

Feature rsaMd5Sign

const tools = require('wucpeng-tools');
const rsaMd5Sign = tools.rsaMd5Sign;

功能 | 变量 | 参数 | 返回值 -----|------|-----|----- 对序列化rsa加密 | getRsaSignArray | params, privateKey | string 对象序列化 | packageParams | options | array 签名验证 | verifyRsa | options, sig, priKey, pubKey | boolean

Feature zip

const tools = require('wucpeng-tools');

const zip = tools.zip;

zip.zipFilePwd(workPath, fileName, pwd, (err)=> {});

zip.zipFile(workPath, fileName, (err)=> {});

Feature timeConvert 时间转换

const tools = require('wucpeng-tools');
const timeConvert = tools.timeConvert;

功能 | 变量 | 参数 | 返回值 -----|------|-----|----- 获取时间小时信息 | getHour | date offsetInSeconds | number 获取本年度第一周时间 | getFirstWeekDayOfYear | date | Date 获取星期时间 | getWeek | date | 0-6 获取时间 | getDayAndWeek | date | x号-周x 是否零点时间 | isZeroTime | timeInt | true or false 判断是否周一 | isMonthFirstDayTime | timeInt | true or false 获取日期零点时间 | getZeroTime | intTime | Date 获取月份零点时间 | getZeroMonthTime | intTime | Date 获取年份零点时间 | getZeroYearTime | intTime | Date 获取一周开始时间(周一) | getZeroWeekTime | intTime | Date 获取当月每天时间 | getMonthDays | intTime | Array [intTime] 判断时间是否是时间格式 | checkTimeIsSet | date | boolean 获取时间字符串 | getTimeYMDH | intTime | 格式: 2015年12月3日8:30 获取时间字符串 | getTimeYMD | intTime | 格式: 2015年12月3日 获取时间字符串 | getTimeYM | intTime | 格式: 2015年12月 获取时间字符串 | getTimeHM | intTime | 格式: 08:30 判断是否同一天 | isSameDay | date1, date2 | boolean 是否当前月 | isCurrentMonth | date | boolean 判断是否是同一天 | isSameDayFormat | time1, time2 | boolean 根据开始时间和天数计算时间 | calcDateByDays | begin, days | Date 计算年龄 | calcAge | dateTime | age 计算年龄 | calcAgeAndMonth | birthYear, birthMonth, birthDate | {year: number, month: number, date: number} 计算时间差距 | calcDateDiff | beginDate, endDate | {year: number, month: number, date: number}

Feature regionCode 区域数据

const tools = require('wucpeng-tools');
const regionCode = tools.regionCode;
const simpleRegion = regionCode.simpleRegion;
{
    '0': ['省1', '省2', '省3', ...],
    '0_省下标': ['城市1', '城市2', '城市3', '城市4', ...],
    '0_省下标_市下标': ['区县1', '区县2', '区县3' '区县4', ....]
}

Feature areaJS 区域数据

const tools = require('wucpeng-tools');
const areaJS = tools.areaJS;
const areaConfig = areaJS.areaConfig;
{
    areas: [
         { code: '110000', name: '北京市' },
         { code: '110100', name: '市辖区' },
         { code: '110101', name: '东城区' },
         { code: '110102', name: '西城区' },
         { code: '110105', name: '朝阳区' },
         { code: '110106', name: '丰台区' },
         { code: '110107', name: '石景山区' },
         { code: '110108', name: '海淀区' },
         { code: '110109', name: '门头沟区' },
         { code: '110111', name: '房山区' },
         { code: '110112', name: '通州区' },
         { code: '110113', name: '顺义区' },
         { code: '110114', name: '昌平区' },
         { code: '110115', name: '大兴区' },
         { code: '110116', name: '怀柔区' },
         { code: '110117', name: '平谷区' },
         { code: '110200', name: '县' },
         { code: '110228', name: '密云县' },
         ......
    ],
    areaMap: {
         '110000': '北京市',
         '110100': '市辖区',
         '110101': '东城区',
         '110102': '西城区',
         '110105': '朝阳区',
         '110106': '丰台区',
         '110107': '石景山区',
         '110108': '海淀区',
         '110109': '门头沟区',
         '110111': '房山区',
         '110112': '通州区',
         '110113': '顺义区',
         '110114': '昌平区',
         '110115': '大兴区',
         '110116': '怀柔区',
         '110117': '平谷区',
         '110200': '县',
         '110228': '密云县',
         '110229': '延庆县',
         '120000': '天津市',
         '120100': '市辖区',
         '120101': '和平区',
         '120102': '河东区',
         '120103': '河西区',
         .......
    },
    codeMap: {
         '1101': '010',
         '1102': '010',
         '1201': '022',
         '1202': '022',
         '1301': '0311',
         '1302': '0315',
         '1303': '0335',
         '1304': '0310',
         '1305': '0319',
         '1306': '0312',
         '1307': '0313',
         '1308': '0314',
         '1309': '0317',
         '1310': '0316',
         '1311': '0318',
         '1401': '0351',
         '1402': '0352',
         ......
    },
    cArea: {
        "31": {
                "cities": [
                    {
                        "code": "310101",
                        "name": "黄浦区"
                    },
                    {
                        "code": "310103",
                        "name": "卢湾区"
                    },
                    {
                        "code": "310104",
                        "name": "徐汇区"
                    },
                    {
                        "code": "310105",
                        "name": "长宁区"
                    },
                    {
                        "code": "310106",
                        "name": "静安区"
                    },
                    {
                        "code": "310107",
                        "name": "普陀区"
                    },
                    {
                        "code": "310108",
                        "name": "闸北区"
                    },
                    {
                        "code": "310109",
                        "name": "虹口区"
                    },
                    {
                        "code": "310110",
                        "name": "杨浦区"
                    },
                    {
                        "code": "310112",
                        "name": "闵行区"
                    },
                    {
                        "code": "310113",
                        "name": "宝山区"
                    },
                    {
                        "code": "310114",
                        "name": "嘉定区"
                    },
                    {
                        "code": "310115",
                        "name": "浦东新区"
                    },
                    {
                        "code": "310116",
                        "name": "金山区"
                    },
                    {
                        "code": "310117",
                        "name": "松江区"
                    },
                    {
                        "code": "310118",
                        "name": "青浦区"
                    },
                    {
                        "code": "310120",
                        "name": "奉贤区"
                    },
                    {
                        "code": "310230",
                        "name": "崇明县"
                    }
                ],
                "name": "上海市"
            },
            ......
    }
}

areaJS.getAreaName('990101');
getAreaName 测试1

areaJS.getProvinceCityCodes('990101');
getProvinceCityCodes [ { code: '990000', name: '孩子通测试' },
  { code: '990100', name: '测试' },
  { code: '990101', name: '测试1' },
  { code: '990102', name: '测试2' },
  { code: '990103', name: '测试3' },
  { code: '990104', name: '测试4' },
  { code: '990105', name: '测试5' } ]

areaJS.getAreaCodes('990101');
getAreaCodes [ '990000',
  '990100',
  '990101',
  '990102',
  '990103',
  '990104',
  '990105' ]

areaJS.getAreaCodesByCodes(['990101', '530901']);
getAreaCodesByCodes [ '990000',
  '990100',
  '990101',
  '990102',
  '990103',
  '990104',
  '990105',
  '530000',
  '530100',
  '530101',
  '530300',
  '530301',
  '530400',
  '530401',
  '530500',
  '530501',
  '530600',
  '530601',
  '530700',
  '530701',
  '530800',
  '530801',
  '530900',
  '530901',
  '532300',
  '532301',
  '532500',
  '532501',
  '532600',
  '532601',
  '532800',
  '532801',
  '532900',
  '532901',
  '533100',
  '533102',
  '533300',
  '533321',
  '533400',
  '533421' ]

areaJS.getProvinceCodes(['990101', '530901']);
getProvinceCodes [ '99', '53' ]