Server IP : 85.214.239.14 / Your IP : 18.223.117.234 Web Server : Apache/2.4.62 (Debian) System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.18 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /proc/2/root/proc/3/task/3/root/usr/lib/node_modules/pm2/node_modules/amp-message/ |
Upload File : |
# 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(new Buffer('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(new Buffer('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