1.1.2 • Published 4 years ago

@electrk/dso v1.1.2

Weekly downloads
-
License
ISC
Repository
github
Last release
4 years ago

dso.js

A DSO decompiler for Blockland.

Installation

npm install @electrk/dso

Usage

Use with the buffer package.

Browser Example:

import { Buffer }     from 'buffer/';
import { decompiler } from '@electrk/dso';


// An HTML <input> element with the type "file" and an ID of "fileUpload"
document.getElementById ('fileUpload').onchange = function ( event )
{
	if ( event.target.files.length <= 0 )
	{
		return;
	}

	const file   = event.target.files[0];
	const reader = new FileReader ();

	reader.readAsArrayBuffer (file);

	reader.onload = function ( readerEvent )
	{
		const buffer     = Buffer.from (readerEvent.target.result);
		const codeString = decompiler.decompileDSO (buffer);

		console.log (codeString);
	};
};

Node.js Example:

const fs = require ('fs');

const { decompiler } = require ('@electrk/dso');


fs.readFile ('./myFile.cs.dso', ( error, buffer ) =>
{
	if ( error )
	{
		console.error (error);
		return;
	}

	const codeString = decompiler.decompileDSO (buffer);

	fs.writeFileSync ('./myFile.cs', codeString);
});

Decompiler Options

The optional second argument of decompileDSO is an options object.

The only one at the moment is the outputArray boolean, which is false by default. When set to true, it makes decompileDSO output a nested code array instead of a string.

Enable the option like this:

decompiler.decompileDSO (buffer, { outputArray: true });
1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago