npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

libamf-fix

v1.3.2

Published

Action Message Format library for node.js

Downloads

10

Readme

libamf

An Action Message Format library for node.js.

Dependencies License

Usage

Parser/Serializer

const libamf = require('libamf');

const data = libamf.serialize(5, libamf.ENCODING.AMF3);
const int = libamf.deserialize(data, libamf.ENCODING.AMF3);

Server

const {Server, Service} = require('libamf');

class PizzaService extends Service {
	constructor() {
		super('pizza');
		
		this.register('order', 'handleOrder');
		this.register('cancelOrder', this.cancelOrder.bind(this));
		this.register('asyncMethod', 'asyncMethod');
	}
	
	handleOrder(pizza, message) {
		message.respond({ status: 1, message: pizza.type + ' pizza ordered!'});
	}
	
	cancelOrder(pizza, message) {
		const id = pizza.id;
		
		return { status: 1, message: 'Order ' + id + ' has been cancelled successfully.'};
	}

	asyncMethod(message) {
		return new Promise((resolve, reject) => {
			resolve('this will be sent as a response');
		});
	}
}

const server = new Server();

// You can also just do this
server.on('data', packet => {
    console.log(packet);
});

server.registerService(pizzaService);
server.listen(8080, () => {
	console.log('Listening on port 8080');
});

You can stop services from enforcing the -service suffix to the name by doing:

libamf.Service.ForceSuffix = false;

You can also allow any service method to be used without registration by doing:

libamf.Service.RequireRegistration = false;

If you wish to return other values in your service methods, you can disable responding with return values using:

libamf.Service.ReturnResponses = false;

To write whole numbers as integers, use this:

libamf.AMF3.AssumeIntegers = true;

To disable the default homepage, use:

libamf.Server.DisableDefaultHome = true;

Client

const {Client} = require('libamf');
const client = new Client();

client.connect('http://localhost:8080/');
client.call('pizza-service.order', { type: 'cheese' }).then(res => {
	console.log(res);
});

SOL

const fs = require('fs');
const libamf = require('libamf');

fs.readFile('path/to/file.sol', (err, data) => {
	console.log(libamf.SOL.read(data));

	const newObj = new libamf.SOL.LSO({
        allow: false,
        always: false,
        allowsecure: false,
        alwayssecure: false,
        klimit: 100,
        hstsEnabled: false,
        hstsMaxAge: '0',
        hstsIncSubDomain: false,
        hstsStartTime: '0'
	});
	newObj.filename = 'domain/settings';
	newObj.version = 0;

	console.log(newObj.write());
});

Supported types

AMF0

|Type|Read|Write|Note| |--|--|--|--| |Null|✔|✔| |Undefined|✔|✔| |String|✔|✔| |Long String|✔|✔| |Number|✔|✔| |Boolean|✔|✔| |Reference|✔|✔| |Strict Array|✔|✔| |ECMA Array|✔|✔| |Typed Object|✔|✔| |Date|✔|✔| |AVMPLUS|✔|✔| |XML|✔|✔|

AMF3

|Type|Read|Write|Note| |--|--|--|--| |Undefined|✔|✔| |Null|✔|✔| |String|✔|✔| |Double|✔|✔| |Integer|✔|✔| |Boolean|✔|✔| |Date|✔|✔| |Array|✔|✔| |Dictionary|✔|✔| |Vector|✔|✔| |Byte Array|✔|✔| |Custom object|✔|✔| |XML|✔|✔|

TODO

  • Better documentation
  • Better tests
  • Better TODO