sort-file-list
Advanced tools
Comparing version 0.0.2 to 0.0.3
62
index.js
@@ -110,23 +110,48 @@ /** | ||
let length = file_a_list_length<file_b_list_length?file_a_list_length:file_b_list_length; | ||
if(file_a_list_length == file_b_list_length) { | ||
//节点数相同.. | ||
let length = file_a_list_length; | ||
for (let i = length-1; i >= 0; i--) { | ||
const element_a = file_a_list[i]; | ||
const element_b = file_b_list[i]; | ||
if(element_a === element_b) { | ||
continue; //二者完全相同,比较下一节点 | ||
} | ||
let sep1 = field_sep(element_a); | ||
let sep2 = field_sep(element_b); | ||
let ret_val = 0; | ||
/////////////////////////////////////////////// | ||
//字母部分相同..则按数字部分排序 | ||
ret_val = order_func(sep1, sep2); | ||
if(ret_val != 0) { | ||
return ret_val; | ||
} | ||
} | ||
}else{ | ||
//节点数不同,从头比较... | ||
let length = file_a_list_length<file_b_list_length?file_a_list_length:file_b_list_length; | ||
for (let i = 0; i < length; i++) { | ||
const element_a = file_a_list[i]; | ||
const element_b = file_b_list[i]; | ||
for (let i = 0; i < length; i++) { | ||
const element_a = file_a_list[i]; | ||
const element_b = file_b_list[i]; | ||
if(element_a === element_b) { | ||
continue; //二者完全相同,比较下一节点 | ||
} | ||
if(element_a === element_b) { | ||
continue; //二者完全相同,比较下一节点 | ||
} | ||
let sep1 = field_sep(element_a); | ||
let sep2 = field_sep(element_b); | ||
let ret_val = 0; | ||
let sep1 = field_sep(element_a); | ||
let sep2 = field_sep(element_b); | ||
let ret_val = 0; | ||
/////////////////////////////////////////////// | ||
//字母部分相同..则按数字部分排序 | ||
ret_val = order_func(sep1, sep2); | ||
if(ret_val != 0) { | ||
return ret_val; | ||
/////////////////////////////////////////////// | ||
//字母部分相同..则按数字部分排序 | ||
ret_val = order_func(sep1, sep2); | ||
if(ret_val != 0) { | ||
return ret_val; | ||
} | ||
} | ||
@@ -136,2 +161,3 @@ | ||
if(file_a_list_length > file_b_list_length) { | ||
@@ -138,0 +164,0 @@ //节点长 a比b长 |
{ | ||
"name": "sort-file-list", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "sort file list", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -252,7 +252,7 @@ /** | ||
run(function () { | ||
let test_array = ['ac111.b.aaa7.txt','ac03.b.aaa00.txt','ac88.b.aaa08.txt','ac6.b.aaa00018.txt','ac.b.aaa0026.txt','ac3.b.aaa03.txt']; | ||
let test_array = ['ac111.b.1.txt','ac111.b.56246.txt','ac111.b.2.txt','ac111.b.3.txt','ac111.b.65.txt','ac3.b.15.txt']; | ||
var out_array = SortFile(test_array, {diff_is_number:true}); | ||
console.log(out_array); | ||
assert(out_array[0] === 'ac.b.aaa0026.txt' && out_array[out_array.length - 1] === 'ac111.b.aaa7.txt'); | ||
assert(out_array[0] === 'ac111.b.1.txt' && out_array[out_array.length - 1] === 'ac111.b.56246.txt'); | ||
}, 1); | ||
@@ -266,7 +266,7 @@ }); | ||
run(function () { | ||
let test_array = ['ac02.b.aaa7.txt','ac2.b.aaa00.txt','ac00002.b.aaa08.txt','ac00003.b.aaa00018.txt','ac00001.b.aaa0026.txt','ac0004.b.aaa03.txt']; | ||
let test_array = ['ac02.b.11.txt','ac2.b.67.txt','ac00002.b.00085.txt','ac00003.b.65.txt','ac00001.b.54.txt','ac0004.b.92.txt']; | ||
var out_array = SortFile(test_array, {diff_is_number:true}); | ||
console.log(out_array); | ||
assert(out_array[0] === 'ac00001.b.aaa0026.txt' && out_array[out_array.length - 1] === 'ac0004.b.aaa03.txt'); | ||
assert(out_array[0] === 'ac02.b.11.txt' && out_array[out_array.length - 1] === 'ac0004.b.92.txt'); | ||
}, 1); | ||
@@ -280,7 +280,7 @@ }); | ||
run(function () { | ||
let test_array = ['ac02.b.aaa7.txt','ac2.b.aaa00.txt','ac00002.b.aaa08.txt','ac00003.b.aaa00018.txt','ac00001.b.aaa0026.txt','ac0004.b.aaa03.txt']; | ||
let test_array = ['ac02.b.aaa7.1.txt','ac02.b.aaa00.2.txt','ac02.b.aaa08.5.txt','ac02.b.aaa00018.9.txt','ac02.b.aaa0026.11166.txt','ac02.b.aaa03.0458.txt']; | ||
var out_array = SortFile(test_array, {diff_is_number:true, reverse:true}); | ||
console.log(out_array); | ||
assert(out_array[0] === 'ac0004.b.aaa03.txt' && out_array[out_array.length - 1] === 'ac00001.b.aaa0026.txt'); | ||
assert(out_array[0] === 'ac02.b.aaa0026.11166.txt' && out_array[out_array.length - 1] === 'ac02.b.aaa7.1.txt'); | ||
}, 1); | ||
@@ -580,2 +580,47 @@ }); | ||
describe('node', function () { | ||
it('DICOM文件4', function () { | ||
run(function () { | ||
let test_array = [ | ||
"/dicom/2.16.840.1.113662.2.1.99999.561908492137470048195311821171660667.2/1.2.826.0.1.3680043.2.1125.1226919802768478504071194913806006494.28.dcm?path=D:\\tmp\\5dcm\\.", | ||
"/dicom/2.16.840.1.113662.2.1.99999.561908492137470048195311821171660667.2/1.2.826.0.1.3680043.2.1125.1326315220132978827872885864395737958.19.dcm?path=D:\\tmp\\5dcm\\.", | ||
"/dicom/2.16.840.1.113662.2.1.99999.561908492137470048195311821171660667.2/1.2.826.0.1.3680043.2.1125.1361768480484444425499527135612779686.18.dcm?path=D:\\tmp\\5dcm\\.", | ||
"/dicom/2.16.840.1.113662.2.1.99999.561908492137470048195311821171660667.2/1.2.826.0.1.3680043.2.1125.1375148876879968910170000487491756040.27.dcm?path=D:\\tmp\\5dcm\\.", | ||
"/dicom/2.16.840.1.113662.2.1.99999.561908492137470048195311821171660667.2/1.2.826.0.1.3680043.2.1125.2235168451025621150770086022819314200.16.dcm?path=D:\\tmp\\5dcm\\.", | ||
"/dicom/2.16.840.1.113662.2.1.99999.561908492137470048195311821171660667.2/1.2.826.0.1.3680043.2.1125.3262531003161696695653458408826368759.17.dcm?path=D:\\tmp\\5dcm\\.", | ||
"/dicom/2.16.840.1.113662.2.1.99999.561908492137470048195311821171660667.2/1.2.826.0.1.3680043.2.1125.3329194536637439351339613339069457736.9.dcm?path=D:\\tmp\\5dcm\\.", | ||
"/dicom/2.16.840.1.113662.2.1.99999.561908492137470048195311821171660667.2/1.2.826.0.1.3680043.2.1125.3992020733902674125961867361486581480.25.dcm?path=D:\\tmp\\5dcm\\.", | ||
"/dicom/2.16.840.1.113662.2.1.99999.561908492137470048195311821171660667.2/1.2.826.0.1.3680043.2.1125.409454565890345131436539996028315758.2.dcm?path=D:\\tmp\\5dcm\\.", | ||
"/dicom/2.16.840.1.113662.2.1.99999.561908492137470048195311821171660667.2/1.2.826.0.1.3680043.2.1125.426862527016684950550902134957533655.26.dcm?path=D:\\tmp\\5dcm\\.", | ||
"/dicom/2.16.840.1.113662.2.1.99999.561908492137470048195311821171660667.2/1.2.826.0.1.3680043.2.1125.4353712056216942851207484441757883251.11.dcm?path=D:\\tmp\\5dcm\\.", | ||
"/dicom/2.16.840.1.113662.2.1.99999.561908492137470048195311821171660667.2/1.2.826.0.1.3680043.2.1125.4392713714470136836780902715412669530.12.dcm?path=D:\\tmp\\5dcm\\.", | ||
"/dicom/2.16.840.1.113662.2.1.99999.561908492137470048195311821171660667.2/1.2.826.0.1.3680043.2.1125.4502164975718899715813793721275035150.13.dcm?path=D:\\tmp\\5dcm\\.", | ||
"/dicom/2.16.840.1.113662.2.1.99999.561908492137470048195311821171660667.2/1.2.826.0.1.3680043.2.1125.4618573550057131756266536144838663018.3.dcm?path=D:\\tmp\\5dcm\\.", | ||
"/dicom/2.16.840.1.113662.2.1.99999.561908492137470048195311821171660667.2/1.2.826.0.1.3680043.2.1125.6323230281259533626521418438015079782.1.dcm?path=D:\\tmp\\5dcm\\.", | ||
"/dicom/2.16.840.1.113662.2.1.99999.561908492137470048195311821171660667.2/1.2.826.0.1.3680043.2.1125.6395472148389810333749152206491833261.4.dcm?path=D:\\tmp\\5dcm\\.", | ||
"/dicom/2.16.840.1.113662.2.1.99999.561908492137470048195311821171660667.2/1.2.826.0.1.3680043.2.1125.6552281530896929394885935853257891221.8.dcm?path=D:\\tmp\\5dcm\\.", | ||
"/dicom/2.16.840.1.113662.2.1.99999.561908492137470048195311821171660667.2/1.2.826.0.1.3680043.2.1125.6747639945168567289535829804795949045.23.dcm?path=D:\\tmp\\5dcm\\.", | ||
"/dicom/2.16.840.1.113662.2.1.99999.561908492137470048195311821171660667.2/1.2.826.0.1.3680043.2.1125.7909610303980471511761137785792119113.15.dcm?path=D:\\tmp\\5dcm\\.", | ||
"/dicom/2.16.840.1.113662.2.1.99999.561908492137470048195311821171660667.2/1.2.826.0.1.3680043.2.1125.8076895386204820193014693324383779939.21.dcm?path=D:\\tmp\\5dcm\\.", | ||
"/dicom/2.16.840.1.113662.2.1.99999.561908492137470048195311821171660667.2/1.2.826.0.1.3680043.2.1125.8199463764920235943997353222932547065.7.dcm?path=D:\\tmp\\5dcm\\.", | ||
"/dicom/2.16.840.1.113662.2.1.99999.561908492137470048195311821171660667.2/1.2.826.0.1.3680043.2.1125.8212025908913477221201014328928423091.10.dcm?path=D:\\tmp\\5dcm\\.", | ||
"/dicom/2.16.840.1.113662.2.1.99999.561908492137470048195311821171660667.2/1.2.826.0.1.3680043.2.1125.8385156019066130968242182450275028457.6.dcm?path=D:\\tmp\\5dcm\\.", | ||
"/dicom/2.16.840.1.113662.2.1.99999.561908492137470048195311821171660667.2/1.2.826.0.1.3680043.2.1125.8507444429618404251074490049909202416.14.dcm?path=D:\\tmp\\5dcm\\.", | ||
"/dicom/2.16.840.1.113662.2.1.99999.561908492137470048195311821171660667.2/1.2.826.0.1.3680043.2.1125.8671711547635827634814524131814884931.22.dcm?path=D:\\tmp\\5dcm\\.", | ||
"/dicom/2.16.840.1.113662.2.1.99999.561908492137470048195311821171660667.2/1.2.826.0.1.3680043.2.1125.8726666596699595605060411598856213026.20.dcm?path=D:\\tmp\\5dcm\\.", | ||
"/dicom/2.16.840.1.113662.2.1.99999.561908492137470048195311821171660667.2/1.2.826.0.1.3680043.2.1125.9177500711179065413026513307172530456.24.dcm?path=D:\\tmp\\5dcm\\.", | ||
"/dicom/2.16.840.1.113662.2.1.99999.561908492137470048195311821171660667.2/1.2.826.0.1.3680043.2.1125.9572665160586034586674635853507392867.5.dcm?path=D:\\tmp\\5dcm\\." | ||
]; | ||
var out_array = SortFile(test_array, {diff_is_number:true}); | ||
console.log(out_array); | ||
assert(out_array[0] === '/dicom/2.16.840.1.113662.2.1.99999.561908492137470048195311821171660667.2/1.2.826.0.1.3680043.2.1125.6323230281259533626521418438015079782.1.dcm?path=D:\\tmp\\5dcm\\.' && out_array[out_array.length - 1] === '/dicom/2.16.840.1.113662.2.1.99999.561908492137470048195311821171660667.2/1.2.826.0.1.3680043.2.1125.1226919802768478504071194913806006494.28.dcm?path=D:\\tmp\\5dcm\\.'); | ||
}, 1); | ||
}); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
58867
669
0