diff --git a/README.md b/README.md index d2545b6..c3425ad 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,8 @@ Equation.registerConstant('N', () => { Equation.solve('N'); // a number between 10 and 20 ``` +For a list of operators and constants see `[operators.js](https://github.com/mdibaiee/Equation.js/blob/master/lib/operators.js)` and `[constants.js](https://github.com/mdibaiee/Equation.js/blob/master/lib/constants.js)`. + API === ####solve(expression: String) diff --git a/npm-debug.log b/npm-debug.log new file mode 100644 index 0000000..6de215d --- /dev/null +++ b/npm-debug.log @@ -0,0 +1,100 @@ +0 info it worked if it ends with ok +1 verbose cli [ 'node', '/usr/local/bin/npm', 'publish' ] +2 info using npm@2.5.1 +3 info using node@v0.12.0 +4 verbose node symlink /usr/local/bin/node +5 verbose publish [ '.' ] +6 silly cache add args [ '.', null ] +7 verbose cache add spec . +8 silly cache add parsed spec { raw: '.', +8 silly cache add scope: null, +8 silly cache add name: null, +8 silly cache add rawSpec: '.', +8 silly cache add spec: '/Users/mahdi/Documents/Workshop/equation', +8 silly cache add type: 'directory' } +9 verbose addLocalDirectory /Users/mahdi/.npm/equations/1.0.0/package.tgz not in flight; packing +10 verbose tar pack [ '/Users/mahdi/.npm/equations/1.0.0/package.tgz', +10 verbose tar pack '/Users/mahdi/Documents/Workshop/equation' ] +11 verbose tarball /Users/mahdi/.npm/equations/1.0.0/package.tgz +12 verbose folder /Users/mahdi/Documents/Workshop/equation +13 info prepublish equations@1.0.0 +14 verbose addLocalTarball adding from inside cache /Users/mahdi/.npm/equations/1.0.0/package.tgz +15 silly cache afterAdd equations@1.0.0 +16 verbose afterAdd /Users/mahdi/.npm/equations/1.0.0/package/package.json not in flight; writing +17 verbose afterAdd /Users/mahdi/.npm/equations/1.0.0/package/package.json written +18 silly publish { name: 'equations', +18 silly publish version: '1.0.0', +18 silly publish description: 'Equation ======== Solve math expressions or create equations for repeated and complex Math tasks.', +18 silly publish main: 'dist/index.js', +18 silly publish directories: { test: 'tests' }, +18 silly publish scripts: { test: 'grunt test' }, +18 silly publish keywords: [ 'Math', 'JavaScript' ], +18 silly publish author: { name: 'Mahdi Dibaiee' }, +18 silly publish license: 'MIT', +18 silly publish devDependencies: +18 silly publish { browserify: '^9.0.8', +18 silly publish grunt: '^0.4.5', +18 silly publish 'grunt-babel': '^5.0.0', +18 silly publish 'grunt-browserify': '^3.7.0', +18 silly publish 'grunt-contrib-uglify': '^0.9.1', +18 silly publish 'grunt-contrib-watch': '^0.6.1', +18 silly publish 'grunt-eslint': '^11.0.0', +18 silly publish 'grunt-mocha-test': '^0.12.7', +18 silly publish mocha: '^2.2.4' }, +18 silly publish readme: 'Equation\n========\nSolve math expressions or create equations for repeated and complex Math tasks.\n\nTo use in browser, download [`equation.min.js`](https://raw.githubusercontent.com/mdibaiee/Equation.js/master/equation.min.js).\n\nInstall using npm:\n\n```\nnpm install equations\n```\n\n####Examples:\n\n```javascript\n// solve\nconsole.log(Equation.solve(\'4 * lg(4) ^ 3\')); // 32\n\n// equation\nlet sphereArea = Equation.equation(\'4 * PI * r^2\');\n\nconsole.log(sphereArea(5)); // 314.1592653589793\n```\n\nYou can also register your own operators and constants.\n\n```javascript\n// these options are explained below\nEquation.registerOperator(\'$\', {\n fn: a => 1/a,\n format: \'10\',\n precedence: 2\n});\n\nEquation.solve(\'$2\'); // 0.5\nEquation.solve(\'$5\'); // 0.2\n\nEquation.registerConstant(\'N\', () => {\n return Math.random() * 10 + 10\n});\n\nEquation.solve(\'N\'); // a number between 10 and 20\n```\n\nAPI\n===\n####solve(expression: String)\nTakes a math expression and evaluates it, returning the result.\n\n####equation(expression: String)\nTakes a math expression containing variables, returning a function which\nreplaces the variables with given arguments, and solves the expression.\n\n####registerOperator(key: String, options: Object)\nRegisters a new operator.\n\nOptions:\n\n#####fn\n The function which is run on arguments and returns the result\n#####format\n The format which specifies how arguments are placed relative to operator, this is a string in which 1 represents the operator and zeroes represent arguments.\n\n For example `+` has the format `010` and factorial has `01`.\n#####precedence\n Specifies the precedence of operator. The less the value, the higher the precedence, resulting in sooner execution.\n\n####registerConstant(key: String, value: Function/Number)\nRegisters a new constant. value can be a function (takes no arguments), or a constant number.\n\nThat\'s right, we have named these *constants* but they actually can change, that\'s why we can use functions to define them. An example is the `RAND` constant which calls `Math.random`.\n\nContributing\n============\nThe code is commented and I hope you don\'t have a hard time contributing,\nanyway, some tips about contributing:\n\nThe source code is in `lib` directory and is then transpiled into `dist`.\n\n#####Grunt Tasks\n######default\nTranspiles `lib` to `dist`\n######build\nTranspiles, browserifies, uglifies\n######eslint\nRuns ESLint on `lib` and `tests`\n######test\nRuns the tests\n\n---\nPlease make sure to run `grunt eslint` before commiting.\n\nIf you\'re adding something new, please add a test, too.\n\nTODO\n====\n* Equation solver\n* More tests\n', +18 silly publish readmeFilename: 'README.md', +18 silly publish gitHead: 'b08841e51b4aa34cb11edaa9a19e6983dda53bff', +18 silly publish _id: 'equations@1.0.0', +18 silly publish _shasum: '56ad9f9971b9af509e9997f5907922b792e4b2a5', +18 silly publish _from: '.' } +19 silly mapToRegistry name equations +20 silly mapToRegistry using default registry +21 silly mapToRegistry registry https://registry.npmjs.org/ +22 silly mapToRegistry uri https://registry.npmjs.org/equations +23 verbose publish registryBase https://registry.npmjs.org/ +24 silly publish uploading /Users/mahdi/.npm/equations/1.0.0/package.tgz +25 verbose request uri https://registry.npmjs.org/equations +26 verbose request sending authorization for write operation +27 info attempt registry request try #1 at 14:49:13 +28 verbose request using bearer token for auth +29 verbose request id 87deb4516c1b4c02 +30 http request PUT https://registry.npmjs.org/equations +31 http 403 https://registry.npmjs.org/equations +32 verbose headers { date: 'Tue, 21 Apr 2015 10:19:05 GMT', +32 verbose headers server: 'Apache', +32 verbose headers 'content-type': 'application/json', +32 verbose headers 'cache-control': 'max-age=60', +32 verbose headers 'content-length': '95', +32 verbose headers 'accept-ranges': 'bytes', +32 verbose headers via: '1.1 varnish', +32 verbose headers 'x-served-by': 'cache-iad2126-IAD', +32 verbose headers 'x-cache': 'MISS', +32 verbose headers 'x-cache-hits': '0', +32 verbose headers 'x-timer': 'S1429611545.135478,VS0,VE364', +32 verbose headers 'keep-alive': 'timeout=10, max=50', +32 verbose headers connection: 'Keep-Alive' } +33 verbose request invalidating /Users/mahdi/.npm/registry.npmjs.org/equations on PUT +34 error publish Failed PUT 403 +35 verbose stack Error: "You cannot publish over the previously published version 1.0.0." : equations +35 verbose stack at CachingRegistryClient. (/usr/local/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:254:14) +35 verbose stack at Request._callback (/usr/local/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:178:14) +35 verbose stack at Request.self.callback (/usr/local/lib/node_modules/npm/node_modules/request/request.js:344:22) +35 verbose stack at Request.emit (events.js:110:17) +35 verbose stack at Request. (/usr/local/lib/node_modules/npm/node_modules/request/request.js:1239:14) +35 verbose stack at Request.emit (events.js:129:20) +35 verbose stack at IncomingMessage. (/usr/local/lib/node_modules/npm/node_modules/request/request.js:1187:12) +35 verbose stack at IncomingMessage.emit (events.js:129:20) +35 verbose stack at _stream_readable.js:908:16 +35 verbose stack at process._tickCallback (node.js:355:11) +36 verbose statusCode 403 +37 verbose pkgid equations +38 verbose cwd /Users/mahdi/Documents/Workshop/equation +39 error Darwin 14.3.0 +40 error argv "node" "/usr/local/bin/npm" "publish" +41 error node v0.12.0 +42 error npm v2.5.1 +43 error code E403 +44 error "You cannot publish over the previously published version 1.0.0." : equations +45 error If you need help, you may report this error at: +45 error +46 verbose exit [ 1, true ]