async function getRoot(startPath) {
return new Promise(async (resolve, reject) => {
fs.access(`${startPath}/package.json`, fs.constants.F_OK, (err) => {
if (!err) {
resolve(startPath);
} else {
const arr = startPath.split('/');
arr.pop();
const newRoot = arr.join('/');
resolve(await (getRoot(newRoot)));
}
});
});
}
getRoot(process.env.PWD).then((data) => console.log(data));
'photo100172_166443618,video85635407_165186811'
class PostApi {
static fetch() {
return fetch(BASE_URL, {method: 'get'}).then(res => res.json())
}
}
class PostApi {
static fetch() {
fetch(BASE_URL, {method: 'get'}).then(res => res.json())
}
}
const fs = require('fs');
const data = fs.readFileSync('text.txt').toString();
console.log(data.split('\n').length);