5etools-utils 0.13.4 → 0.13.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/UtilMisc.js CHANGED
@@ -37,6 +37,27 @@ export default class MiscUtil {
37
37
 
38
38
  /* -------------------------------------------- */
39
39
 
40
+ /** Delete a prop from a nested object, then all now-empty objects backwards from that point. */
41
+ static deleteObjectPath (object, ...path) {
42
+ const stack = [object];
43
+
44
+ if (object == null) return object;
45
+ for (let i = 0; i < path.length - 1; ++i) {
46
+ object = object[path[i]];
47
+ stack.push(object);
48
+ if (object === undefined) return object;
49
+ }
50
+ const out = delete object[path.at(-1)];
51
+
52
+ for (let i = path.length - 1; i > 0; --i) {
53
+ if (!Object.keys(stack[i]).length) delete stack[i - 1][path[i - 1]];
54
+ }
55
+
56
+ return out;
57
+ }
58
+
59
+ /* -------------------------------------------- */
60
+
40
61
  static setEq (a, b) {
41
62
  if (a.size !== b.size) return false;
42
63
  for (const it of a) if (!b.has(it)) return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "5etools-utils",
3
- "version": "0.13.4",
3
+ "version": "0.13.6",
4
4
  "description": "Shared utilities for the 5etools ecosystem.",
5
5
  "type": "module",
6
6
  "main": "lib/Api.js",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
3
  "$id": "fluff-class.json",
4
- "version": "1.0.1",
4
+ "version": "1.0.2",
5
5
  "type": "object",
6
6
  "$defs": {
7
7
  "_subclassFluffItemData": {
@@ -117,15 +117,6 @@
117
117
  },
118
118
  "images": {
119
119
  "oneOf": [
120
- {
121
- "type": "array",
122
- "items": {
123
- "$ref": "../entry.json#/$defs/entryImage"
124
- }
125
- },
126
- {
127
- "type": "null"
128
- },
129
120
  {
130
121
  "type": "array",
131
122
  "items": {
@@ -151,9 +142,15 @@
151
142
  },
152
143
  "classSource": {
153
144
  "$ref": "../util.json#/$defs/source"
145
+ },
146
+ "_copy": {
147
+ "$ref": "../util-copy.json#/$defs/copyBlock_copy_generic"
154
148
  }
155
149
  },
156
- "additionalProperties": false
150
+ "additionalProperties": false,
151
+ "required": [
152
+ "_copy"
153
+ ]
157
154
  }
158
155
  ]
159
156
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
3
  "$id": "fluff-races.json",
4
- "version": "2.1.2",
4
+ "version": "2.2.0",
5
5
  "type": "object",
6
6
  "$defs": {
7
7
  "raceFluffData": {
@@ -31,12 +31,6 @@
31
31
  "items": {
32
32
  "$ref": "entry.json"
33
33
  }
34
- },
35
- "uncommon": {
36
- "type": "boolean"
37
- },
38
- "monstrous": {
39
- "type": "boolean"
40
34
  }
41
35
  },
42
36
  "additionalProperties": false
@@ -70,12 +64,6 @@
70
64
  "items": {
71
65
  "$ref": "entry.json"
72
66
  }
73
- },
74
- "uncommon": {
75
- "type": "boolean"
76
- },
77
- "monstrous": {
78
- "type": "boolean"
79
67
  }
80
68
  },
81
69
  "additionalProperties": false,
@@ -113,12 +101,6 @@
113
101
  "$ref": "entry.json"
114
102
  }
115
103
  },
116
- "uncommon": {
117
- "type": "boolean"
118
- },
119
- "monstrous": {
120
- "type": "boolean"
121
- },
122
104
  "_copy": {
123
105
  "$ref": "util-copy.json#/$defs/copyBlock_copy_generic"
124
106
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
3
  "$id": "fluff-class.json",
4
- "version": "1.0.1",
4
+ "version": "1.0.2",
5
5
  "type": "object",
6
6
  "$defs": {
7
7
  "_subclassFluffItemData": {
@@ -117,15 +117,6 @@
117
117
  },
118
118
  "images": {
119
119
  "oneOf": [
120
- {
121
- "type": "array",
122
- "items": {
123
- "$ref": "../entry.json#/$defs/entryImage"
124
- }
125
- },
126
- {
127
- "type": "null"
128
- },
129
120
  {
130
121
  "type": "array",
131
122
  "items": {
@@ -151,9 +142,15 @@
151
142
  },
152
143
  "classSource": {
153
144
  "$ref": "../util.json#/$defs/source"
145
+ },
146
+ "_copy": {
147
+ "$ref": "../util-copy.json#/$defs/copyBlock_copy_generic"
154
148
  }
155
149
  },
156
- "additionalProperties": false
150
+ "additionalProperties": false,
151
+ "required": [
152
+ "_copy"
153
+ ]
157
154
  }
158
155
  ]
159
156
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
3
  "$id": "fluff-races.json",
4
- "version": "2.1.2",
4
+ "version": "2.2.0",
5
5
  "type": "object",
6
6
  "$defs": {
7
7
  "raceFluffData": {
@@ -31,12 +31,6 @@
31
31
  "items": {
32
32
  "$ref": "entry.json"
33
33
  }
34
- },
35
- "uncommon": {
36
- "type": "boolean"
37
- },
38
- "monstrous": {
39
- "type": "boolean"
40
34
  }
41
35
  },
42
36
  "additionalProperties": false
@@ -70,12 +64,6 @@
70
64
  "items": {
71
65
  "$ref": "entry.json"
72
66
  }
73
- },
74
- "uncommon": {
75
- "type": "boolean"
76
- },
77
- "monstrous": {
78
- "type": "boolean"
79
67
  }
80
68
  },
81
69
  "additionalProperties": false,
@@ -113,12 +101,6 @@
113
101
  "$ref": "entry.json"
114
102
  }
115
103
  },
116
- "uncommon": {
117
- "type": "boolean"
118
- },
119
- "monstrous": {
120
- "type": "boolean"
121
- },
122
104
  "_copy": {
123
105
  "$ref": "util-copy.json#/$defs/copyBlock_copy_generic"
124
106
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
3
  "$id": "fluff-class.json",
4
- "version": "1.0.1",
4
+ "version": "1.0.2",
5
5
  "type": "object",
6
6
  "$defs": {
7
7
  "_subclassFluffItemData": {
@@ -117,15 +117,6 @@
117
117
  },
118
118
  "images": {
119
119
  "oneOf": [
120
- {
121
- "type": "array",
122
- "items": {
123
- "$ref": "../entry.json#/$defs/entryImage"
124
- }
125
- },
126
- {
127
- "type": "null"
128
- },
129
120
  {
130
121
  "type": "array",
131
122
  "items": {
@@ -151,9 +142,15 @@
151
142
  },
152
143
  "classSource": {
153
144
  "$ref": "../util.json#/$defs/source"
145
+ },
146
+ "_copy": {
147
+ "$ref": "../util-copy.json#/$defs/copyBlock_copy_generic"
154
148
  }
155
149
  },
156
- "additionalProperties": false
150
+ "additionalProperties": false,
151
+ "required": [
152
+ "_copy"
153
+ ]
157
154
  }
158
155
  ]
159
156
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
3
  "$id": "fluff-races.json",
4
- "version": "2.1.2",
4
+ "version": "2.2.0",
5
5
  "type": "object",
6
6
  "$defs": {
7
7
  "raceFluffData": {
@@ -33,10 +33,10 @@
33
33
  }
34
34
  },
35
35
  "uncommon": {
36
- "type": "boolean"
36
+ "const": true
37
37
  },
38
38
  "monstrous": {
39
- "type": "boolean"
39
+ "const": true
40
40
  }
41
41
  },
42
42
  "additionalProperties": false
@@ -72,10 +72,10 @@
72
72
  }
73
73
  },
74
74
  "uncommon": {
75
- "type": "boolean"
75
+ "const": true
76
76
  },
77
77
  "monstrous": {
78
- "type": "boolean"
78
+ "const": true
79
79
  }
80
80
  },
81
81
  "additionalProperties": false,
@@ -114,10 +114,10 @@
114
114
  }
115
115
  },
116
116
  "uncommon": {
117
- "type": "boolean"
117
+ "const": true
118
118
  },
119
119
  "monstrous": {
120
- "type": "boolean"
120
+ "const": true
121
121
  },
122
122
  "_copy": {
123
123
  "$ref": "util-copy.json#/$defs/copyBlock_copy_generic"
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
3
  "$id": "fluff-class.json",
4
- "version": "1.0.1",
4
+ "version": "1.0.2",
5
5
  "type": "object",
6
6
  "$defs": {
7
7
  "_subclassFluffItemData": {
@@ -117,15 +117,6 @@
117
117
  },
118
118
  "images": {
119
119
  "oneOf": [
120
- {
121
- "type": "array",
122
- "items": {
123
- "$ref": "../entry.json#/$defs/entryImage"
124
- }
125
- },
126
- {
127
- "type": "null"
128
- },
129
120
  {
130
121
  "type": "array",
131
122
  "items": {
@@ -151,9 +142,15 @@
151
142
  },
152
143
  "classSource": {
153
144
  "$ref": "../util.json#/$defs/source"
145
+ },
146
+ "_copy": {
147
+ "$ref": "../util-copy.json#/$defs/copyBlock_copy_generic"
154
148
  }
155
149
  },
156
- "additionalProperties": false
150
+ "additionalProperties": false,
151
+ "required": [
152
+ "_copy"
153
+ ]
157
154
  }
158
155
  ]
159
156
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
3
  "$id": "fluff-races.json",
4
- "version": "2.1.2",
4
+ "version": "2.2.0",
5
5
  "type": "object",
6
6
  "$defs": {
7
7
  "raceFluffData": {
@@ -33,10 +33,10 @@
33
33
  }
34
34
  },
35
35
  "uncommon": {
36
- "type": "boolean"
36
+ "const": true
37
37
  },
38
38
  "monstrous": {
39
- "type": "boolean"
39
+ "const": true
40
40
  }
41
41
  },
42
42
  "additionalProperties": false
@@ -72,10 +72,10 @@
72
72
  }
73
73
  },
74
74
  "uncommon": {
75
- "type": "boolean"
75
+ "const": true
76
76
  },
77
77
  "monstrous": {
78
- "type": "boolean"
78
+ "const": true
79
79
  }
80
80
  },
81
81
  "additionalProperties": false,
@@ -114,10 +114,10 @@
114
114
  }
115
115
  },
116
116
  "uncommon": {
117
- "type": "boolean"
117
+ "const": true
118
118
  },
119
119
  "monstrous": {
120
- "type": "boolean"
120
+ "const": true
121
121
  },
122
122
  "_copy": {
123
123
  "$ref": "util-copy.json#/$defs/copyBlock_copy_generic"
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
3
  "$id": "fluff-class.json",
4
- "version": "1.0.1",
4
+ "version": "1.0.2",
5
5
  "type": "object",
6
6
  "$defs": {
7
7
  "_subclassFluffItemData": {
@@ -117,15 +117,6 @@
117
117
  },
118
118
  "images": {
119
119
  "oneOf": [
120
- {
121
- "type": "array",
122
- "items": {
123
- "$ref": "../entry.json#/$defs/entryImage"
124
- }
125
- },
126
- {
127
- "type": "null"
128
- },
129
120
  {
130
121
  "type": "array",
131
122
  "items": {
@@ -151,9 +142,15 @@
151
142
  },
152
143
  "classSource": {
153
144
  "$ref": "../util.json#/$defs/source"
145
+ },
146
+ "_copy": {
147
+ "$ref": "../util-copy.json#/$defs/copyBlock_copy_generic"
154
148
  }
155
149
  },
156
- "additionalProperties": false
150
+ "additionalProperties": false,
151
+ "required": [
152
+ "_copy"
153
+ ]
157
154
  }
158
155
  ]
159
156
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
3
  "$id": "fluff-races.json",
4
- "version": "2.1.2",
4
+ "version": "2.2.0",
5
5
  "type": "object",
6
6
  "$defs": {
7
7
  "raceFluffData": {
@@ -31,12 +31,6 @@
31
31
  "items": {
32
32
  "$ref": "entry.json"
33
33
  }
34
- },
35
- "uncommon": {
36
- "type": "boolean"
37
- },
38
- "monstrous": {
39
- "type": "boolean"
40
34
  }
41
35
  },
42
36
  "additionalProperties": false
@@ -70,12 +64,6 @@
70
64
  "items": {
71
65
  "$ref": "entry.json"
72
66
  }
73
- },
74
- "uncommon": {
75
- "type": "boolean"
76
- },
77
- "monstrous": {
78
- "type": "boolean"
79
67
  }
80
68
  },
81
69
  "additionalProperties": false,
@@ -113,12 +101,6 @@
113
101
  "$ref": "entry.json"
114
102
  }
115
103
  },
116
- "uncommon": {
117
- "type": "boolean"
118
- },
119
- "monstrous": {
120
- "type": "boolean"
121
- },
122
104
  "_copy": {
123
105
  "$ref": "util-copy.json#/$defs/copyBlock_copy_generic"
124
106
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
3
  "$id": "fluff-class.json",
4
- "version": "1.0.1",
4
+ "version": "1.0.2",
5
5
  "type": "object",
6
6
  "$defs": {
7
7
  "_subclassFluffItemData": {
@@ -117,15 +117,6 @@
117
117
  },
118
118
  "images": {
119
119
  "oneOf": [
120
- {
121
- "type": "array",
122
- "items": {
123
- "$ref": "../entry.json#/$defs/entryImage"
124
- }
125
- },
126
- {
127
- "type": "null"
128
- },
129
120
  {
130
121
  "type": "array",
131
122
  "items": {
@@ -151,9 +142,15 @@
151
142
  },
152
143
  "classSource": {
153
144
  "$ref": "../util.json#/$defs/source"
145
+ },
146
+ "_copy": {
147
+ "$ref": "../util-copy.json#/$defs/copyBlock_copy_generic"
154
148
  }
155
149
  },
156
- "additionalProperties": false
150
+ "additionalProperties": false,
151
+ "required": [
152
+ "_copy"
153
+ ]
157
154
  }
158
155
  ]
159
156
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
3
  "$id": "fluff-races.json",
4
- "version": "2.1.2",
4
+ "version": "2.2.0",
5
5
  "type": "object",
6
6
  "$defs": {
7
7
  "raceFluffData": {
@@ -31,12 +31,6 @@
31
31
  "items": {
32
32
  "$ref": "entry.json"
33
33
  }
34
- },
35
- "uncommon": {
36
- "type": "boolean"
37
- },
38
- "monstrous": {
39
- "type": "boolean"
40
34
  }
41
35
  },
42
36
  "additionalProperties": false
@@ -70,12 +64,6 @@
70
64
  "items": {
71
65
  "$ref": "entry.json"
72
66
  }
73
- },
74
- "uncommon": {
75
- "type": "boolean"
76
- },
77
- "monstrous": {
78
- "type": "boolean"
79
67
  }
80
68
  },
81
69
  "additionalProperties": false,
@@ -113,12 +101,6 @@
113
101
  "$ref": "entry.json"
114
102
  }
115
103
  },
116
- "uncommon": {
117
- "type": "boolean"
118
- },
119
- "monstrous": {
120
- "type": "boolean"
121
- },
122
104
  "_copy": {
123
105
  "$ref": "util-copy.json#/$defs/copyBlock_copy_generic"
124
106
  }