Skip to content

Commit b63200d

Browse files
author
pemrouz
committed
add max log header and default mode
1 parent bd455ed commit b63200d

File tree

3 files changed

+15
-16
lines changed

3 files changed

+15
-16
lines changed

dist/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ function data(ripple) {
5050
parse: function parse(res) {
5151
var existing = ripple.resources[res.name] || {};
5252

53-
res.body = (0, _set2.default)()(res.body || [], existing.body && existing.body.log);
5453
(0, _extend2.default)(res.headers)(existing.headers);
54+
res.body = (0, _set2.default)()(res.body || [], existing.body && existing.body.log, _is2.default.num(res.headers.log) ? res.headers.log : -1);
5555
(0, _overwrite2.default)(res.body.on)(listeners(existing));
5656
res.body.on('change.bubble', function (change) {
5757
return ripple.emit('change', [res.name, change], (0, _not2.default)(_is2.default.in(['data'])));

src/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,12 @@ export default function data(ripple){
1010
, parse(res){
1111
const existing = ripple.resources[res.name] || {}
1212

13-
res.body = set()(res.body || [], existing.body && existing.body.log)
1413
extend(res.headers)(existing.headers)
14+
res.body = set()(
15+
res.body || []
16+
, existing.body && existing.body.log
17+
, is.num(res.headers.log) ? res.headers.log : -1
18+
)
1519
overwrite(res.body.on)(listeners(existing))
1620
res.body.on('change.bubble', change => ripple.emit('change', [res.name, change], not(is.in(['data']))))
1721

test.js

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -132,22 +132,17 @@ describe('Data Type', function() {
132132
ripple('foo', ['foo'])
133133
update(0, 'bar')(ripple('foo'))
134134

135-
ripple('foo', set()(['baz']))
135+
ripple('foo', ['baz'])
136136
update(0, 'boo')(ripple('foo'))
137137

138-
expect(ripple('foo').log)
139-
.to.eql(changes)
140-
.to.eql([
141-
{ time: 0, type: 'update', value: ['foo'] }
142-
, { time: 1, type: 'update', value: 'bar', key: '0' }
143-
, { time: 2, type: 'update', value: ['baz'] }
144-
, { time: 3, type: 'update', value: 'boo', key: '0' }
145-
])
146-
147-
ripple('bar', ripple('foo'))
148-
expect(ripple('foo')).to.not.equal(ripple('bar'))
149-
expect(ripple('foo').log).to.have.lengthOf(4)
150-
expect(ripple('bar').log).to.have.lengthOf(5)
138+
expect(changes).to.eql([
139+
{ time: 0, type: 'update', value: ['foo'] }
140+
, { time: 1, type: 'update', value: 'bar', key: '0' }
141+
, { time: 2, type: 'update', value: ['baz'] }
142+
, { time: 3, type: 'update', value: 'boo', key: '0' }
143+
])
144+
145+
expect(ripple('foo').log).to.eql([null, null, null, null])
151146
})
152147

153148
it('should not lose existing headers', function(){

0 commit comments

Comments
 (0)