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

ziyo-functions

v0.0.8

Published

一些常用的公共方法

Downloads

11

Readme

Functions

平时常用的一些JS方法,整理在此备用

安装

npm install ziyo-functions

使用

const zfun = require('ziyo-functions');

var isArr1 = zfun.isArray('[1]'); // return false
var isArr2 = zfun.isArray([1]);   // return true

常用方法清单

buildDir(path) : < JsonObject >

  • 作用:创建目录
  • 参数:path 如:js ['/path/me', '/path/u']
  • 返回:< JsonObject > 如:js {'/path/me':true, '/path/u':true}

encodeXML(data) : < string >

  • 作用:简单的生成XML方法
  • 参数:data < JsonObject > 如:js {a:1, b:2}
  • 返回:< string > 返回XML格式字符串

isArray(obj) : < Boolean >

  • 作用:判断变量是否是数组类型
  • 参数:obj < * > 任何类型的变量
  • 返回:true | false

isEmpty(obj) : < Boolean >

  • 作用:判断变量是否为空
  • 参数:obj < * > 任何类型的变量
  • 返回:true | false

isObject(obj) : < Boolean >

  • 作用:判断变量是否为对象
  • 参数:obj < * > 任何类型的变量
  • 返回:true | false

isString(obj) : < Boolean >

  • 作用:判断变量是否为字符型
  • 参数:obj < * > 任何类型的变量
  • 返回:true | false

jsonMerge(obj1, obj2, ...) : < JsonObject >

  • 作用:将多个JSON对象合并成一个
  • 参数:obj1 < JsonObject >
  • 返回:< JsonObject > 返回一个JSON对象

ksort(obj) : < Object >

  • 作用:根据JSON对象的Key升序排序
  • 参数:obj < JsonObject >
  • 返回:< JsonObject > 排序后的JSON

loadPost(request, callback) : < undefined >

  • 作用:接收POST数据
  • 参数:request http的请求流
  •    callback(err, buf) 回调方法,参数分别为err(错误消息)和buf(数据流的二进制值)
  • 返回:无

readFileSync(filename) : < string >

  • 作用:同步读取文件内容
  • 参数:filename 文件名及路径
  • 返回:< string > 文件内容

time() : < int >

  • 作用:获取10位的时间戳
  • 参数:无
  • 返回:< int >

timer() : < long >

  • 作用:获取13位的长时间戳
  • 参数:无
  • 返回:< long >

writeFileSync(filename, data) : < undefined >

  • 作用:同步写文件
  • 参数:filename 文件名及路径
  •    data 需要写入的内容
  • 返回:< undefined >

getRandom(min, max) : < int >

  • 作用:随机获取指定区别内的整数
  • 参数:min < int >, max < int > 最小值与最大值
  • 返回:< int >