TO = 'to',
}
+export enum States {
+ TRASHED = 'trashed',
+ PAST_VERSION = 'pastVersion'
+}
+
const keyValuePattern = (key: string) => new RegExp(`${key}:([^ ]*)`);
const propertyPattern = /has:"(.*?)":"(.*?)"/;
}
return properties;
}, [] as Property[]);
+
+
+export const isTrashed = (tokens: string[]) => isSomeState(States.TRASHED, tokens);
+
+export const isPastVersion = (tokens: string[]) => isSomeState(States.PAST_VERSION, tokens);
+
+const isSomeState = (state: string, tokens: string[]) => {
+ for (const token of tokens) {
+ const match = token.match(keyValuePattern(Keywords.IS)) || ['', ''];
+ if (match) {
+ const [, value] = match;
+ if(value === state) {
+ return true;
+ }
+ }
+ }
+ return false;
+};