'use strict';

/**
 * [格式化日期]
 * @param  {[type]} date [description]
 * @return {[type]}      [description]
 */
const formatTime = date => {
	const year = date.getFullYear();
	const month = date.getMonth() + 1;
	const day = date.getDate();
	const hour = date.getHours();
	const minute = date.getMinutes();
	const second = date.getSeconds();

	return [year, month, day].map(formatNumber).join('') + ' ' + [hour, minute, second].map(formatNumber).join(':');
}

/**
 * [格式化数字]
 * @param  {[type]} n [description]
 * @return {[type]}   [description]
 */
const formatNumber = n => {
	n = n.toString();
	return n[1] ? n : '0' + n
}

/**
 * [截取Url的参数并转为对象]
 * @param  {[type]} url [description]
 * @return {[type]}     [description]
 */
const parseQueryUrl = url => {
	let str = url.split('?')[1];
	let params = str.split('&');
	let arr = [],
		json = {};
	for (let i = 0; i < params.length; i++) {
		arr = params[i].split('=');
		json[arr[0]] = arr[1];
	}
	return json;
}

/**
 * [description]
 * @param  {[type]} str [description]
 * @return {[type]}     [description]
 */
const string2Array = str => {
	let arr = str.split(',');
	let newArr = [];
	for (let i = 0; i < arr.length; i++) {
		let arrOne = arr[i];
		newArr.push(arrOne);
	}
	return newArr;
}

/**
 * 
 */
const array2String = arr => {
	return arr.toString();
}

module.exports = {
	formatTime,
	formatNumber,
	parseQueryUrl,
	string2Array,
	array2String
}
@@ -1255,70 +1255,319 @@
 %0A * 
-%0A */%0Aconst array2String = arr =%3E %7B%0A%09return arr.toString(
+%5Bdescription%5D%0A * @param  %7B%5Btype%5D%7D to   %5B%E7%9B%AE%E6%A0%87%E6%95%B0%E7%BB%84%5D%0A * @param  %7B%5Btype%5D%7D from %5B%E8%BD%AC%E6%8D%A2%E6%95%B0%E7%BB%84%5D%0A * @return %7B%5Btype%5D%7D      %5Bdescription%5D%0A */%0Aconst array2String = (to, from) =%3E %7B%0A%09let tempObject = %7B%7D;%0A%09to.map(item =%3E %7B%0A%09%09tempObject%5Bitem.itemName%5D = from%5Bitem.itemName%5D.join(',')%0A%09%7D)%0A%09return Object.assign(%7B%7D, from, tempObject
 );%0A%7D%0A%0A
+%0A
 modu

add new methods