gff-nostream 1.3.1 → 1.3.3

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/dist/api.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { GFF3Item } from './util';
1
+ import { GFF3Feature } from './util';
2
2
  /** Parser options */
3
3
  export interface ParseOptions {
4
4
  /** Whether to resolve references to derives from features */
@@ -19,5 +19,13 @@ export interface ParseOptions {
19
19
  */
20
20
  parseAll?: boolean;
21
21
  }
22
- export declare function parseStringSync(str: string, inputOptions?: ParseOptions): GFF3Item[];
22
+ /**
23
+ * Synchronously parse a string containing GFF3 and return an array of the
24
+ * parsed items.
25
+ *
26
+ * @param str - GFF3 string
27
+ * @param inputOptions - Parsing options
28
+ * @returns array of parsed features, directives, comments and/or sequences
29
+ */
30
+ export declare function parseStringSync(str: string): GFF3Feature[];
23
31
  export { type GFF3FeatureLine, type GFF3Comment, type GFF3FeatureLineWithRefs, type GFF3Directive, type GFF3Sequence, type GFF3Feature, type GFF3Item, } from './util';
package/dist/api.js CHANGED
@@ -5,35 +5,26 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.parseStringSync = parseStringSync;
7
7
  const parse_1 = __importDefault(require("./parse"));
8
- // shared arg processing for the parse routines
9
- function _processParseOptions(options) {
10
- const out = Object.assign({ encoding: 'utf8', parseFeatures: true, parseDirectives: false, parseSequences: true, parseComments: false, disableDerivesFromReferences: false }, options);
11
- if (options.parseAll) {
12
- out.parseFeatures = true;
13
- out.parseDirectives = true;
14
- out.parseComments = true;
15
- out.parseSequences = true;
16
- }
17
- return out;
18
- }
19
- function parseStringSync(str, inputOptions = {}) {
20
- if (!str) {
21
- return [];
22
- }
23
- const options = _processParseOptions(inputOptions);
8
+ /**
9
+ * Synchronously parse a string containing GFF3 and return an array of the
10
+ * parsed items.
11
+ *
12
+ * @param str - GFF3 string
13
+ * @param inputOptions - Parsing options
14
+ * @returns array of parsed features, directives, comments and/or sequences
15
+ */
16
+ function parseStringSync(str) {
24
17
  const items = [];
25
- const push = items.push.bind(items);
26
18
  const parser = new parse_1.default({
27
- featureCallback: options.parseFeatures ? push : undefined,
28
- directiveCallback: options.parseDirectives ? push : undefined,
29
- commentCallback: options.parseComments ? push : undefined,
30
- sequenceCallback: options.parseSequences ? push : undefined,
31
- disableDerivesFromReferences: options.disableDerivesFromReferences || false,
19
+ featureCallback: arg => items.push(arg),
20
+ disableDerivesFromReferences: true,
32
21
  errorCallback: err => {
33
22
  throw err;
34
23
  },
35
24
  });
36
- str.split(/\r?\n/).forEach(parser.addLine.bind(parser));
25
+ for (const line of str.split(/\r?\n/)) {
26
+ parser.addLine(line);
27
+ }
37
28
  parser.finish();
38
29
  return items;
39
30
  }
package/dist/api.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":";;;;;AAgDA,0CA2BC;AA3ED,oDAA4B;AA0B5B,+CAA+C;AAC/C,SAAS,oBAAoB,CAAC,OAAqB;IACjD,MAAM,GAAG,mBACP,QAAQ,EAAE,MAAe,EACzB,aAAa,EAAE,IAAI,EACnB,eAAe,EAAE,KAAK,EACtB,cAAc,EAAE,IAAI,EACpB,aAAa,EAAE,KAAK,EACpB,4BAA4B,EAAE,KAAK,IAChC,OAAO,CACX,CAAA;IAED,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;QACrB,GAAG,CAAC,aAAa,GAAG,IAAI,CAAA;QACxB,GAAG,CAAC,eAAe,GAAG,IAAI,CAAA;QAC1B,GAAG,CAAC,aAAa,GAAG,IAAI,CAAA;QACxB,GAAG,CAAC,cAAc,GAAG,IAAI,CAAA;IAC3B,CAAC;IAED,OAAO,GAAG,CAAA;AACZ,CAAC;AAED,SAAgB,eAAe,CAC7B,GAAW,EACX,eAA6B,EAAE;IAE/B,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,OAAO,EA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A4B,EAAE,IAAI;QAClC,aAAa,EAAE,GAAG,CAAC,EAAE;YACnB,MAAM,GAAG,CAAA;QACX,CAAC;KACF,CAAC,CAAA;IAEF,KAAK,MAAM,IAAI,IAAI,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;QACtC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IACtB,CAAC;IACD,MAAM,CAAC,MAAM,EAAE,CAAA;IAEf,OAAO,KAAK,CAAA;AACd,CAAC"}
package/esm/api.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { GFF3Item } from './util';
1
+ import { GFF3Feature } from './util';
2
2
  /** Parser options */
3
3
  export interface ParseOptions {
4
4
  /** Whether to resolve references to derives from features */
@@ -19,5 +19,13 @@ export interface ParseOptions {
19
19
  */
20
20
  parseAll?: boolean;
21
21
  }
22
- export declare function parseStringSync(str: string, inputOptions?: ParseOptions): GFF3Item[];
22
+ /**
23
+ * Synchronously parse a string containing GFF3 and return an array of the
24
+ * parsed items.
25
+ *
26
+ * @param str - GFF3 string
27
+ * @param inputOptions - Parsing options
28
+ * @returns array of parsed features, directives, comments and/or sequences
29
+ */
30
+ export declare function parseStringSync(str: string): GFF3Feature[];
23
31
  export { type GFF3FeatureLine, type GFF3Comment, type GFF3FeatureLineWithRefs, type GFF3Directive, type GFF3Sequence, type GFF3Feature, type GFF3Item, } from './util';
package/esm/api.js CHANGED
@@ -1,41 +1,24 @@
1
1
  import Parser from './parse';
2
- // shared arg processing for the parse routines
3
- function _processParseOptions(options) {
4
- const out = {
5
- encoding: 'utf8',
6
- parseFeatures: true,
7
- parseDirectives: false,
8
- parseSequences: true,
9
- parseComments: false,
10
- disableDerivesFromReferences: false,
11
- ...options,
12
- };
13
- if (options.parseAll) {
14
- out.parseFeatures = true;
15
- out.parseDirectives = true;
16
- out.parseComments = true;
17
- out.parseSequences = true;
18
- }
19
- return out;
20
- }
21
- export function parseStringSync(str, inputOptions = {}) {
22
- if (!str) {
23
- return [];
24
- }
25
- const options = _processParseOptions(inputOptions);
2
+ /**
3
+ * Synchronously parse a string containing GFF3 and return an array of the
4
+ * parsed items.
5
+ *
6
+ * @param str - GFF3 string
7
+ * @param inputOptions - Parsing options
8
+ * @returns array of parsed features, directives, comments and/or sequences
9
+ */
10
+ export function parseStringSync(str) {
26
11
  const items = [];
27
- const push = items.push.bind(items);
28
12
  const parser = new Parser({
29
- featureCallback: options.parseFeatures ? push : undefined,
30
- directiveCallback: options.parseDirectives ? push : undefined,
31
- commentCallback: options.parseComments ? push : undefined,
32
- sequenceCallback: options.parseSequences ? push : undefined,
33
- disableDerivesFromReferences: options.disableDerivesFromReferences || false,
13
+ featureCallback: arg => items.push(arg),
14
+ disableDerivesFromReferences: true,
34
15
  errorCallback: err => {
35
16
  throw err;
36
17
  },
37
18
  });
38
- str.split(/\r?\n/).forEach(parser.addLine.bind(parser));
19
+ for (const line of str.split(/\r?\n/)) {
20
+ parser.addLine(line);
21
+ }
39
22
  parser.finish();
40
23
  return items;
41
24
  }
package/esm/api.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,SAAS,CAAA;AA0B5B,+CAA+C;AAC/C,SAAS,oBAAoB,CAAC,OAAqB;IACjD,MAAM,GAAG,GAAG;QACV,QAAQ,EAAE,MAAe;QACzB,aAAa,EAAE,IAAI;QACnB,eAAe,EAAE,KAAK;QACtB,cAAc,EAAE,IAAI;QACpB,aAAa,EAAE,KAAK;QACpB,4BAA4B,EAAE,KAAK;QACnC,GAAG,OAAO;KACX,CAAA;IAED,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;QACrB,GAAG,CAAC,aAAa,GAAG,IAAI,CAAA;QACxB,GAAG,CAAC,eAAe,GAAG,IAAI,CAAA;QAC1B,GAAG,CAAC,aAAa,GAAG,IAAI,CAAA;QACxB,GAAG,CAAC,cAAc,GAAG,IAAI,CAAA;IAC3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K,GAAkB,EAAE,CAAA;IAC/B,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC;QACxB,eAAe,EAAE,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC;QACvC,4BAA4B,EAAE,IAAI;QAClC,aAAa,EAAE,GAAG,CAAC,EAAE;YACnB,MAAM,GAAG,CAAA;QACX,CAAC;KACF,CAAC,CAAA;IAEF,KAAK,MAAM,IAAI,IAAI,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;QACtC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IACtB,CAAC;IACD,MAAM,CAAC,MAAM,EAAE,CAAA;IAEf,OAAO,KAAK,CAAA;AACd,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gff-nostream",
3
- "version": "1.3.1",
3
+ "version": "1.3.3",
4
4
  "description": "utilities to read GFF3 data",
5
5
  "license": "MIT",
6
6
  "repository": "cmdcolin/gff-nostream",
package/src/api.ts CHANGED
@@ -1,5 +1,12 @@
1
1
  import Parser from './parse'
2
- import { GFF3Item } from './util'
2
+ import {
3
+ GFF3Comment,
4
+ GFF3Directive,
5
+ GFF3Feature,
6
+ GFF3Item,
7
+ GFF3Sequence,
8
+ parseFeature,
9
+ } from './util'
3
10
 
4
11
  /** Parser options */
5
12
  export interface ParseOptions {
@@ -24,52 +31,27 @@ export interface ParseOptions {
24
31
 
25
32
  type ParseOptionsProcessed = Required<Omit<ParseOptions, 'parseAll'>>
26
33
 
27
- // shared arg processing for the parse routines
28
- function _processParseOptions(options: ParseOptions): ParseOptionsProcessed {
29
- const out = {
30
- encoding: 'utf8' as const,
31
- parseFeatures: true,
32
- parseDirectives: false,
33
- parseSequences: true,
34
- parseComments: false,
35
- disableDerivesFromReferences: false,
36
- ...options,
37
- }
38
-
39
- if (options.parseAll) {
40
- out.parseFeatures = true
41
- out.parseDirectives = true
42
- out.parseComments = true
43
- out.parseSequences = true
44
- }
45
-
46
- return out
47
- }
48
-
49
- export function parseStringSync(
50
- str: string,
51
- inputOptions: ParseOptions = {},
52
- ): GFF3Item[] {
53
- if (!str) {
54
- return []
55
- }
56
-
57
- const options = _processParseOptions(inputOptions)
58
- const items: GFF3Item[] = []
59
- const push = items.push.bind(items)
60
-
34
+ /**
35
+ * Synchronously parse a string containing GFF3 and return an array of the
36
+ * parsed items.
37
+ *
38
+ * @param str - GFF3 string
39
+ * @param inputOptions - Parsing options
40
+ * @returns array of parsed features, directives, comments and/or sequences
41
+ */
42
+ export function parseStringSync(str: string): GFF3Feature[] {
43
+ const items: GFF3Feature[] = []
61
44
  const parser = new Parser({
62
- featureCallback: options.parseFeatures ? push : undefined,
63
- directiveCallback: options.parseDirectives ? push : undefined,
64
- commentCallback: options.parseComments ? push : undefined,
65
- sequenceCallback: options.parseSequences ? push : undefined,
66
- disableDerivesFromReferences: options.disableDerivesFromReferences || false,
45
+ featureCallback: arg => items.push(arg),
46
+ disableDerivesFromReferences: true,
67
47
  errorCallback: err => {
68
48
  throw err
69
49
  },
70
50
  })
71
51
 
72
- str.split(/\r?\n/).forEach(parser.addLine.bind(parser))
52
+ for (const line of str.split(/\r?\n/)) {
53
+ parser.addLine(line)
54
+ }
73
55
  parser.finish()
74
56
 
75
57
  return items