Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stefanwimmer128/postfix.js
Use postfix notation in JavaScript
https://github.com/stefanwimmer128/postfix.js
Last synced: 2 days ago
JSON representation
Use postfix notation in JavaScript
- Host: GitHub
- URL: https://github.com/stefanwimmer128/postfix.js
- Owner: stefanwimmer128
- License: isc
- Created: 2018-09-18T10:45:25.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-09-18T10:45:47.000Z (over 6 years ago)
- Last Synced: 2024-12-10T01:57:07.499Z (29 days ago)
- Language: JavaScript
- Homepage: https://yarn.pm/postfix.js
- Size: 34.2 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# postfix.js
Complex features made easy
``` bash
$ yarn add [-D] postfix.js
# or
$ npm i -D postfix.js
```## ES6 import
``` js
import postfix, {
stackify,
} from "postfix.js";
```## CommonJS require
``` js
var postfix = require("postfix.js").default;
stackify = require("postfix.js").stackify;
```## UMD bundle
`dist/core.js` and `dist/core.min.js` are UMD bundles.
``` js
/* Using AMD require */
require([
"https://unpkg.com/postfix.js",
], function (postfix) {
// postfix
// postfix.stackify
});
`````` html
```
# Usage
``` js
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`)