diff --git a/src/misc.ts b/src/misc.ts index c579ec7..e66cae1 100644 --- a/src/misc.ts +++ b/src/misc.ts @@ -46,8 +46,8 @@ export const getFolderLevels = (x: string) => { let i = 0; for (let index = 0; index + 1 < y1.length; index++) { const k = y1.slice(0, index + 1).join("/"); - if (k !== '' && k!== '/') { - res.push(k) + if (k !== "" && k !== "/") { + res.push(k); } } return res; @@ -145,3 +145,13 @@ export const getPathFolder = (a: string) => { const b = path.posix.dirname(a); return b.endsWith("/") ? b : `${b}/`; }; + +/** + * https://stackoverflow.com/questions/54511144 + * @param a + * @param delimiter + * @returns + */ +export const setToString = (a: Set, delimiter: string = ",") => { + return [...a].join(delimiter); +}; diff --git a/tests/misc.test.ts b/tests/misc.test.ts index 35867fb..4022a0a 100644 --- a/tests/misc.test.ts +++ b/tests/misc.test.ts @@ -70,7 +70,7 @@ describe("Misc: get folder levels", () => { expect(misc.getFolderLevels(item3)).to.deep.equal(res3); }); - it("should treat path starting with / correctly", ()=> { + it("should treat path starting with / correctly", () => { const item = "/xxx/yyy/zzz.md"; const res = ["/xxx", "/xxx/yyy"]; expect(misc.getFolderLevels(item)).to.deep.equal(res);