bfj 6.1.0 → 7.0.1
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 +2 -0
- package/.gitlab-ci.yml +25 -0
- package/AUTHORS +1 -1
- package/CONTRIBUTING.md +4 -4
- package/HISTORY.md +48 -0
- package/README.md +28 -19
- package/package.json +17 -17
- package/src/datastream.js +1 -1
- package/src/eventify.js +13 -6
- package/src/jsonstream.js +1 -1
- package/src/match.js +16 -0
- package/src/parse.js +2 -2
- package/src/read.js +1 -1
- package/src/unpipe.js +1 -1
- package/test/integration.js +6 -2
- package/test/unit/eventify.js +352 -73
- package/test/unit/match.js +140 -0
- package/test/unit/walk.js +114 -115
- package/.travis.yml +0 -12
package/test/unit/match.js
CHANGED
|
@@ -776,6 +776,7 @@ suite('match:', () => {
|
|
|
776
776
|
suite('read events:', () => {
|
|
777
777
|
setup(() => {
|
|
778
778
|
log.args.DataStream[0][0]()
|
|
779
|
+
// [ { "foo": "bar" }, "baz", 1, true ]
|
|
779
780
|
log.args.on[0][1]()
|
|
780
781
|
log.args.on[1][1]()
|
|
781
782
|
log.args.on[2][1]('foo')
|
|
@@ -824,6 +825,7 @@ suite('match:', () => {
|
|
|
824
825
|
suite('read events:', () => {
|
|
825
826
|
setup(() => {
|
|
826
827
|
log.args.DataStream[0][0]()
|
|
828
|
+
// { "foo": "bar", "baz": "qux", "foo": "wibble" }
|
|
827
829
|
log.args.on[1][1]()
|
|
828
830
|
log.args.on[2][1]('foo')
|
|
829
831
|
log.args.on[5][1]('bar')
|
|
@@ -879,6 +881,7 @@ suite('match:', () => {
|
|
|
879
881
|
suite('read events:', () => {
|
|
880
882
|
setup(() => {
|
|
881
883
|
log.args.DataStream[0][0]()
|
|
884
|
+
// { "foo": "bar", "fo": "baz", "oo": "qux" }
|
|
882
885
|
log.args.on[1][1]()
|
|
883
886
|
log.args.on[2][1]('foo')
|
|
884
887
|
log.args.on[5][1]('bar')
|
|
@@ -934,6 +937,7 @@ suite('match:', () => {
|
|
|
934
937
|
suite('read events:', () => {
|
|
935
938
|
setup(() => {
|
|
936
939
|
log.args.DataStream[0][0]()
|
|
940
|
+
// { "0": "foo", "1": "bar", "2": [ "baz", "qux" ] }
|
|
937
941
|
log.args.on[1][1]()
|
|
938
942
|
log.args.on[2][1]('0')
|
|
939
943
|
log.args.on[5][1]('foo')
|
|
@@ -1054,5 +1058,141 @@ suite('match:', () => {
|
|
|
1054
1058
|
})
|
|
1055
1059
|
})
|
|
1056
1060
|
})
|
|
1061
|
+
|
|
1062
|
+
suite('match with minDepth=1:', () => {
|
|
1063
|
+
let stream, predicate, options, result
|
|
1064
|
+
|
|
1065
|
+
setup(() => {
|
|
1066
|
+
predicate = spooks.fn({ name: 'predicate', log, results: [ true ] })
|
|
1067
|
+
result = match({}, predicate, { minDepth: 1 })
|
|
1068
|
+
})
|
|
1069
|
+
|
|
1070
|
+
test('DataStream was called once', () => {
|
|
1071
|
+
assert.strictEqual(log.counts.DataStream, 1)
|
|
1072
|
+
})
|
|
1073
|
+
|
|
1074
|
+
test('walk was called once', () => {
|
|
1075
|
+
assert.strictEqual(log.counts.walk, 1)
|
|
1076
|
+
})
|
|
1077
|
+
|
|
1078
|
+
test('EventEmitter.on was called eleven times', () => {
|
|
1079
|
+
assert.strictEqual(log.counts.on, 11)
|
|
1080
|
+
})
|
|
1081
|
+
|
|
1082
|
+
suite('read events:', () => {
|
|
1083
|
+
setup(() => {
|
|
1084
|
+
log.args.DataStream[0][0]()
|
|
1085
|
+
// { "foo": { "bar": { "baz": "qux" } } }
|
|
1086
|
+
log.args.on[1][1]()
|
|
1087
|
+
log.args.on[2][1]('foo')
|
|
1088
|
+
log.args.on[1][1]()
|
|
1089
|
+
log.args.on[2][1]('bar')
|
|
1090
|
+
log.args.on[1][1]()
|
|
1091
|
+
log.args.on[2][1]('baz')
|
|
1092
|
+
log.args.on[5][1]('qux')
|
|
1093
|
+
log.args.on[4][1]()
|
|
1094
|
+
log.args.on[4][1]()
|
|
1095
|
+
log.args.on[4][1]()
|
|
1096
|
+
log.args.on[8][1]()
|
|
1097
|
+
})
|
|
1098
|
+
|
|
1099
|
+
test('results.push was called four times', () => {
|
|
1100
|
+
assert.strictEqual(log.counts.push, 4)
|
|
1101
|
+
})
|
|
1102
|
+
|
|
1103
|
+
test('results.push was called correctly first time', () => {
|
|
1104
|
+
const args = log.args.push[0]
|
|
1105
|
+
assert.lengthOf(args, 1)
|
|
1106
|
+
assert.equal(args[0], 'qux')
|
|
1107
|
+
})
|
|
1108
|
+
|
|
1109
|
+
test('results.push was called correctly second time', () => {
|
|
1110
|
+
const args = log.args.push[1]
|
|
1111
|
+
assert.lengthOf(args, 1)
|
|
1112
|
+
assert.deepEqual(args[0], { baz: 'qux' })
|
|
1113
|
+
})
|
|
1114
|
+
|
|
1115
|
+
test('results.push was called correctly third time', () => {
|
|
1116
|
+
const args = log.args.push[2]
|
|
1117
|
+
assert.lengthOf(args, 1)
|
|
1118
|
+
assert.deepEqual(args[0], { bar: { baz: 'qux' } })
|
|
1119
|
+
})
|
|
1120
|
+
|
|
1121
|
+
test('results.push was called correctly fourth time', () => {
|
|
1122
|
+
const args = log.args.push[3]
|
|
1123
|
+
assert.lengthOf(args, 1)
|
|
1124
|
+
assert.isNull(args[0])
|
|
1125
|
+
})
|
|
1126
|
+
|
|
1127
|
+
test('results.emit was not called', () => {
|
|
1128
|
+
assert.strictEqual(log.counts.emit, 0)
|
|
1129
|
+
})
|
|
1130
|
+
})
|
|
1131
|
+
})
|
|
1132
|
+
|
|
1133
|
+
suite('match with minDepth=2:', () => {
|
|
1134
|
+
let stream, predicate, options, result
|
|
1135
|
+
|
|
1136
|
+
setup(() => {
|
|
1137
|
+
predicate = spooks.fn({ name: 'predicate', log, results: [ true ] })
|
|
1138
|
+
result = match({}, predicate, { minDepth: 2 })
|
|
1139
|
+
})
|
|
1140
|
+
|
|
1141
|
+
test('DataStream was called once', () => {
|
|
1142
|
+
assert.strictEqual(log.counts.DataStream, 1)
|
|
1143
|
+
})
|
|
1144
|
+
|
|
1145
|
+
test('walk was called once', () => {
|
|
1146
|
+
assert.strictEqual(log.counts.walk, 1)
|
|
1147
|
+
})
|
|
1148
|
+
|
|
1149
|
+
test('EventEmitter.on was called eleven times', () => {
|
|
1150
|
+
assert.strictEqual(log.counts.on, 11)
|
|
1151
|
+
})
|
|
1152
|
+
|
|
1153
|
+
suite('read events:', () => {
|
|
1154
|
+
setup(() => {
|
|
1155
|
+
log.args.DataStream[0][0]()
|
|
1156
|
+
// { "foo": { "bar": { "baz": "qux" } } }
|
|
1157
|
+
log.args.on[1][1]()
|
|
1158
|
+
log.args.on[2][1]('foo')
|
|
1159
|
+
log.args.on[1][1]()
|
|
1160
|
+
log.args.on[2][1]('bar')
|
|
1161
|
+
log.args.on[1][1]()
|
|
1162
|
+
log.args.on[2][1]('baz')
|
|
1163
|
+
log.args.on[5][1]('qux')
|
|
1164
|
+
log.args.on[4][1]()
|
|
1165
|
+
log.args.on[4][1]()
|
|
1166
|
+
log.args.on[4][1]()
|
|
1167
|
+
log.args.on[8][1]()
|
|
1168
|
+
})
|
|
1169
|
+
|
|
1170
|
+
test('results.push was called three times', () => {
|
|
1171
|
+
assert.strictEqual(log.counts.push, 3)
|
|
1172
|
+
})
|
|
1173
|
+
|
|
1174
|
+
test('results.push was called correctly first time', () => {
|
|
1175
|
+
const args = log.args.push[0]
|
|
1176
|
+
assert.lengthOf(args, 1)
|
|
1177
|
+
assert.equal(args[0], 'qux')
|
|
1178
|
+
})
|
|
1179
|
+
|
|
1180
|
+
test('results.push was called correctly second time', () => {
|
|
1181
|
+
const args = log.args.push[1]
|
|
1182
|
+
assert.lengthOf(args, 1)
|
|
1183
|
+
assert.deepEqual(args[0], { baz: 'qux' })
|
|
1184
|
+
})
|
|
1185
|
+
|
|
1186
|
+
test('results.push was called correctly third time', () => {
|
|
1187
|
+
const args = log.args.push[2]
|
|
1188
|
+
assert.lengthOf(args, 1)
|
|
1189
|
+
assert.isNull(args[0])
|
|
1190
|
+
})
|
|
1191
|
+
|
|
1192
|
+
test('results.emit was not called', () => {
|
|
1193
|
+
assert.strictEqual(log.counts.emit, 0)
|
|
1194
|
+
})
|
|
1195
|
+
})
|
|
1196
|
+
})
|
|
1057
1197
|
})
|
|
1058
1198
|
})
|