This is a
playground to test code. It runs a full
Node.js environment and already has all of
npm’s 400,000 packages pre-installed, including
dfi-asterisk-ami-event-utils with all
npm packages installed. Try it out:
This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.
Some service functions for parse\stringify raw data packages (events, actions, responses, extended responses) from Asterisk AMI's socket. This library is a part of Asterisk's AMI Client library.
$ npm i asterisk-ami-event-utils
.toString(buffer)- converts raw AMI's data package from buffer to utf-8 string and trim all CRLF in start or end of this string;
.toObject(buffer)- converts raw AMI's data package from buffer to object;
.toJson(buffer)- converts raw AMI's data package from buffer to json-string;
.toArray(buffer)- converts raw AMI's data package from buffer to paired-array,
.fromObject(obj)- converts data package from object to string, which ready for send into
.fromArray(arr)- converts data package from paired-array to string, which ready for send into
.fromString(str)- prepares data package's string into correct form for send into socket of Asterisk AMI socket;
const amiUtils = require('asterisk-ami-event-utils'); let eventBuffer = '...'; // any buffer or string of event from AMI's socket or from other place let eventObject = amiUtils.toObject(eventBuffer);
For examples, please, see tests
Tests require Mocha.
Test coverage with Istanbul
npm run coverage
Licensed under the MIT License