# amp-message

> Higher level Message object for the AMP protocol

Latest version **0.1.2** (published 2014-03-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install amp-message
pnpm add amp-message
yarn add amp-message
bun add amp-message
```

## Health

**Score 18/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.2 |
| Published | 2014-03-28 |
| First published | 2013-10-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/amp-message) |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 45 |
| Maintainers | tjholowaychuk |
| Keywords | amp, actor, message, messaging, zmq, zeromq |

## Links

- npm: https://www.npmjs.com/package/amp-message
- Repository: https://github.com/visionmedia/node-amp-message
- Issues: https://github.com/visionmedia/node-amp-message/issues
- npm.io page: https://npm.io/package/amp-message

## Dependencies (1)

- [amp](https://npm.io/package/amp.md) 0.3.1

## Recent versions

- 0.1.2 (latest) — 2014-03-28
- 0.1.1 — 2013-11-13
- 0.1.0 — 2013-10-31
- 0.0.1 — 2013-10-30

## README

# amp-message

  High level [AMP](https://github.com/visionmedia/node-amp) `Message` implementation for manipulating, encoding and decoding AMP messages.

## Installation

```
$ npm install amp-message
```

## Example

  Encoding a message:

```js
var Message = require('amp-message');

var msg = new Message;

console.log(msg.toBuffer());
// => <Buffer 10>

msg.push('foo');
msg.push('bar');
msg.push('baz');
console.log(msg.toBuffer());
// => <Buffer 13 00 05 73 3a 66 6f 6f 00 05 73 3a 62 61 72 00 05 73 3a 62 61 7a>

msg.push({ foo: 'bar' });
console.log(msg.toBuffer());
// => <Buffer 14 00 05 73 3a 66 6f 6f 00 05 73 3a 62 61 72 00 05 73 3a 62 61 7a 00 0f 6a 3a 7b 22 66 6f 6f 22 3a 22 62 61 72 22 7d>

msg.push(Buffer.from('image data'));
console.log(msg.toBuffer());
// => <Buffer 15 00 05 73 3a 66 6f 6f 00 05 73 3a 62 61 72 00 05 73 3a 62 61 7a 00 0f 6a 3a 7b 22 66 6f 6f 22 3a 22 62 61 72 22 7d 00 0a 69 6d 61 67 65 20 64 61 74 ... >
```

  Decoding a message:

```js
var Message = require('..');

var msg = new Message;

msg.push('foo')
msg.push({ hello: 'world' })
msg.push(Buffer.from('hello'))

var other = new Message(msg.toBuffer());

console.log(other.shift());
console.log(other.shift());
console.log(other.shift());
```

## API

### Message

  Initialize an empty message.

### Message(buffer)

  Decode the `buffer` AMP message to populate the `Message`.

### Message(args)

  Initialize a messeage populated with `args`.

# License

  MIT

---
_Source: https://npm.io/package/amp-message · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
