gff-nostream 1.3.9 → 2.0.0

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/esm/util.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,qEAAqE;AAErE;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CAAC,SAAiB;IACxC,OAAO,SAAS,CAAC,UAAU,CAAC,oBAAoB,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE,CAChE,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CACvC,CAAA;AACH,CAAC;AAED,SAAS,OAAO,CAAC,KAAa,EAAE,CAAkB;IAChD,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE;QACnC,MAAM,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;QACxE,OAAO,IAAI,GAAG,EAAE,CAAA;IAClB,CAAC,CAAC,CAAA;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,MAAM,CAAC,MAAuB;IAC5C,OAAO,OAAO,CAAC,0CAA0C,EAAE,MAAM,CAAC,CAAA;AACpE,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,MAAuB;IAClD,OAAO,OAAO,CAAC,sCAAsC,EAAE,MAAM,CAAC,CAAA;AAChE,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,UAAkB;IAChD,IAAI,CAAC,UAAU,CAAC,MAAM,IAAI,UAAU,KAAK,GAAG,EAAE,CAAC;QAC7C,OAAO,EAAE,CAAA;IACX,CAAC;IAED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C,CAAC,CAAC,IAAI,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,KAC9D,GAAG,CAAC,QACN,IAAI,CAAA;AACN,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CACxB,WAK4E;IAE5E,SAAS,gBAAgB,CACvB,IAA0E;QAE1E,IAAI,YAAY,IAAI,IAAI,EAAE,CAAC;YACzB,OAAO,aAAa,CAAC,IAAI,CAAC,CAAA;QAC5B,CAAC;QACD,IAAI,WAAW,IAAI,IAAI,EAAE,CAAC;YACxB,OAAO,eAAe,CAAC,IAAI,CAAC,CAAA;QAC9B,CAAC;QACD,IAAI,UAAU,IAAI,IAAI,EAAE,CAAC;YACvB,OAAO,cAAc,CAAC,IAAI,CAAC,CAAA;QAC7B,CAAC;QACD,IAAI,SAAS,IAAI,IAAI,EAAE,CAAC;YACtB,OAAO,aAAa,CAAC,IAAI,CAAC,CAAA;QAC5B,CAAC;QACD,OAAO,wCAAwC,CAAA;IACjD,CAAC;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC;QAC/B,OAAO,WAAW,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAA;IAC1C,CAAC;IACD,OAAO,gBAAgB,CAAC,WAAW,CAAC,CAAA;AACtC,CAAC;AAsCD,SAAS,sBAAsB,CAC7B,WAAsD;IAEtD,OAAO;IACL,uEAAuE;IACtE,WAAuC,CAAC,cAAc,KAAK,SAAS;QACrE,uEAAuE;QACtE,WAAuC,CAAC,gBAAgB,KAAK,SAAS,CACxE,CAAA;AACH,CAAC"}
package/package.json CHANGED
@@ -1,11 +1,19 @@
1
1
  {
2
2
  "name": "gff-nostream",
3
- "version": "1.3.9",
3
+ "version": "2.0.0",
4
4
  "description": "utilities to read GFF3 data",
5
5
  "license": "MIT",
6
6
  "repository": "cmdcolin/gff-nostream",
7
- "main": "dist/index.js",
8
- "module": "esm/index.js",
7
+ "type": "module",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ "import": {
11
+ "import": "./esm/index.js"
12
+ },
13
+ "require": {
14
+ "require": "./dist/index.js"
15
+ }
16
+ },
9
17
  "author": {
10
18
  "name": "Colin Diesh",
11
19
  "email": "colin.diesh@gmail.com",
@@ -18,13 +26,15 @@
18
26
  ],
19
27
  "scripts": {
20
28
  "test": "vitest",
29
+ "benchonly": "vitest bench",
30
+ "bench": "./scripts/build-both-branches.sh \"$BRANCH1\" \"$BRANCH2\" && vitest bench",
21
31
  "clean": "rimraf dist esm",
22
- "lint": "eslint src test",
32
+ "lint": "eslint --report-unused-disable-directives --max-warnings 0",
23
33
  "docs": "documentation readme src/api.ts --section=API --shallow && yarn format",
24
34
  "format": "prettier --write .",
25
35
  "prebuild": "yarn clean",
26
- "build:esm": "tsc --target es2018 --outDir esm",
27
- "build:es5": "tsc --target es2015 --module commonjs --outDir dist",
36
+ "build:esm": "tsc --target esnext --outDir esm",
37
+ "build:es5": "tsc --target es2020 --module commonjs --outDir dist",
28
38
  "postbuild:es5": "echo '{\"type\": \"commonjs\"}' > dist/package.json",
29
39
  "build": "yarn build:es5 && yarn build:esm",
30
40
  "prepublishOnly": "yarn test --run && yarn build",
@@ -38,16 +48,17 @@
38
48
  "genomics"
39
49
  ],
40
50
  "devDependencies": {
41
- "@types/node": "^22.15.17",
42
- "@typescript-eslint/eslint-plugin": "^8.4.0",
43
- "@typescript-eslint/parser": "^8.4.0",
44
- "@vitest/coverage-v8": "^3.0.1",
51
+ "@types/node": "^24.10.1",
52
+ "@typescript-eslint/eslint-plugin": "^8.48.0",
53
+ "@typescript-eslint/parser": "^8.48.0",
54
+ "@vitest/coverage-v8": "^4.0.14",
45
55
  "documentation": "^14.0.1",
46
- "eslint": "^9.9.1",
47
- "prettier": "^3.3.3",
48
- "rimraf": "^6.0.1",
49
- "typescript": "^5.5.4",
50
- "typescript-eslint": "^8.4.0",
51
- "vitest": "^3.0.1"
56
+ "eslint": "^9.39.1",
57
+ "eslint-plugin-import": "^2.32.0",
58
+ "prettier": "^3.6.2",
59
+ "rimraf": "^6.1.2",
60
+ "typescript": "^5.9.3",
61
+ "typescript-eslint": "^8.48.0",
62
+ "vitest": "^4.0.14"
52
63
  }
53
64
  }
package/src/api.ts CHANGED
@@ -1,5 +1,12 @@
1
- import Parser from './parse'
2
- import { GFF3Feature } from './util'
1
+ import Parser from './parse.ts'
2
+ import { parseFieldsArray } from './util.ts'
3
+
4
+ import type { GFF3Feature, GFF3FeatureLine } from './util.ts'
5
+
6
+ export interface LineRecord {
7
+ fields: string[]
8
+ lineHash?: string | number
9
+ }
3
10
 
4
11
  /**
5
12
  * Synchronously parse a string containing GFF3 and return an array of the
@@ -15,7 +22,7 @@ export function parseStringSync(str: string): GFF3Feature[] {
15
22
  featureCallback: arg => items.push(arg),
16
23
  disableDerivesFromReferences: true,
17
24
  errorCallback: err => {
18
- throw err
25
+ throw new Error(err)
19
26
  },
20
27
  })
21
28
 
@@ -27,12 +34,70 @@ export function parseStringSync(str: string): GFF3Feature[] {
27
34
  return items
28
35
  }
29
36
 
30
- export {
31
- type GFF3FeatureLine,
32
- type GFF3Comment,
33
- type GFF3FeatureLineWithRefs,
34
- type GFF3Directive,
35
- type GFF3Sequence,
36
- type GFF3Feature,
37
- type GFF3Item,
38
- } from './util'
37
+ /**
38
+ * Synchronously parse an array of strings containing GFF3 and return an array of the
39
+ * parsed items.
40
+ *
41
+ * @param arr - GFF3 array of strings
42
+ * @param inputOptions - Parsing options
43
+ * @returns array of parsed features, directives, comments and/or sequences
44
+ */
45
+ export function parseArraySync(arr: string[]): GFF3Feature[] {
46
+ const items: GFF3Feature[] = []
47
+ const parser = new Parser({
48
+ featureCallback: arg => items.push(arg),
49
+ disableDerivesFromReferences: true,
50
+ errorCallback: err => {
51
+ throw new Error(err)
52
+ },
53
+ })
54
+
55
+ for (const line of arr) {
56
+ parser.addLine(line)
57
+ }
58
+ parser.finish()
59
+
60
+ return items
61
+ }
62
+
63
+ /**
64
+ * Synchronously parse an array of LineRecord objects containing pre-split GFF3
65
+ * fields and return an array of the parsed items.
66
+ *
67
+ * @param records - Array of LineRecord objects with fields array and optional lineHash
68
+ * @returns array of parsed features
69
+ */
70
+ export function parseRecordsSync(records: LineRecord[]): GFF3Feature[] {
71
+ const items: GFF3Feature[] = []
72
+ const parser = new Parser({
73
+ featureCallback: arg => items.push(arg),
74
+ disableDerivesFromReferences: true,
75
+ errorCallback: err => {
76
+ throw new Error(err)
77
+ },
78
+ })
79
+
80
+ for (const record of records) {
81
+ const featureLine: GFF3FeatureLine = parseFieldsArray(record.fields)
82
+ if (record.lineHash !== undefined) {
83
+ if (!featureLine.attributes) {
84
+ featureLine.attributes = {}
85
+ }
86
+ featureLine.attributes._lineHash = [String(record.lineHash)]
87
+ }
88
+ parser.addParsedFeatureLine(featureLine)
89
+ }
90
+ parser.finish()
91
+
92
+ return items
93
+ }
94
+
95
+ export type {
96
+ GFF3Comment,
97
+ GFF3Directive,
98
+ GFF3Feature,
99
+ GFF3FeatureLine,
100
+ GFF3FeatureLineWithRefs,
101
+ GFF3Item,
102
+ GFF3Sequence,
103
+ } from './util.ts'
package/src/index.ts CHANGED
@@ -1,12 +1,13 @@
1
- import { parseStringSync } from './api'
2
- export { parseStringSync }
1
+ import { parseArraySync, parseRecordsSync, parseStringSync } from './api.ts'
2
+ export { parseArraySync, parseRecordsSync, parseStringSync }
3
3
 
4
4
  export type {
5
5
  GFF3Comment,
6
- GFF3Feature,
7
6
  GFF3Directive,
8
- GFF3FeatureLineWithRefs,
7
+ GFF3Feature,
9
8
  GFF3FeatureLine,
9
+ GFF3FeatureLineWithRefs,
10
10
  GFF3Item,
11
11
  GFF3Sequence,
12
- } from './api'
12
+ LineRecord,
13
+ } from './api.ts'
package/src/parse.ts CHANGED
@@ -1,44 +1,15 @@
1
- import * as GFF3 from './util'
1
+ import * as GFF3 from './util.ts'
2
2
 
3
3
  const containerAttributes = {
4
4
  Parent: 'child_features' as const,
5
5
  Derives_from: 'derived_features' as const,
6
6
  }
7
7
 
8
- export class FASTAParser {
9
- seqCallback: (sequence: GFF3.GFF3Sequence) => void
10
- currentSequence:
11
- | { id: string; sequence: string; description?: string }
12
- | undefined
13
-
14
- constructor(seqCallback: (sequence: GFF3.GFF3Sequence) => void) {
15
- this.seqCallback = seqCallback
16
- this.currentSequence = undefined
17
- }
18
-
19
- addLine(line: string): void {
20
- const defMatch = /^>\s*(\S+)\s*(.*)/.exec(line)
21
- if (defMatch) {
22
- this._flush()
23
- this.currentSequence = { id: defMatch[1], sequence: '' }
24
- if (defMatch[2]) {
25
- this.currentSequence.description = defMatch[2].trim()
26
- }
27
- } else if (this.currentSequence && /\S/.test(line)) {
28
- this.currentSequence.sequence += line.replaceAll(/\s/g, '')
29
- }
30
- }
31
-
32
- private _flush() {
33
- if (this.currentSequence) {
34
- this.seqCallback(this.currentSequence)
35
- }
36
- }
37
-
38
- finish(): void {
39
- this._flush()
40
- }
41
- }
8
+ const featureLineRegex = /^\s*[^#\s>]/
9
+ const commentOrDirectiveRegex = /^\s*(#+)(.*)/
10
+ const blankLineRegex = /^\s*$/
11
+ const fastaStartRegex = /^\s*>/
12
+ const lineEndingRegex = /\r?\n?$/g
42
13
 
43
14
  interface ParserArgs {
44
15
  featureCallback?(feature: GFF3.GFF3Feature): void
@@ -46,7 +17,6 @@ interface ParserArgs {
46
17
  commentCallback?(comment: GFF3.GFF3Comment): void
47
18
  errorCallback?(error: string): void
48
19
  directiveCallback?(directive: GFF3.GFF3Directive): void
49
- sequenceCallback?(sequence: GFF3.GFF3Sequence): void
50
20
  bufferSize?: number
51
21
  disableDerivesFromReferences?: boolean
52
22
  }
@@ -63,12 +33,7 @@ export default class Parser {
63
33
  errorCallback: (error: string) => void
64
34
  disableDerivesFromReferences: boolean
65
35
  directiveCallback: (directive: GFF3.GFF3Directive) => void
66
- sequenceCallback: (sequence: GFF3.GFF3Sequence) => void
67
36
  bufferSize: number
68
- fastaParser: FASTAParser | undefined = undefined
69
- // if this is true, the parser ignores the
70
- // rest of the lines in the file. currently
71
- // set when the file switches over to FASTA
72
37
  eof = false
73
38
  lineNumber = 0
74
39
  // features that we have to keep on hand for now because they
@@ -99,7 +64,6 @@ export default class Parser {
99
64
  this.commentCallback = args.commentCallback || nullFunc
100
65
  this.errorCallback = args.errorCallback || nullFunc
101
66
  this.directiveCallback = args.directiveCallback || nullFunc
102
- this.sequenceCallback = args.sequenceCallback || nullFunc
103
67
  this.disableDerivesFromReferences =
104
68
  args.disableDerivesFromReferences || false
105
69
 
@@ -108,68 +72,63 @@ export default class Parser {
108
72
  }
109
73
 
110
74
  addLine(line: string): void {
111
- // if we have transitioned to a fasta section, just delegate to that parser
112
- if (this.fastaParser) {
113
- this.fastaParser.addLine(line)
114
- return
115
- }
116
75
  if (this.eof) {
117
- // otherwise, if we are done, ignore this line
118
76
  return
119
77
  }
120
78
 
121
79
  this.lineNumber += 1
122
80
 
123
- if (/^\s*[^#\s>]/.test(line)) {
81
+ if (featureLineRegex.test(line)) {
124
82
  // feature line, most common case
125
83
  this._bufferLine(line)
126
84
  return
127
85
  }
128
86
 
129
- const match = /^\s*(#+)(.*)/.exec(line)
87
+ const match = commentOrDirectiveRegex.exec(line)
130
88
  if (match) {
131
89
  // directive or comment
132
90
  const [, hashsigns] = match
133
91
  let [, , contents] = match
134
92
 
135
- if (hashsigns.length === 3) {
93
+ if (hashsigns!.length === 3) {
136
94
  // sync directive, all forward-references are resolved.
137
95
  this._emitAllUnderConstructionFeatures()
138
- } else if (hashsigns.length === 2) {
96
+ } else if (hashsigns!.length === 2) {
139
97
  const directive = GFF3.parseDirective(line)
140
98
  if (directive) {
141
99
  if (directive.directive === 'FASTA') {
142
100
  this._emitAllUnderConstructionFeatures()
143
101
  this.eof = true
144
- this.fastaParser = new FASTAParser(this.sequenceCallback)
145
102
  } else {
146
103
  this._emitItem(directive)
147
104
  }
148
105
  }
149
106
  } else {
150
- contents = contents.replace(/\s*/, '')
151
- this._emitItem({ comment: contents })
107
+ this._emitItem({ comment: contents!.trimStart() })
152
108
  }
153
- } else if (/^\s*$/.test(line)) {
109
+ } else if (blankLineRegex.test(line)) {
154
110
  // blank line, do nothing
155
- } else if (/^\s*>/.test(line)) {
156
- // implicit beginning of a FASTA section
111
+ } else if (fastaStartRegex.test(line)) {
112
+ // implicit beginning of a FASTA section, stop parsing
157
113
  this._emitAllUnderConstructionFeatures()
158
114
  this.eof = true
159
- this.fastaParser = new FASTAParser(this.sequenceCallback)
160
- this.fastaParser.addLine(line)
161
115
  } else {
162
116
  // it's a parse error
163
- const errLine = line.replaceAll(/\r?\n?$/g, '')
117
+ const errLine = line.replaceAll(lineEndingRegex, '')
164
118
  throw new Error(`GFF3 parse error. Cannot parse '${errLine}'.`)
165
119
  }
166
120
  }
167
121
 
122
+ addParsedFeatureLine(featureLine: GFF3.GFF3FeatureLine): void {
123
+ if (this.eof) {
124
+ return
125
+ }
126
+ this.lineNumber += 1
127
+ this._bufferParsedLine(featureLine)
128
+ }
129
+
168
130
  finish(): void {
169
131
  this._emitAllUnderConstructionFeatures()
170
- if (this.fastaParser) {
171
- this.fastaParser.finish()
172
- }
173
132
  this.endCallback()
174
133
  }
175
134
 
@@ -194,11 +153,17 @@ export default class Parser {
194
153
  delete this._completedReferences[id]
195
154
  })
196
155
  item.forEach(i => {
156
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
197
157
  if (i.child_features) {
198
- i.child_features.forEach(c => _unbufferItem(c))
158
+ i.child_features.forEach(c => {
159
+ _unbufferItem(c)
160
+ })
199
161
  }
162
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
200
163
  if (i.derived_features) {
201
- i.derived_features.forEach(d => _unbufferItem(d))
164
+ i.derived_features.forEach(d => {
165
+ _unbufferItem(d)
166
+ })
202
167
  }
203
168
  })
204
169
  }
@@ -229,26 +194,23 @@ export default class Parser {
229
194
 
230
195
  // if we have any orphans hanging around still, this is a
231
196
  // problem. die with a parse error
232
- if (Array.from(Object.values(this._underConstructionOrphans)).length) {
197
+ const orphanKeys = Object.keys(this._underConstructionOrphans)
198
+ if (orphanKeys.length) {
233
199
  throw new Error(
234
- `some features reference other features that do not exist in the file (or in the same '###' scope). ${Object.keys(
235
- this._underConstructionOrphans,
236
- ).join(',')}`,
200
+ `some features reference other features that do not exist in the file (or in the same '###' scope). ${orphanKeys.join(',')}`,
237
201
  )
238
202
  }
239
203
  }
240
204
 
241
- // do the right thing with a newly-parsed feature line
242
205
  private _bufferLine(line: string) {
243
- const rawFeatureLine = GFF3.parseFeature(line)
244
- const featureLine: GFF3.GFF3FeatureLineWithRefs = {
245
- ...rawFeatureLine,
246
- child_features: [],
247
- derived_features: [],
248
- }
249
- // featureLine._lineNumber = this.lineNumber //< debugging aid
206
+ this._bufferParsedLine(GFF3.parseFeature(line))
207
+ }
208
+
209
+ private _bufferParsedLine(rawFeatureLine: GFF3.GFF3FeatureLine) {
210
+ const featureLine = rawFeatureLine as GFF3.GFF3FeatureLineWithRefs
211
+ featureLine.child_features = []
212
+ featureLine.derived_features = []
250
213
 
251
- // NOTE: a feature is an arrayref of one or more feature lines.
252
214
  const ids = featureLine.attributes?.ID || []
253
215
  const parents = featureLine.attributes?.Parent || []
254
216
  const derives = this.disableDerivesFromReferences
@@ -256,8 +218,6 @@ export default class Parser {
256
218
  : featureLine.attributes?.Derives_from || []
257
219
 
258
220
  if (!ids.length && !parents.length && !derives.length) {
259
- // if it has no IDs and does not refer to anything, we can just
260
- // output it
261
221
  this._emitItem([featureLine])
262
222
  return
263
223
  }
@@ -266,7 +226,6 @@ export default class Parser {
266
226
  ids.forEach(id => {
267
227
  const existing = this._underConstructionById[id]
268
228
  if (existing) {
269
- // another location of the same feature
270
229
  if (existing[existing.length - 1].type !== featureLine.type) {
271
230
  this._parseError(
272
231
  `multi-line feature "${id}" has inconsistent types: "${
@@ -277,8 +236,6 @@ export default class Parser {
277
236
  existing.push(featureLine)
278
237
  feature = existing
279
238
  } else {
280
- // haven't seen it yet, so buffer it so we can attach
281
- // child features to it
282
239
  feature = [featureLine]
283
240
 
284
241
  this._enforceBufferSizeLimit(1)
@@ -287,13 +244,12 @@ export default class Parser {
287
244
  }
288
245
  this._underConstructionById[id] = feature
289
246
 
290
- // see if we have anything buffered that refers to it
291
247
  this._resolveReferencesTo(feature, id)
292
248
  }
293
249
  })
294
250
 
295
- // try to resolve all its references
296
251
  this._resolveReferencesFrom(
252
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
297
253
  feature || [featureLine],
298
254
  { Parent: parents, Derives_from: derives },
299
255
  ids,
@@ -302,20 +258,13 @@ export default class Parser {
302
258
 
303
259
  private _resolveReferencesTo(feature: GFF3.GFF3Feature, id: string) {
304
260
  const references = this._underConstructionOrphans[id]
305
- // references is of the form
306
- // {
307
- // 'Parent' : [ orphans that have a Parent attr referencing this feature ],
308
- // 'Derives_from' : [ orphans that have a Derives_from attr referencing this feature ],
309
- // }
310
261
  if (!references) {
311
262
  return
312
263
  }
313
- feature.forEach(loc => {
264
+ for (const loc of feature) {
314
265
  loc.child_features.push(...references.Parent)
315
- })
316
- feature.forEach(loc => {
317
266
  loc.derived_features.push(...references.Derives_from)
318
- })
267
+ }
319
268
  delete this._underConstructionOrphans[id]
320
269
  }
321
270
 
@@ -329,72 +278,58 @@ export default class Parser {
329
278
  references: { Parent: string[]; Derives_from: string[] },
330
279
  ids: string[],
331
280
  ) {
332
- // this is all a bit more awkward in javascript than it was in perl
333
- function postSet(
334
- obj: Record<string, Record<string, boolean | undefined> | undefined>,
335
- slot1: string,
336
- slot2: string,
337
- ) {
338
- let subObj = obj[slot1]
339
- if (!subObj) {
340
- subObj = {}
341
- obj[slot1] = subObj
342
- }
343
- const returnVal = subObj[slot2] || false
344
- subObj[slot2] = true
345
- return returnVal
346
- }
347
-
348
- references.Parent.forEach(toId => {
281
+ for (const toId of references.Parent) {
349
282
  const otherFeature = this._underConstructionById[toId]
350
283
  if (otherFeature) {
351
- const pname = containerAttributes.Parent
352
- if (
353
- !ids.filter(id =>
354
- postSet(this._completedReferences, id, `Parent,${toId}`),
355
- ).length
356
- ) {
357
- otherFeature.forEach(location => {
358
- location[pname].push(feature)
359
- })
284
+ let dominated = false
285
+ for (const id of ids) {
286
+ const domKey = `Parent,${toId}`
287
+ const rec = this._completedReferences[id] || (this._completedReferences[id] = {})
288
+ if (rec[domKey]) {
289
+ dominated = true
290
+ }
291
+ rec[domKey] = true
292
+ }
293
+ if (!dominated) {
294
+ for (const location of otherFeature) {
295
+ location.child_features.push(feature)
296
+ }
360
297
  }
361
298
  } else {
362
299
  let ref = this._underConstructionOrphans[toId]
363
300
  if (!ref) {
364
- ref = {
365
- Parent: [],
366
- Derives_from: [],
367
- }
301
+ ref = { Parent: [], Derives_from: [] }
368
302
  this._underConstructionOrphans[toId] = ref
369
303
  }
370
304
  ref.Parent.push(feature)
371
305
  }
372
- })
306
+ }
373
307
 
374
- references.Derives_from.forEach(toId => {
308
+ for (const toId of references.Derives_from) {
375
309
  const otherFeature = this._underConstructionById[toId]
376
310
  if (otherFeature) {
377
- const pname = containerAttributes.Derives_from
378
- if (
379
- !ids.filter(id =>
380
- postSet(this._completedReferences, id, `Derives_from,${toId}`),
381
- ).length
382
- ) {
383
- otherFeature.forEach(location => {
384
- location[pname].push(feature)
385
- })
311
+ let dominated = false
312
+ for (const id of ids) {
313
+ const domKey = `Derives_from,${toId}`
314
+ const rec = this._completedReferences[id] || (this._completedReferences[id] = {})
315
+ if (rec[domKey]) {
316
+ dominated = true
317
+ }
318
+ rec[domKey] = true
319
+ }
320
+ if (!dominated) {
321
+ for (const location of otherFeature) {
322
+ location.derived_features.push(feature)
323
+ }
386
324
  }
387
325
  } else {
388
326
  let ref = this._underConstructionOrphans[toId]
389
327
  if (!ref) {
390
- ref = {
391
- Parent: [],
392
- Derives_from: [],
393
- }
328
+ ref = { Parent: [], Derives_from: [] }
394
329
  this._underConstructionOrphans[toId] = ref
395
330
  }
396
331
  ref.Derives_from.push(feature)
397
332
  }
398
- })
333
+ }
399
334
  }
400
335
  }