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

myself-tool

v1.3.0

Published

收集、自定义js开发过程中可能会用到的工具

Downloads

157

Readme

1、用途

收集、自定义js开发过程中可能会用到的工具,目前包括日志分隔线、字节数组相关、MD5加密、线程休眠、数据类型相关工具

2、用法

安装方式

# npm安装方式
npm i myself-tool

# yarn安装方式
yarn add myself-tool

导入方式

// 导入所有工具
const $_$ = require('myself-tool')

// 导入指定工具
const {byteTools} = require('myself-tool')

日志分隔线

// 导入日志工具
const {logTools} = require('myself-tool')

// 打印日志分隔线
logTools.log()

字节数组相关

// 导入字节工具
const {byteTools} = require('./myself-tool')

// 将字符串按utf-8编码转字节数组
const byteArr = byteTools.str2Utf8ByteArr('今天天气真不错')
console.log(byteArr)

// 将字节数组转十六进制字符串
const hexStr = byteTools.byteArr2HexStr(byteArr)
console.log(hexStr)

md5加密

// 导入加解密工具
const {cryptoTools} = require('./myself-tool')

const plaintext = 'admin' + '8eac51ed-92f4-45b2-9015-f96c3e52d991'

// MD5加密
console.log('小写32位MD5', cryptoTools.md5.encrypt(plaintext))
console.log('大写32位MD5', cryptoTools.md5.encrypt(plaintext, {upperCase: true}))
console.log('小写16位MD5', cryptoTools.md5.encrypt(plaintext, {shortText: true}))
console.log('大写16位MD5', cryptoTools.md5.encrypt(plaintext, {
  upperCase: true,
  shortText: true
}))

线程休眠

// 导入线程工具
const {threadTools} = require('./myself-tool')
// 线程休眠
console.log(1, Date.now())
threadTools.sleep(3000)
console.log(2, Date.now())

数据类型相关

// 导入数据类型工具
const {dataTypeTools} = require('./myself-tool')

console.log('判断数据是不是Number类型', dataTypeTools.isNumber(1.5))
console.log('判断数据是不是String类型', dataTypeTools.isString('hello'))
console.log('判断数据是不是Boolean类型', dataTypeTools.isBoolean(true))
console.log('判断数据是不是Undefined类型', dataTypeTools.isUndefined(undefined))
console.log('判断数据是不是Null类型', dataTypeTools.isNull(null))
console.log('判断数据是不是Object类型', dataTypeTools.isObject({}))
console.log('判断数据是不是Function类型', dataTypeTools.isFunction(() => Date.now()))
console.log('判断数据是不是Array类型', dataTypeTools.isArray([]))

console.log('获取数据的类型字符串', dataTypeTools.getDataTypeStr([]))

console.log('将数据转换成Number类型', dataTypeTools.toNumber('-123'))
console.log('将数据转换成String类型', dataTypeTools.toString(666))
console.log('将数据转换成Boolean类型', dataTypeTools.toBoolean(''))

3、注意

开源许可协议

本包采用的开源许可协议为MIT