Git Product home page Git Product logo

solmeister's Introduction

solmeister

Edit your solidity code by applying transforms on its (Spider Monkey compliant) AST's nodes.

#Installation

npm install solmeister

#Usage

let solmeister = require ('solmeister');

##Available methods -> version (): Version information

-> edit (code, callback): code is the source code on which to operate (This can be a String or a Buffer object) & callback is the function solmeister calls upon entering every Node during the AST treversal. The callback is passed the node just entered.

##Properties of node -> node.parent: access the parent node of the current node

-> node.getSourceCode (): get the source code of the current node

-> node.transform (finalCode): apply the transform on the node by replacing its source code with finalCode.

#Example

/**
 * Append '.00' to every integer and change every Identifier name to lowercase, like:
 * 178 --> 178.00
 * hasEther --> hasether
 */
 
'use strict';

let i = require ('solmeister'),
	code = 'contract Visual {\n\tuint[] x = [13,212,334,44,52];\n\tMIxEDCaSEvAr = 100;\n}';

let output = i.edit (code, function (node) {

	if (node.type === 'Literal' && typeof node.value === 'number' && node.value === parseInt (node.value)) {

		node.transform (node.getSourceCode () + '.00');
	
	} else if (node.type === 'Identifier') {
	
		node.transform (node.getSourceCode ().toLowerCase ());
	
	}

});

console.log ('Version: ', i.version);
console.log (output);

##Code before transform

contract Visual {
	uint[] x = [13,212,334,44,52];
	MIxEDCaSEvAr = 100;
}

##Code after transform

contract Visual {
	uint[] x = [13.00,212.00,334.00,44.00,52.00];
	mixedcasevar = 100.00;
}

solmeister's People

Stargazers

 avatar Jialiang C. avatar yxliang avatar Raghav avatar

Watchers

James Cloos avatar yxliang avatar Raghav avatar  avatar

solmeister's Issues

TODO

  • Browser Support
  • Tests

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.