aboutsummaryrefslogtreecommitdiff
path: root/src/pattern.js
diff options
context:
space:
mode:
authorDeterminant <ted.sybil@gmail.com>2019-02-13 01:11:31 -0500
committerDeterminant <ted.sybil@gmail.com>2019-02-13 01:11:31 -0500
commitc594888953151ddfb4ca04b7752bfd51edc1d6da (patch)
tree59b6d0b0f514f76d152eee9a4359c08110f73531 /src/pattern.js
parentf28b818cc62c7fff67517a4147e64f08ebd73027 (diff)
WIP: migrate to TypeScriptX
Diffstat (limited to 'src/pattern.js')
-rw-r--r--src/pattern.js48
1 files changed, 0 insertions, 48 deletions
diff --git a/src/pattern.js b/src/pattern.js
deleted file mode 100644
index 858f2a3..0000000
--- a/src/pattern.js
+++ /dev/null
@@ -1,48 +0,0 @@
-export class Pattern {
- constructor(id, isRegex, value, label) {
- this.id = id;
- this.isRegex = isRegex;
- this.value = value;
- this.label = label;
- }
-
- get regex() { return new RegExp(this.isRegex ? this.value : `^${this.value}$`); }
- get isEmpty() { return this.label === null; }
- deflate() {
- return {
- id: this.id,
- isRegex: this.isRegex,
- value: this.value,
- label: this.label
- };
- }
- static emptyPattern = () => new Pattern(0, true, '', null);
- static anyPattern = () => new Pattern('any', true, '.*', 'Any');
- static inflate = obj => new Pattern(obj.id, obj.isRegex, obj.value, obj.label);
-}
-
-export class PatternEntry {
- constructor(name, idx, calPattern, eventPattern, color) {
- this.name = name;
- this.idx = idx;
- this.cal = calPattern;
- this.event = eventPattern;
- this.color = color;
- }
-
- deflate() {
- return {
- name: this.name,
- idx: this.idx,
- cal: this.cal.deflate(),
- event: this.event.deflate(),
- color: this.color
- };
- }
-
- static defaultPatternEntry = (idx) => new PatternEntry('', idx, Pattern.emptyPattern(), Pattern.anyPattern(), {background: null});
- static inflate = obj => new PatternEntry(
- obj.name, obj.idx,
- Pattern.inflate(obj.cal), Pattern.inflate(obj.event),
- obj.color);
-}