gff-nostream 1.3.1 → 1.3.4

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,23 +1,11 @@
1
- import { GFF3Item } from './util';
2
- /** Parser options */
3
- export interface ParseOptions {
4
- /** Whether to resolve references to derives from features */
5
- disableDerivesFromReferences?: boolean;
6
- /** Text encoding of the input GFF3. default 'utf8' */
7
- encoding?: BufferEncoding;
8
- /** Whether to parse features, default true */
9
- parseFeatures?: boolean;
10
- /** Whether to parse directives, default false */
11
- parseDirectives?: boolean;
12
- /** Whether to parse comments, default false */
13
- parseComments?: boolean;
14
- /** Whether to parse sequences, default true */
15
- parseSequences?: boolean;
16
- /**
17
- * Parse all features, directives, comments, and sequences. Overrides other
18
- * parsing options. Default false.
19
- */
20
- parseAll?: boolean;
21
- }
22
- export declare function parseStringSync(str: string, inputOptions?: ParseOptions): GFF3Item[];
1
+ import { GFF3Feature } from './util';
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 declare function parseStringSync(str: string): GFF3Feature[];
23
11
  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,GAA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A,0CAgBC;AA3BD,oDAA4B;AAG5B;;;;;;;GAOG;AACH,SAAgB,eAAe,CAAC,GAAW;IACzC,MAAM,KAAK,GAAkB,EAAE,CAAA;IAC/B,MAAM,MAAM,GAAG,IAAI,eAAM,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/esm/api.d.ts CHANGED
@@ -1,23 +1,11 @@
1
- import { GFF3Item } from './util';
2
- /** Parser options */
3
- export interface ParseOptions {
4
- /** Whether to resolve references to derives from features */
5
- disableDerivesFromReferences?: boolean;
6
- /** Text encoding of the input GFF3. default 'utf8' */
7
- encoding?: BufferEncoding;
8
- /** Whether to parse features, default true */
9
- parseFeatures?: boolean;
10
- /** Whether to parse directives, default false */
11
- parseDirectives?: boolean;
12
- /** Whether to parse comments, default false */
13
- parseComments?: boolean;
14
- /** Whether to parse sequences, default true */
15
- parseSequences?: boolean;
16
- /**
17
- * Parse all features, directives, comments, and sequences. Overrides other
18
- * parsing options. Default false.
19
- */
20
- parseAll?: boolean;
21
- }
22
- export declare function parseStringSync(str: string, inputOptions?: ParseOptions): GFF3Item[];
1
+ import { GFF3Feature } from './util';
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 declare function parseStringSync(str: string): GFF3Feature[];
23
11
  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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B,EAAE,OAAO,CAAC,4BAA4B,IAAI,KAAK;QAC3E,aAAa,EAAE,GAAG,CAAC,EAAE;YACnB,MAAM,GAAG,CAAA;QACX,CAAC;KACF,CAAC,CAAA;IAEF,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAA;IACvD,MAAM,CAAC,MAAM,EAAE,CAAA;IAEf,OAAO,KAAK,CAAA;AACd,CAAC"}
1
+ {"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,SAAS,CAAA;AAG5B;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAAC,GAAW;IACzC,MAAM,KAAK,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.4",
4
4
  "description": "utilities to read GFF3 data",
5
5
  "license": "MIT",
6
6
  "repository": "cmdcolin/gff-nostream",
package/src/api.ts CHANGED
@@ -1,75 +1,27 @@
1
1
  import Parser from './parse'
2
- import { GFF3Item } from './util'
3
-
4
- /** Parser options */
5
- export interface ParseOptions {
6
- /** Whether to resolve references to derives from features */
7
- disableDerivesFromReferences?: boolean
8
- /** Text encoding of the input GFF3. default 'utf8' */
9
- encoding?: BufferEncoding
10
- /** Whether to parse features, default true */
11
- parseFeatures?: boolean
12
- /** Whether to parse directives, default false */
13
- parseDirectives?: boolean
14
- /** Whether to parse comments, default false */
15
- parseComments?: boolean
16
- /** Whether to parse sequences, default true */
17
- parseSequences?: boolean
18
- /**
19
- * Parse all features, directives, comments, and sequences. Overrides other
20
- * parsing options. Default false.
21
- */
22
- parseAll?: boolean
23
- }
24
-
25
- type ParseOptionsProcessed = Required<Omit<ParseOptions, 'parseAll'>>
26
-
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
-
2
+ import { GFF3Feature } from './util'
3
+
4
+ /**
5
+ * Synchronously parse a string containing GFF3 and return an array of the
6
+ * parsed items.
7
+ *
8
+ * @param str - GFF3 string
9
+ * @param inputOptions - Parsing options
10
+ * @returns array of parsed features, directives, comments and/or sequences
11
+ */
12
+ export function parseStringSync(str: string): GFF3Feature[] {
13
+ const items: GFF3Feature[] = []
61
14
  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,
15
+ featureCallback: arg => items.push(arg),
16
+ disableDerivesFromReferences: true,
67
17
  errorCallback: err => {
68
18
  throw err
69
19
  },
70
20
  })
71
21
 
72
- str.split(/\r?\n/).forEach(parser.addLine.bind(parser))
22
+ for (const line of str.split(/\r?\n/)) {
23
+ parser.addLine(line)
24
+ }
73
25
  parser.finish()
74
26
 
75
27
  return items