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

yyl-util

v2.3.9

Published

node function util

Downloads

41

Readme

yyl-util 2.0

a node util for yyl

  • yyl-util 已根据功能拆分为 yyl-os, yyl-fs, yyl-file-replacer, yyl-print

API 说明

util.cmdParse(processArgv)

/**
 * 将 process.argv 转成 obj 形式
 * @param  {Array} processArgv process.argv 对象
 * @return { cmds, env, shortEnv }
 */
 util.cmdParse(processArgv);

util.envStringify(obj);

/**
 * 将obj 转成 命令行 env 形式 {name: jack} => --name jack
 * @param  {Object} obj 值对象
 * @return {String} str env 操作字符串
 */
util.envStringify(obj);

util.envParse(argv);

/**
 * 将 数组转成 对象 [--name, jack] => {name: jack}
 * @param  {Array}  argv 数组
 * @return {Object} obj  值对象
 */
util.envParse(argv);

util.requireJs(iPath);

/**
 * 获取 js 内容
 * @param {String} iPath 文件路径
 * @return {JS}    js    返回 文件执行的结果
 */
util.requireJs(iPath);

util.makeCssJsDate();

/**
 * 创建 YYYYMMDDmmss 格式时间搓
 * @return {String} cssjsdate 时间搓
 */
util.makeCssJsDate();

util.makeArray(obj)

/**
 * 将 arguments 变为数组
 */
util.makeArray(obj);

util.type(obj)

/**
 * 判断对象类别
 * @param {Anything} 对象
 * @return {string}  类型
 */
util.type(obj);

util.extend()

/**
 * 扩展方法(来自 jQuery)
 * extend([deep,] target, obj1 [, objN])
 * @base she.isPlainObject
 */
util.extend();

util.compareVersion(v1, v2)

/**
 * 版本对比
 * @param  {String} v1     版本1
 * @param  {String} v2     版本2
 * @return {Number} result 结果
 *                         -  1 v1 大
 *                         - -1 v2 大
 *                         -  0 相等
 */
util.compareVersion(v1, v2);

util.matchVersion(v1, v2)

/**
 * 校验版本是否匹配
 * @param  {String} v1      带特殊字符的版本
 * @param  {String} v2      不带特殊字符的版本
 * @return {Boolean} result 结果
 */
util.matchVersion(v1, v2);

util.path

/**
 * 同 path.join(), path.relative(), path.resolve() 但多了路径纠正逻辑
 */
util.path.join()
util.path.relative()
util.path.resolve()
/**
 * 可以将 ./, ../ 这类型相对路径 format 掉的 方法
 * @param  {String} iUrl 需要进行格式化的 url
 * @return {String} r
 */
util.path.formatUrl(iUrl)

util.makeAwait(fn)

/**
 * 截取带颜色文字的长度
 * @param  {function} fn(next, reject) 让函数变成 await 形式
 * @param  {function} next
 * @param  {function} reject
 * @return {Promise} r
 */
util.makeAwait(fn)

util.waitFor(ms)

/**
 * 等待 x ms 后继续执行
 * @param  {number} ms 等待时长
 * @return {Promise}
 */
util.waitFor(ms)

util.shortEnvParse(str)

/**
 * 短名字符串解析
 * @param  {String} str 输入字符串
 * @return {Object} 解析后对象
 */
util.shortEnvParse(str)

util.shortEnvStringify(obj)

/**
 * 短名字符串解析
 * @param  {Object} obj 输入对象
 * @return {String} 解析后字符串
 */
util.shortEnvStringify(obj)

util.makeAsync(fn)

/**
 * 将 fn(done) 类型异步回调函数变成 async 函数
 * @param  {Function} fn async 函数
 * @param  {Boolean} isMocha 是否用于 mocha
 * @return {Function}
 */
util.makeAsync(fn, isMocha);

util.forEach(arr, fn)

/**
 * forEach asycn 版本, 如果 fn 内 返回 true 则会终止循环
 * @param  {Array}    arr              需要循环的数组
 * @param  {Function} fn(item, index)  循环中的回调函数
 * @param  {Any}      item             arr[i] 内容
 * @param  {Number}   index            arr 下标
 * @return {void}
 */
util.forEach(arr, fn);

历史记录

这里