Commit eb680f48 authored by Scott Sun's avatar Scott Sun

scott

parent 7b419ac5
node_modules
.vscode
\ No newline at end of file
var fs = require("fs");
var book = require('topsin.excelxs');
function ExlDb (props) {
this.props = props
}
ExlDb.prototype.read = function (path, suffix) { // 读取方法 接收参数1 string 文件夹路径 参数2 array 读取对应后缀的文件
var suffix = suffix || "XLSX"
var files = fs.listDir(path).filter(function(v){
return Array.isArray(suffix) ? suffix.indexOf(v.completeSuffix) >= 0 :
v.completeSuffix === suffix
})
if(files.length === 0){ return }
files = files.map(function(v){return (v.dir + '/' + v.name)})
return files;
}
module.exports = function(props){
return new ExlDb(props);
}
\ No newline at end of file
var fs = require('fs');
// 程序启动时 判断是否存在 .
var exl = require("./index.js")({}); // 引入并初始化
var files = exl.read("../excel"); // 读取文件夹获取文件列表 默认是只读取XLSX后缀文件
console.log(files);
function stringZip(iStr) {
var arr = [];
var temp = {};
for (var i = 0, len = iStr.length; i < len; i++) {
var element = iStr[i];
if (i === 0) {
temp[element] = 1
} else if (element === iStr[i-1]) {
temp[element]++
} else {
arr.push(temp)
temp = {}
temp[element] = 1
}
if(i >= len - 1){
arr.push(temp)
}
}
var res = "";
arr.forEach(function(v){
for (var key in v) {
res += v[key] + key
}
})
return res
}
function stringUnZip(iStr) {
var str = ""
for(var i = 0,len=iStr.length;i<len;i+=2){
for(var j = 0; j<iStr[i];j++){
str += iStr[i+1]
}
}
return str
}
// console.log(stringZip("aaabccccaaaaccddecccee"));
console.log(stringUnZip("3a1b6c2d3e"));
...@@ -230,7 +230,7 @@ Main.prototype.filterOldData = function (datas,dbdatas, type){ ...@@ -230,7 +230,7 @@ Main.prototype.filterOldData = function (datas,dbdatas, type){
this.UpdateKeys(updateData,dbdatas[dbI.indexOf(dataI)]["id"]) this.UpdateKeys(updateData,dbdatas[dbI.indexOf(dataI)]["id"])
} }
oldData.push(v) oldData.push(v)
} else{ } else {
// 新数据 // 新数据
newData.push(v) newData.push(v)
} }
...@@ -304,7 +304,5 @@ if(!config.isUseing){ // 如果没在运行程序就可以实例化 ...@@ -304,7 +304,5 @@ if(!config.isUseing){ // 如果没在运行程序就可以实例化
configReset(false) // 状态变成未运行 configReset(false) // 状态变成未运行
} }
// ["attr_data","action_data","extra_data","tags","sys_tags","sys_data"] // ["attr_data","action_data","extra_data","tags","sys_tags","sys_data"]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment