Skip to content
This repository has been archived by the owner on Apr 16, 2021. It is now read-only.

Commit

Permalink
Merge pull request #35 from tableflip/fix/slow-buffer-serialization
Browse files Browse the repository at this point in the history
fix: slow buffer serialization in firefox
  • Loading branch information
Alan Shaw authored Sep 17, 2018
2 parents fdaaeaf + a42b1fb commit d893e31
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/serialization/buffer.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { preArrayOf } from './utils/prepost-array-of'

export const bufferFromJson = (obj) => Buffer.from(obj.data)
export const bufferFromJson = (obj) => Buffer.from(JSON.parse(obj.data).data)

export const bufferToJson = (buf) => ({
__ipfsPostMsgProxyType: 'Buffer',
data: Array.from(buf)
data: JSON.stringify(buf)
})

export const isBuffer = Buffer.isBuffer
Expand Down
6 changes: 3 additions & 3 deletions test/functional/pubsub.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ describe('pubsub', () => {
await ipfsClient.pubsub.subscribe(topic, handler)

// Check the subscription was registered
assert.equal(mockIpfs._subs.length, 1)
assert.equal(mockIpfs._subs[0].topic, topic)
assert.strictEqual(mockIpfs._subs.length, 1)
assert.strictEqual(mockIpfs._subs[0].topic, topic)

// Close the proxy server without unsubscribing
await closeProxyServer(ipfsServer)

assert.equal(mockIpfs._subs.length, 0)
assert.strictEqual(mockIpfs._subs.length, 0)
})
})

0 comments on commit d893e31

Please sign in to comment.