How to use amp - 10 common examples

To help you get started, we’ve selected a few amp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DefinitelyTyped / DefinitelyTyped / types / amp / amp-tests.ts View on Github external
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('');
github DefinitelyTyped / DefinitelyTyped / types / amp / amp-tests.ts View on Github external
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();
github DefinitelyTyped / DefinitelyTyped / types / amp / amp-tests.ts View on Github external
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({});
github DefinitelyTyped / DefinitelyTyped / types / amp / amp-tests.ts View on Github external
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) => {
github DefinitelyTyped / DefinitelyTyped / types / amp / amp-tests.ts View on Github external
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) => {
github gridcontrol / gridcontrol / src / network / socket-router.js View on Github external
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);
}
github gridcontrol / gridcontrol / src / network / secure-socket-router.js View on Github external
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);
}
github tj / node-actorify / index.js View on Github external
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);
}
github tj / node-amp-message / index.js View on Github external
function decode(msg) {
  var args = amp.decode(msg);

  for (var i = 0; i < args.length; i++) {
    args[i] = unpack(args[i]);
  }

  return args;
}
github AraBlocks / cfsnet / protocol.js View on Github external
  static decode(buffer) { return amp.decode(buffer) }

amp

Abstract messaging protocol

MIT
Latest version published 11 years ago

Package Health Score

67 / 100
Full package analysis

Popular amp functions