postfix.js
v1.0.0-rc.1
Published
Use postfix notation in JavaScript
Downloads
3
Readme
postfix.js
Complex features made easy
$ yarn add [-D] postfix.js
# or
$ npm i -D postfix.jsES6 import
import postfix, {
stackify,
} from "postfix.js";CommonJS require
var postfix = require("postfix.js").default;
stackify = require("postfix.js").stackify;UMD bundle
dist/core.js and dist/core.min.js are UMD bundles.
/* Using AMD require */
require([
"https://unpkg.com/postfix.js",
], function (postfix) {
// postfix
// postfix.stackify
});<!-- Using html <script>-tag -->
<script src="https://unpkg.com/postfix.js"></script>Usage
postfix("60 5 7 5 - * /"); // [ 6 ]
postfix("60 5 / 7 5 - *"); // [ 24 ]
postfix("1 2 x -", {
"x": stack => stack.reverse(),
}); // [ 1 ]
postfix("-1 abs", {
"abs": stackify(Math.abs),
}); // [ 1 ]Nativly supported operations: +, -, *, /, % and ^ (Math.pow)
