Skip to content

Instantly share code, notes, and snippets.

@pizzacat83
Created March 6, 2019 13:46
Show Gist options
  • Save pizzacat83/ed55f605913eba04db3c191b0aca3a33 to your computer and use it in GitHub Desktop.
Save pizzacat83/ed55f605913eba04db3c191b0aca3a33 to your computer and use it in GitHub Desktop.
const ignored = new Map<string, boolean>();
const isIgnoredItem = (driveItem: ItemWrapper): boolean => {
if (ignored.has(driveItem.id)) {
return ignored.get(driveItem.id);
}
if (ignoredList.indexOf(driveItem.id) !== -1) {
ignored.set(driveItem.id, true);
return true;
}
if (driveItem.id === rootFolderId) {
ignored.set(driveItem.id, false);
return false;
}
let parents = driveItem.content.getParents();
if (!parents.hasNext()) {
ignored.set(driveItem.id, false);
return false;
}
while (parents.hasNext()) {
// 全ての親がignoredならtrue
const parent = parents.next();
const parentWrapper = { content: parent, id: parent.getId() };
if (!isIgnoredItem(parentWrapper)) {
ignored.set(driveItem.id, false);
return false;
}
}
ignored.set(driveItem.id, true);
return true;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment