Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { decode, encode, Stream } from 'amp';
// $ExpectType Buffer[]
decode(new Buffer('something'));
// $ExpectType Buffer
encode([new Buffer('something'), new Buffer('something')]);
// $ExpectError
decode('');
// $ExpectError
decode(1);
// $ExpectError
decode();
// $ExpectError
encode('');
import { decode, encode, Stream } from 'amp';
// $ExpectType Buffer[]
decode(new Buffer('something'));
// $ExpectType Buffer
encode([new Buffer('something'), new Buffer('something')]);
// $ExpectError
decode('');
// $ExpectError
decode(1);
// $ExpectError
decode();
// $ExpectError
encode('');
// $ExpectError
encode(1);
// $ExpectError
encode();
import { decode, encode, Stream } from 'amp';
// $ExpectType Buffer[]
decode(new Buffer('something'));
// $ExpectType Buffer
encode([new Buffer('something'), new Buffer('something')]);
// $ExpectError
decode('');
// $ExpectError
decode(1);
// $ExpectError
decode();
// $ExpectError
encode('');
// $ExpectError
encode(1);
// $ExpectError
encode();
// $ExpectType Stream
new Stream({});
encode([new Buffer('something'), new Buffer('something')]);
// $ExpectError
decode('');
// $ExpectError
decode(1);
// $ExpectError
decode();
// $ExpectError
encode('');
// $ExpectError
encode(1);
// $ExpectError
encode();
// $ExpectType Stream
new Stream({});
// $ExpectType Stream
new Stream({
highWaterMark: 1,
decodeStrings: true,
objectMode: true,
destroy: (error: Error | null) => {
return 'handle error';
},
final: (callback: (error?: Error) => void) => {
decode(new Buffer('something'));
// $ExpectType Buffer
encode([new Buffer('something'), new Buffer('something')]);
// $ExpectError
decode('');
// $ExpectError
decode(1);
// $ExpectError
decode();
// $ExpectError
encode('');
// $ExpectError
encode(1);
// $ExpectError
encode();
// $ExpectType Stream
new Stream({});
// $ExpectType Stream
new Stream({
highWaterMark: 1,
decodeStrings: true,
objectMode: true,
destroy: (error: Error | null) => {
function Actor(stream) {
if (!(this instanceof Actor)) return new Actor(stream);
this.parser = new amp.Stream;
this.parser.on('data', this.onmessage.bind(this));
stream.pipe(this.parser);
this.stream = stream;
this.callbacks = {};
this.ids = 0;
this.id = ++ids;
Actor.emit('actor', this);
}
function Actor(stream) {
if (!(this instanceof Actor)) return new Actor(stream);
var that = this;
this.parser = new amp.Stream;
this.parser.on('data', this.onmessage.bind(this));
stream.pipe(this.parser);
this.stream = stream;
this.callbacks = {};
this.ids = 0;
this.id = ++ids;
this.secret_key = null;
Actor.emit('actor', this);
}
function Actor(stream) {
if (!(this instanceof Actor)) return new Actor(stream);
this.parser = new amp.Stream;
this.parser.on('data', this.onmessage.bind(this));
stream.pipe(this.parser);
this.stream = stream;
this.callbacks = {};
this.ids = 0;
this.id = ++ids;
Actor.emit('actor', this);
}
function decode(msg) {
var args = amp.decode(msg);
for (var i = 0; i < args.length; i++) {
args[i] = unpack(args[i]);
}
return args;
}
static decode(buffer) { return amp.decode(buffer) }