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

mill-n-utils

v1.0.13

Published

about node util of my usage

Downloads

6

Readme

mill-n-utils

关于nodejs的一些工具模块封装 只为了简化操作

npm install mill-n-utils --save-dev

继承事件处理对象

var min=require('../index');

var temp={};
min.eventBind(temp);
temp.on('done',function (name,age) {
	console.log("name:%s;age:%d;",name,age);
});

temp.emit('done',"mill",29)

变量的命名

支持大写命名up、驼峰命名tf、pascal命名和下划线xhx命名

var name=min.doName.up('get an apple');
console.log(name);//GET_AN_APPLE

接收控制台参数

var option=min.mist();
console.log(option.mill);

控制台输入

$node testmist.js --mill aaa
> aaa

写出文件

var min=require('../index');
var path=require('path');

describe("写出JSON文件成功",function  () {
	var file=path.resolve(__dirname,"./test.json");
	beforeAll(function  () {
	
		min.fs.writeJSON(file,{
			"name":"mill",
			"age" :30
		});
		min.fs.copy(
			file,"./test1.json"
		);
	
	}) ;
	afterAll(function  () {
		min.fs.delete(file);
		min.fs.commit(function  () {
			
		});
	}) ;
	it("文件存在",function  () {
		expect(min.fs.exists(file)).toBe(true);
		expect(min.fs.exists("./test1.json")).toBe(true);
	});
});

excel转成markdown的表格

var min=require('../index');

var excelStr=`

编码	父级	说明		响应格式
data		数据集合		List<BusSupplierInfo> json格式
supplierId	data	供应商id		Long
storeId	data	店铺id		Long
supplierCode	data	供应商简码		Long
supplierName	data	供应商名称		String




`;
var name=min.excel2table(excelStr);
console.log(name);

excel转成json

var min=require('../index');

var excelStr=`

编码	父级	说明		响应格式
data		数据集合		List<BusSupplierInfo> json格式
supplierId	data	供应商id		Long
storeId	data	店铺id		Long
supplierCode	data	供应商简码		Long
supplierName	data	供应商名称		String

`;
var name=min.excel2json(excelStr);
console.log(name);

base64的编码和解码

var min=require('../index');

let temp=min.base64.encode('mill');
console.log('encode',temp);

temp=min.base64.decode(temp);
console.log('decode',temp);

temp=min.base64.encodeHex(temp);
console.log('encodeHex',temp);

temp=min.base64.decodeHex(temp);
console.log('decodeHex',temp);

日期格式化

var min=require('../index');

let temp=min.dateFormat(new Date(),"yyyy-MM-dd hh:mm:ss");

console.log(temp);

日期解析

将格式化的字符串解析成为一个时间对象 2017-12-22 00:00:00或者2017-12-22这样的格式都可以

let index=require('../index.js');
	let date=	index.dateParse('2017-12-22 00:00:00');
	console.log(index.dateFormat(date,"yyyy-MM-dd hh:mm:ss"));