on master help sign in
lib: remove cruft
commit7c805080003967b0fe23e6e687c8979478d56e86 authorMatilde Park <matilde@tlon.io> dateTue 22 Jun 2021, 16:36 (5 years ago) parenta7786d3
1 file changed−38
lib/lib.js−38
lib/lib.js−38
@@ -123,44 +123,6 @@ export function formatDate(d) {
123123// }))
124124// }
125125
126−export const getAllFiles = function (dirPath, arrayOfFiles) {
127− let files = fs.readdirSync(dirPath);
128−
129− arrayOfFiles = arrayOfFiles || [];
130−
131− files.forEach(function (file) {
132− if (fs.statSync(dirPath + "/" + file).isDirectory()) {
133− arrayOfFiles = getAllFiles(dirPath + "/" + file, arrayOfFiles);
134− } else {
135− arrayOfFiles.push(join(__dirname, dirPath, "/", file));
136− }
137− });
138−
139− return arrayOfFiles;
140−};
141−
142−function get(obj, path, defaultValue) {
143− for (const index of path) {
144− if (obj[index] === undefined) {
145− return defaultValue;
146− }
147− obj = obj[index];
148− }
149− return obj;
150−}
151−
152−function set(obj, path, value) {
153− let piece = obj;
154− for (let i = 0; i < path.length - 1; i++) {
155− if (piece[path[i]] === undefined) {
156− piece[path[i]] = typeof path[i + 1] === "number" ? [] : {};
157− }
158− piece = piece[path[i]];
159− }
160− piece[path[path.length - 1]] = value;
161− return obj;
162−}
163−
164126/**
165127 * buildPageTree is written to provide a recursive index of posts
166128 * for nested directories for creating sidebars