bfj 5.3.1 → 6.1.2

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/.eslintrc CHANGED
@@ -83,7 +83,7 @@ rules:
83
83
  no-extra-bind: 2
84
84
  no-extra-boolean-cast: 2
85
85
  no-extra-label: 2
86
- no-extra-parens: [ 2, "all" ]
86
+ no-extra-parens: [ 2, "all", { "nestedBinaryExpressions": false } ]
87
87
  no-extra-semi: 2
88
88
  no-fallthrough: 0
89
89
  no-floating-decimal: 2
package/.gitlab-ci.yml ADDED
@@ -0,0 +1,25 @@
1
+ cache:
2
+ key: "$CI_JOB_NAME"
3
+ untracked: true
4
+ paths:
5
+ - node_modules/
6
+
7
+ before_script:
8
+ - npm install
9
+
10
+ .test_template: &npm_test
11
+ script:
12
+ - npm run lint
13
+ - npm test
14
+
15
+ test:node6:
16
+ image: node:6
17
+ <<: *npm_test
18
+
19
+ test:node8:
20
+ image: node:8
21
+ <<: *npm_test
22
+
23
+ test:node10:
24
+ image: node:10
25
+ <<: *npm_test
package/AUTHORS CHANGED
@@ -1,4 +1,4 @@
1
- Phil Booth <pmbooth@gmail.com> (https://github.com/philbooth)
1
+ Phil Booth <pmbooth@gmail.com> (https://philbooth.me/)
2
2
  Rowan Manning (https://github.com/rowanmanning)
3
3
  Benedikt Rötsch (https://github.com/axe312ger)
4
4
 
package/CONTRIBUTING.md CHANGED
@@ -30,8 +30,8 @@
30
30
  if the change is one that you think
31
31
  needs some discussion.
32
32
 
33
- [readme]: https://github.com/philbooth/bfj/blob/master/README.md
34
- [authors]: https://github.com/philbooth/bfj/blob/master/AUTHORS
35
- [newissue]: https://github.com/philbooth/bfj/issues/new
36
- [issues]: https://github.com/philbooth/bfj/issues
33
+ [readme]: https://gitlab.com/philbooth/bfj/blob/master/README.md
34
+ [authors]: https://gitlab.com/philbooth/bfj/blob/master/AUTHORS
35
+ [newissue]: https://gitlab.com/philbooth/bfj/issues/new
36
+ [issues]: https://gitlab.com/philbooth/bfj/issues
37
37
 
package/HISTORY.md CHANGED
@@ -1,5 +1,55 @@
1
1
  # History
2
2
 
3
+ ## 6.1.2
4
+
5
+ ### Bug fixes
6
+
7
+ * eventify: escape object keys (910ad08)
8
+
9
+ ### Other changes
10
+
11
+ * package: update deps (aafb4ff)
12
+
13
+ ## 6.1.1
14
+
15
+ ### Bug fixes
16
+
17
+ * eventify: don't serialise NaN or infinities (3c50fe4)
18
+
19
+ ### Other changes
20
+
21
+ * deps: npm update (b3c86d0)
22
+ * project: add package lock file (63df27d)
23
+ * project: migrate to gitlab (26746a0)
24
+
25
+ ## 6.1.0
26
+
27
+ ### New features
28
+
29
+ * match: pass a depth argument to selector predicates (af15939)
30
+
31
+ ### Other changes
32
+
33
+ * tests: delete unused var (f10902a)
34
+ * ci: reinstate tests in node 9 (7cd2594)
35
+ * ci: temporarily disable tests in node 9 (e27ccd0)
36
+
37
+ ## 6.0.0
38
+
39
+ ### Breaking changes
40
+
41
+ * eventify: distinguish between syntax and operational errors (e7bc23d)
42
+ * walk: distinguish between syntax and operational errors (419ddae)
43
+
44
+ ### New features
45
+
46
+ * streams: expose a highWaterMark option (626f755)
47
+ * match: implement a streaming match api (e2e320d)
48
+
49
+ ### Other changes
50
+
51
+ * docs: note the end of node-4 maintenance (0a32090)
52
+
3
53
  ## 5.3.1
4
54
 
5
55
  ### Bug fixes
package/README.md CHANGED
@@ -1,8 +1,9 @@
1
1
  # BFJ
2
2
 
3
- [![Package status](https://img.shields.io/npm/v/bfj.svg?style=flat-square)](https://www.npmjs.com/package/bfj)
4
- [![Build status](https://img.shields.io/travis/philbooth/bfj.svg?style=flat-square)](https://travis-ci.org/philbooth/bfj)
5
- [![License](https://img.shields.io/github/license/philbooth/bfj.svg?style=flat-square)](https://opensource.org/licenses/MIT)
3
+ [![Build status](https://gitlab.com/philbooth/bfj/badges/master/pipeline.svg)](https://gitlab.com/philbooth/bfj/pipelines)
4
+ [![Package status](https://img.shields.io/npm/v/bfj.svg)](https://www.npmjs.com/package/bfj)
5
+ [![Downloads](https://img.shields.io/npm/dm/bfj.svg)](https://www.npmjs.com/package/bfj)
6
+ [![License](https://img.shields.io/npm/l/bfj.svg)](https://opensource.org/licenses/MIT)
6
7
 
7
8
  Big-Friendly JSON. Asynchronous streaming functions for large JSON data sets.
8
9
 
@@ -11,10 +12,11 @@ Big-Friendly JSON. Asynchronous streaming functions for large JSON data sets.
11
12
  * [What functions does it implement?](#what-functions-does-it-implement)
12
13
  * [How do I install it?](#how-do-i-install-it)
13
14
  * [How do I read a JSON file?](#how-do-i-read-a-json-file)
14
- * [How do I write a JSON file?](#how-do-i-write-a-json-file)
15
15
  * [How do I parse a stream of JSON?](#how-do-i-parse-a-stream-of-json)
16
- * [How do I create a JSON string?](#how-do-i-create-a-json-string)
16
+ * [How do I selectively parse individual items from a JSON stream?](#how-do-i-selectively-parse-individual-items-from-a-json-stream)
17
+ * [How do I write a JSON file?](#how-do-i-write-a-json-file)
17
18
  * [How do I create a stream of JSON?](#how-do-i-create-a-stream-of-json)
19
+ * [How do I create a JSON string?](#how-do-i-create-a-json-string)
18
20
  * [What other methods are there?](#what-other-methods-are-there)
19
21
  * [bfj.walk (stream, options)](#bfjwalk-stream-options)
20
22
  * [bfj.eventify (data, options)](#bfjeventify-data-options)
@@ -69,10 +71,10 @@ BFJ is not for you.
69
71
 
70
72
  ## What functions does it implement?
71
73
 
72
- Eight functions
74
+ Nine functions
73
75
  are exported.
74
76
 
75
- Four are
77
+ Five are
76
78
  concerned with
77
79
  parsing, or
78
80
  turning JSON strings
@@ -86,6 +88,10 @@ into JavaScript data:
86
88
  are for asynchronously parsing
87
89
  streams of JSON.
88
90
 
91
+ * [`match`](#how-do-i-selectively-parse-individual-items-from-a-json-stream)
92
+ selectively parses individual items
93
+ from a JSON stream.
94
+
89
95
  * [`walk`](#bfjwalk-stream-options)
90
96
  asynchronously walks
91
97
  a stream,
@@ -105,14 +111,14 @@ to JSON:
105
111
  asynchronously serialises data
106
112
  to a JSON file on disk.
107
113
 
108
- * [`stringify`](#how-do-i-create-a-json-string)
109
- asynchronously serialises data
110
- to a JSON string.
111
-
112
114
  * [`streamify`](#how-do-i-create-a-stream-of-json)
113
115
  asynchronously serialises data
114
116
  to a stream of JSON.
115
117
 
118
+ * [`stringify`](#how-do-i-create-a-json-string)
119
+ asynchronously serialises data
120
+ to a JSON string.
121
+
116
122
  * [`eventify`](#bfjeventify-data-options)
117
123
  asynchronously traverses
118
124
  a data structure
@@ -136,7 +142,7 @@ Or if you just want
136
142
  the git repo:
137
143
 
138
144
  ```
139
- git clone git@github.com:philbooth/bfj.git
145
+ git clone git@gitlab.com:philbooth/bfj.git
140
146
  ```
141
147
 
142
148
  ## How do I read a JSON file?
@@ -170,33 +176,6 @@ If syntax errors occur,
170
176
  the promise is rejected
171
177
  with the first error.
172
178
 
173
- ## How do I write a JSON file?
174
-
175
- ```js
176
- const bfj = require('bfj');
177
-
178
- bfj.write(path, data, options)
179
- .then(() => {
180
- // :)
181
- })
182
- .catch(error => {
183
- // :(
184
- });
185
- ```
186
-
187
- `write` returns a [bluebird promise][promise]
188
- and asynchronously serialises a data structure
189
- to a JSON file on disk.
190
- The promise is resolved
191
- when the file has been written,
192
- or rejected with the error
193
- if writing failed.
194
-
195
- It takes three arguments;
196
- the path to the JSON file,
197
- the data structure to serialise
198
- and an [options](#options-for-serialisation-functions) object.
199
-
200
179
  ## How do I parse a stream of JSON?
201
180
 
202
181
  ```js
@@ -259,13 +238,60 @@ request({ url }).pipe(bfj.unpipe((error, data) => {
259
238
  the callback
260
239
  as the first argument.
261
240
 
262
- ## How do I create a JSON string?
241
+ ## How do I selectively parse individual items from a JSON stream?
263
242
 
264
243
  ```js
265
244
  const bfj = require('bfj');
266
245
 
267
- bfj.stringify(data, options)
268
- .then(json => {
246
+ // Call match with your stream and a selector predicate/regex/string
247
+ const dataStream = bfj.match(jsonStream, selector, options);
248
+
249
+ // Get data out of the returned stream with event handlers
250
+ dataStream.on('data', item => { /* ... */ });
251
+ dataStream.on('end', () => { /* ... */);
252
+ dataStream.on('error', () => { /* ... */);
253
+ dataStream.on('dataError', () => { /* ... */);
254
+
255
+ // ...or you can pipe it to another stream
256
+ dataStream.pipe(someOtherStream);
257
+ ```
258
+
259
+ `match` returns a readable, object-mode stream
260
+ and asynchronously parses individual matching items
261
+ from an input JSON stream.
262
+
263
+ It takes three arguments:
264
+ a [readable stream][readable]
265
+ from which the JSON will be parsed;
266
+ a selector argument for determining matches,
267
+ which may be a string, a regular expression or a predicate function;
268
+ and an [options](#options-for-parsing-functions) object.
269
+
270
+ If the selector is a string,
271
+ it will be compared to property keys
272
+ to determine whether
273
+ each item in the data is a match.
274
+ If it is a regular expression,
275
+ the comparison will be made
276
+ by calling the [RegExp `test` method][regexp-test]
277
+ with the property key.
278
+ Predicate functions will be called with three arguments:
279
+ `key`, `value` and `depth`.
280
+ If the result of the predicate is a truthy value
281
+ then the item will be deemed a match.
282
+
283
+ If there are any syntax errors in the JSON,
284
+ a `dataError` event will be emitted.
285
+ If any other errors occur,
286
+ an `error` event will be emitted.
287
+
288
+ ## How do I write a JSON file?
289
+
290
+ ```js
291
+ const bfj = require('bfj');
292
+
293
+ bfj.write(path, data, options)
294
+ .then(() => {
269
295
  // :)
270
296
  })
271
297
  .catch(error => {
@@ -273,14 +299,16 @@ bfj.stringify(data, options)
273
299
  });
274
300
  ```
275
301
 
276
- `stringify` returns a [bluebird promise][promise] and
277
- asynchronously serialises a data structure
278
- to a JSON string.
302
+ `write` returns a [bluebird promise][promise]
303
+ and asynchronously serialises a data structure
304
+ to a JSON file on disk.
279
305
  The promise is resolved
280
- to the JSON string
281
- when serialisation is complete.
306
+ when the file has been written,
307
+ or rejected with the error
308
+ if writing failed.
282
309
 
283
- It takes two arguments;
310
+ It takes three arguments;
311
+ the path to the JSON file,
284
312
  the data structure to serialise
285
313
  and an [options](#options-for-serialisation-functions) object.
286
314
 
@@ -294,6 +322,7 @@ const stream = bfj.streamify(data, options);
294
322
  // Get data out of the stream with event handlers
295
323
  stream.on('data', chunk => { /* ... */ });
296
324
  stream.on('end', () => { /* ... */);
325
+ stream.on('error', () => { /* ... */);
297
326
  stream.on('dataError', () => { /* ... */);
298
327
 
299
328
  // ...or you can pipe it to another stream
@@ -310,6 +339,37 @@ It takes two arguments;
310
339
  the data structure to serialise
311
340
  and an [options](#options-for-serialisation-functions) object.
312
341
 
342
+ If there a circular reference is encountered in the data
343
+ and `options.circular` is not set to `'ignore'`,
344
+ a `dataError` event will be emitted.
345
+ If any other errors occur,
346
+ an `error` event will be emitted.
347
+
348
+ ## How do I create a JSON string?
349
+
350
+ ```js
351
+ const bfj = require('bfj');
352
+
353
+ bfj.stringify(data, options)
354
+ .then(json => {
355
+ // :)
356
+ })
357
+ .catch(error => {
358
+ // :(
359
+ });
360
+ ```
361
+
362
+ `stringify` returns a [bluebird promise][promise] and
363
+ asynchronously serialises a data structure
364
+ to a JSON string.
365
+ The promise is resolved
366
+ to the JSON string
367
+ when serialisation is complete.
368
+
369
+ It takes two arguments;
370
+ the data structure to serialise
371
+ and an [options](#options-for-serialisation-functions) object.
372
+
313
373
  ## What other methods are there?
314
374
 
315
375
  ### bfj.walk (stream, options)
@@ -328,6 +388,7 @@ emitter.on(bfj.events.literal, value => { /* ... */ });
328
388
  emitter.on(bfj.events.endArray, () => { /* ... */ });
329
389
  emitter.on(bfj.events.endObject, () => { /* ... */ });
330
390
  emitter.on(bfj.events.error, error => { /* ... */ });
391
+ emitter.on(bfj.events.dataError, error => { /* ... */ });
331
392
  emitter.on(bfj.events.end, () => { /* ... */ });
332
393
  ```
333
394
 
@@ -423,16 +484,24 @@ of an object,
423
484
 
424
485
  * `bfj.events.error`
425
486
  indicates that
426
- an error has occurred.
427
- The error may be due to
428
- invalid syntax on the incoming stream
429
- or caught from one of the event handlers
487
+ an error was caught
488
+ from one of the event handlers
430
489
  in user code.
431
490
  The listener
432
491
  will be passed
433
492
  the `Error` instance
434
493
  as its argument.
435
494
 
495
+ * `bfj.events.dataError`
496
+ indicates that
497
+ a syntax error was encountered
498
+ in the incoming JSON stream.
499
+ The listener
500
+ will be passed
501
+ an `Error` instance
502
+ decorated with `actual`, `expected`, `lineNumber` and `columnNumber` properties
503
+ as its argument.
504
+
436
505
  * `bfj.events.end`
437
506
  indicates that
438
507
  the end of the input
@@ -464,7 +533,8 @@ emitter.on(bfj.events.number, value => { /* ... */ });
464
533
  emitter.on(bfj.events.literal, value => { /* ... */ });
465
534
  emitter.on(bfj.events.endArray, () => { /* ... */ });
466
535
  emitter.on(bfj.events.endObject, () => { /* ... */ });
467
- emitter.on(bfj.events.error, () => { /* ... */ });
536
+ emitter.on(bfj.events.error, error => { /* ... */ });
537
+ emitter.on(bfj.events.dataError, error => { /* ... */ });
468
538
  emitter.on(bfj.events.end, () => { /* ... */ });
469
539
  ```
470
540
 
@@ -551,17 +621,23 @@ of an object,
551
621
 
552
622
  * `bfj.events.error`
553
623
  indicates that
554
- an error has occurred.
555
- The error may be due to
556
- a circular reference
557
- encountered in the data
558
- or caught from one of the event handlers
624
+ an error was caught
625
+ from one of the event handlers
559
626
  in user code.
560
627
  The listener
561
628
  will be passed
562
629
  the `Error` instance
563
630
  as its argument.
564
631
 
632
+ * `bfj.events.dataError`
633
+ indicates that
634
+ a circular reference was encountered in the data
635
+ and the `circular` option was not set to `'ignore'`.
636
+ The listener
637
+ will be passed
638
+ an `Error` instance
639
+ as its argument.
640
+
565
641
  * `bfj.events.end`
566
642
  indicates that
567
643
  the end of the data
@@ -610,6 +686,26 @@ of an object,
610
686
  discrete chunks of JSON.
611
687
  See [NDJSON](#can-it-handle-newline-delimited-json-ndjson) for more information.
612
688
 
689
+ * `options.numbers`:
690
+ For `bfj.match` only,
691
+ set this to `true`
692
+ if you wish to match against numbers
693
+ with a string or regular expression
694
+ `selector` argument.
695
+
696
+ * `options.bufferLength`:
697
+ For `bfj.match` only,
698
+ the length of the match buffer.
699
+ Smaller values use less memory
700
+ but may result in a slower parse time.
701
+ The default value is `1024`.
702
+
703
+ * `options.highWaterMark`:
704
+ For `bfj.match` only,
705
+ set this if you would like to
706
+ pass a value for the `highWaterMark` option
707
+ to the readable stream constructor.
708
+
613
709
  ### Options for serialisation functions
614
710
 
615
711
  * `options.space`:
@@ -681,6 +777,11 @@ of an object,
681
777
  but may result in a slower serialisation time.
682
778
  The default value is `1024`.
683
779
 
780
+ * `options.highWaterMark`:
781
+ Set this if you would like to
782
+ pass a value for the `highWaterMark` option
783
+ to the readable stream constructor.
784
+
684
785
  * `options.yieldRate`:
685
786
  The number of data items to process
686
787
  before yielding to the event loop.
@@ -734,7 +835,7 @@ resume();
734
835
 
735
836
  Yes.
736
837
  If you pass the `ndjson` [option](#options-for-parsing-functions)
737
- to `bfj.walk` or `bfj.parse`,
838
+ to `bfj.walk`, `bfj.match` or `bfj.parse`,
738
839
  newline characters at the root level
739
840
  will act as delimiters between
740
841
  discrete JSON values:
@@ -742,6 +843,9 @@ discrete JSON values:
742
843
  * `bfj.walk` will emit a `bfj.events.endLine` event
743
844
  each time it encounters a newline character.
744
845
 
846
+ * `bfj.match` will just ignore the newlines
847
+ while it continues looking for matching items.
848
+
745
849
  * `bfj.parse` will resolve with the first value
746
850
  and pause the underlying stream.
747
851
  If it's called again with the same stream,
@@ -821,14 +925,15 @@ As of [version `3.0.0`](HISTORY.md#300),
821
925
  only Node.js versions 6 or greater
822
926
  are supported
823
927
  because of the dependency
824
- on [Hoopy](https://github.com/philbooth/hoopy).
928
+ on [Hoopy](https://gitlab.com/philbooth/hoopy).
825
929
  Previous versions supported
826
930
  node 4 and later.
827
931
 
828
- A separate `node-4` branch is also maintained,
829
- which maintains feature parity version-for-version
830
- with `master`.
831
- Releases from this branch
932
+ A separate `node-4` branch was maintained
933
+ until version `5.4.1`,
934
+ which had feature parity version-for-version
935
+ with releases from `master`.
936
+ Releases from the `node-4` branch
832
937
  are available in npm
833
938
  under the package name [`bfj-node4`](https://www.npmjs.com/package/bfj-node4).
834
939
 
@@ -845,6 +950,7 @@ under the package name [`bfj-node4`](https://www.npmjs.com/package/bfj-node4).
845
950
  [readable]: https://nodejs.org/api/stream.html#stream_readable_streams
846
951
  [writable]: https://nodejs.org/api/stream.html#stream_writable_streams
847
952
  [pipe]: https://nodejs.org/api/stream.html#stream_readable_pipe_destination_options
953
+ [regexp-test]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test
848
954
  [reviver]: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#Using_the_reviver_parameter
849
955
  [space]: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#The_space_argument
850
956
  [history]: HISTORY.md
@@ -853,5 +959,5 @@ under the package name [`bfj-node4`](https://www.npmjs.com/package/bfj-node4).
853
959
  [mocha]: https://mochajs.org/
854
960
  [chai]: http://chaijs.com/
855
961
  [proxyquire]: https://github.com/thlorenz/proxyquire
856
- [spooks]: https://github.com/philbooth/spooks.js
962
+ [spooks]: https://gitlab.com/philbooth/spooks.js
857
963
  [license]: COPYING
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "bfj",
3
- "version": "5.3.1",
3
+ "version": "6.1.2",
4
4
  "description": "Big-friendly JSON. Asynchronous streaming functions for large JSON data sets.",
5
- "homepage": "https://github.com/philbooth/bfj",
6
- "bugs": "https://github.com/philbooth/bfj/issues",
5
+ "homepage": "https://gitlab.com/philbooth/bfj",
6
+ "bugs": "https://gitlab.com/philbooth/bfj/issues",
7
7
  "license": "MIT",
8
- "author": "Phil Booth (https://github.com/philbooth)",
8
+ "author": "Phil Booth (https://gitlab.com/philbooth)",
9
9
  "main": "./src",
10
10
  "keywords": [
11
11
  "json",
@@ -23,25 +23,25 @@
23
23
  ],
24
24
  "repository": {
25
25
  "type": "git",
26
- "url": "https://github.com/philbooth/bfj.git"
26
+ "url": "https://gitlab.com/philbooth/bfj.git"
27
27
  },
28
28
  "engines": {
29
29
  "node": ">= 6.0.0"
30
30
  },
31
31
  "dependencies": {
32
- "bluebird": "^3.5.1",
33
- "check-types": "^7.3.0",
34
- "hoopy": "^0.1.2",
35
- "tryer": "^1.0.0"
32
+ "bluebird": "^3.5.5",
33
+ "check-types": "^8.0.3",
34
+ "hoopy": "^0.1.4",
35
+ "tryer": "^1.0.1"
36
36
  },
37
37
  "devDependencies": {
38
- "eslint": "4.19.x",
39
- "mocha": "5.0.x",
40
- "chai": "4.1.x",
41
- "proxyquire": "1.8.x",
42
- "spooks": "2.0.x",
43
- "please-release-me": "2.0.x",
44
- "request": "2.85.x"
38
+ "chai": "^4.2.0",
39
+ "eslint": "^6.0.1",
40
+ "mocha": "^6.1.4",
41
+ "please-release-me": "^2.1.2",
42
+ "proxyquire": "^2.1.0",
43
+ "request": "^2.88.0",
44
+ "spooks": "^2.0.0"
45
45
  },
46
46
  "scripts": {
47
47
  "lint": "eslint src",
@@ -0,0 +1,17 @@
1
+ 'use strict'
2
+
3
+ const check = require('check-types')
4
+ const BfjStream = require('./stream')
5
+ const util = require('util')
6
+
7
+ util.inherits(DataStream, BfjStream)
8
+
9
+ module.exports = DataStream
10
+
11
+ function DataStream (read, options) {
12
+ if (check.not.instanceStrict(this, DataStream)) {
13
+ return new DataStream(read, options)
14
+ }
15
+
16
+ return BfjStream.call(this, read, Object.assign({ objectMode: true }, options))
17
+ }
package/src/eventify.js CHANGED
@@ -110,7 +110,7 @@ function eventify (data, options = {}) {
110
110
  })
111
111
 
112
112
  function after (coerced) {
113
- if (isInvalidType(coerced)) {
113
+ if (isInvalid(coerced)) {
114
114
  return
115
115
  }
116
116
 
@@ -205,8 +205,15 @@ function eventify (data, options = {}) {
205
205
  })
206
206
  }
207
207
 
208
- function isInvalidType (datum) {
209
- return !! invalidTypes[typeof datum]
208
+ function isInvalid (datum) {
209
+ const type = typeof datum
210
+ return !! invalidTypes[type] || (
211
+ type === 'number' && ! isValidNumber(datum)
212
+ )
213
+ }
214
+
215
+ function isValidNumber (datum) {
216
+ return datum > Number.NEGATIVE_INFINITY && datum < Number.POSITIVE_INFINITY
210
217
  }
211
218
 
212
219
  function literal (datum) {
@@ -232,7 +239,7 @@ function eventify (data, options = {}) {
232
239
  function array (datum) {
233
240
  // For an array, collection:object and collection:array are the same.
234
241
  return collection(datum, datum, 'array', item => {
235
- if (isInvalidType(item)) {
242
+ if (isInvalid(item)) {
236
243
  return proceed(null)
237
244
  }
238
245
 
@@ -249,7 +256,7 @@ function eventify (data, options = {}) {
249
256
  ignoreThisItem = ignoreItems = true
250
257
 
251
258
  if (! ignoreCircularReferences) {
252
- return emit(events.error, new Error('Circular reference.'))
259
+ return emit(events.dataError, new Error('Circular reference.'))
253
260
  }
254
261
  } else {
255
262
  references.set(obj, true)
@@ -286,11 +293,11 @@ function eventify (data, options = {}) {
286
293
  return collection(datum, Object.keys(datum), 'object', key => {
287
294
  const item = datum[key]
288
295
 
289
- if (isInvalidType(item)) {
296
+ if (isInvalid(item)) {
290
297
  return Promise.resolve()
291
298
  }
292
299
 
293
- return emit(events.property, key)
300
+ return emit(events.property, escapeString(key))
294
301
  .then(() => proceed(item))
295
302
  })
296
303
  }
package/src/events.js CHANGED
@@ -15,3 +15,4 @@ module.exports = {
15
15
  module.exports.endArray = module.exports.endPrefix + module.exports.array
16
16
  module.exports.endObject = module.exports.endPrefix + module.exports.object
17
17
  module.exports.endLine = `${module.exports.endPrefix}line`
18
+ module.exports.dataError = `${module.exports.error}-data`
package/src/index.js CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  module.exports = {
4
4
  walk: require('./walk'),
5
+ match: require('./match'),
5
6
  parse: require('./parse'),
6
7
  unpipe: require('./unpipe'),
7
8
  read: require('./read'),