Skip to content

Commit

Permalink
actually tell swarm compression strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
Phineas committed Jul 9, 2020
1 parent b5c499c commit 8a880bf
Show file tree
Hide file tree
Showing 7 changed files with 229 additions and 4 deletions.
2 changes: 2 additions & 0 deletions node_modules/.yarn-integrity

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions node_modules/@types/pako/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions node_modules/@types/pako/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

148 changes: 148 additions & 0 deletions node_modules/@types/pako/index.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions node_modules/@types/pako/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions swarm.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { EventEmitter } from 'events';
import pako from 'pako';
import {inflate} from 'pako';

enum DecompressionStrategy {
export enum DecompressionStrategy {
ZlibJson = 'zlib_json',
TextJson = 'text_json'
}
Expand Down Expand Up @@ -32,7 +32,7 @@ export class SwarmClient extends EventEmitter {
}

connect() {
const socket = new WebSocket(`${this.swarmHost}/socket?encoding=${this.encoding}`);
const socket = new WebSocket(`${this.swarmHost}/socket?encoding=${this.encoding}&compression=${this.compression}`);

this.socket = socket;
this.state = "connecting";
Expand Down Expand Up @@ -85,7 +85,7 @@ export class SwarmClient extends EventEmitter {
private decompress(data: any): any {
switch (this.compression) {
case DecompressionStrategy.ZlibJson: {
return JSON.parse(pako.inflate(data, {to: 'string'}));
return JSON.parse(inflate(data, {to: 'string'}));
}

default: {
Expand Down
4 changes: 4 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
version "3.0.0"
resolved "https://registry.yarnpkg.com/@types/events/-/events-3.0.0.tgz#2862f3f58a9a7f7c3e78d79f130dd4d71c25c2a7"

"@types/pako@^1.0.1":
version "1.0.1"
resolved "https://registry.yarnpkg.com/@types/pako/-/pako-1.0.1.tgz#33b237f3c9aff44d0f82fe63acffa4a365ef4a61"

events@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/events/-/events-3.0.0.tgz#9a0a0dfaf62893d92b875b8f2698ca4114973e88"
Expand Down

0 comments on commit 8a880bf

Please sign in to comment.