{"_id":"@alu0101163970/constant-folding","_rev":"3-59b61893686bd14d117f2cb3355fffcc","name":"@alu0101163970/constant-folding","dist-tags":{"latest":"1.1.0"},"versions":{"1.0.0":{"name":"@alu0101163970/constant-folding","author":{"name":"Francisco Jesús Mendes Gómez - alu0101163970","email":"alu0101163970@ull.edu.es"},"description":"Constant Folding javascript code","scripts":{"test":"mocha","prod-test":"cd ../constant-folding-production-test-alu0101163970 && npm test","cov":"nyc npm run test","full-cov":"npm run clean && npm i && npm run cov","clean":"rm -rf node_modules package-lock.json","doc":"jsdoc ./src/constant-folding.js -d ./docs -R ./README.md"},"repository":{"type":"git","url":"git+https://github.com/ULL-ESIT-PL-2021/constant-folding-module-alu0101163970.git"},"keywords":["ULL","constant-folding","javascript"],"license":"Unlicense","dependencies":{"commander":"^7.1.0","escodegen":"^1.14.3","espree":"^9.3.1"},"version":"1.0.0","main":"src/constant-folding.js","bin":{"cf":"bin/constant-folding-cli.js"},"devDependencies":{"chai":"latest","jison":"latest","jsdoc":"latest","mocha":"latest","nyc":"latest"},"gitHead":"47acf12604d139832dfb14a57c00396381b60f95","bugs":{"url":"https://github.com/ULL-ESIT-PL-2021/constant-folding-module-alu0101163970/issues"},"homepage":"https://github.com/ULL-ESIT-PL-2021/constant-folding-module-alu0101163970#readme","_id":"@alu0101163970/constant-folding@1.0.0","_nodeVersion":"17.5.0","_npmVersion":"8.4.1","dist":{"integrity":"sha512-eYa5WN6u0wy/u6ExuwCQxYuYg5UhgzskYalTwiq8otHijKLtQ0YZ+OyKSG4VsFaFycysc/IQxEpVpeFDjzdDvA==","shasum":"b351d00584d8a0eb17b8d4577461f391b66f3cc7","tarball":"https://registry.npmjs.org/@alu0101163970/constant-folding/-/constant-folding-1.0.0.tgz","fileCount":39,"unpackedSize":1040973,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiJ8EtACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpYxA/9EwdJnkCNc7Ftn6ne5+lFQly3v6SRf13J3/4x1ylISZT2PIxT\r\nWlKuaLzD8g6CKgTM1RP2kzUYqrbUFped22IZkmGYZFXH3D6OOH0yJN8DU38y\r\nPWKJ4CBJVfY4/Hs5b3paFK0FBNSN7C2ARXOfoYIG3w/ENfUxakW8QNx/91rv\r\nV9couVvz04K2fshM4YwZaPTnH03lwannHrwx93Yel/Y3fUachPDpgY4w9zn3\r\nd8zXv/xIrKjnOoQ6TguQ84xE/W6KfQ51iEYFVtZj0rlta564ZqcU+DX9eET8\r\njEkX2PEOV3aeeu5v6gkLg1z4+M0Vd46+EOadkC5p5iY7L2gAf7xijxJwzsvw\r\nOW9LB81Z6/Oz7IJdLpA4QTQxxZ7Kl1syjZQt+IW5Yr3k7pj33oYLU7XtQUzL\r\nZfnJB9nfQC6Eo++cb19+b2YdgSduKpxTYu26wi56y1XxGsG1Xo+dCMYDnz+M\r\nuQPxn0mH4qTjP3TfG1EyFPUB1r5dRBtpKXH8W48+vy7sYA4wPhgULEsznnwH\r\nJ0ozf5oxXKJNwEvpoJ/OYD+Ja8kKtXC5oS6lPNkoWzCNKZjy3PXgzKtatzA1\r\np60gLc2w0hIwJh7pey5COcWUPiJOWw3Lc/8TZDR/T2lyE/XRLq1Bdsr67zfz\r\nUvlFWTKpVSEPtQdtd6Oevh4JyUS9lXHO0qA=\r\n=PgAe\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCZgWfxTljBCCUsmQ3ULEaEThXflnvlqPmT+kwCeMIOtwIgP4iqr4LFCGA6100CSOWoJ/MpONehAxY+19nmmy4Frao="}]},"_npmUser":{"name":"alu0101163970","email":"alu0101163970@ull.edu.es"},"directories":{},"maintainers":[{"name":"alu0101163970","email":"alu0101163970@ull.edu.es"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/constant-folding_1.0.0_1646772524990_0.5554001681294987"},"_hasShrinkwrap":false},"1.0.1":{"name":"@alu0101163970/constant-folding","author":{"name":"Francisco Jesús Mendes Gómez - alu0101163970","email":"alu0101163970@ull.edu.es"},"description":"Constant Folding javascript code","scripts":{"test":"mocha","prod-test":"cd ../constant-folding-production-test-alu0101163970 && npm test","cov":"nyc npm run test","full-cov":"npm run clean && npm i && npm run cov","clean":"rm -rf node_modules package-lock.json","doc":"jsdoc ./src/constant-folding.js -d ./docs -R ./README.md"},"repository":{"type":"git","url":"git+https://github.com/ULL-ESIT-PL-2021/constant-folding-module-alu0101163970.git"},"keywords":["ULL","constant-folding","javascript"],"license":"Unlicense","dependencies":{"commander":"^7.1.0","escodegen":"^1.14.3","espree":"^9.3.1"},"version":"1.0.1","main":"src/constant-folding.js","bin":{"cf":"bin/constant-folding-cli.js"},"devDependencies":{"chai":"latest","jison":"latest","jsdoc":"latest","mocha":"latest","nyc":"latest"},"gitHead":"7f58c5ff48480f942ba6e1d07c06c28733b61c0d","bugs":{"url":"https://github.com/ULL-ESIT-PL-2021/constant-folding-module-alu0101163970/issues"},"homepage":"https://github.com/ULL-ESIT-PL-2021/constant-folding-module-alu0101163970#readme","_id":"@alu0101163970/constant-folding@1.0.1","_nodeVersion":"17.5.0","_npmVersion":"8.4.1","dist":{"integrity":"sha512-xQpezfQnwFttUyhEe9wLYnmWmvnfG5X3Uw83y+DYWlgV9TzCqTkRufrJsFjzzNCi6gcau/jY+u1Lf1ZVvQwIrQ==","shasum":"38e3415983866b0a8e6a902cced25eb0b18eef2d","tarball":"https://registry.npmjs.org/@alu0101163970/constant-folding/-/constant-folding-1.0.1.tgz","fileCount":39,"unpackedSize":1041815,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiKRDlACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpdOhAAiHpBlL0Zt9+FbtwxZG1ZDRkeUJYUR+17OnJQ4D9gZuxQuvZd\r\nmSW8tgD9Q4fu102rF3VQNgmZJJkQZnXQLXYnG2AkuFvSGfOjD+XcqJ0qWXsY\r\nYNx5mrIFeNLSCV+7zLYmyrArQapsu+Je3/KakKdgR34TgofIKlrz4uPeJ8TQ\r\n5g0klmMcApCal+qB0hX5r0U3wnGzQ0oA5Vlx+Pz3R9FSIucDTcYmqgDHFG/b\r\n536urXFxgNF6PuhQ+N0/ZScIsJkzYgzH2Ing1QBzPnjgQNusPH+8ppeqHyvi\r\nrJHW+r5rJGnvl5wd9fzFzB9BHy/ucrIHE2NRFucQB/2O+MXT46W3sY/BoRrU\r\niAOHvshyvttRb8qZICeFzVQSO1e9IU+yP9S0QmLRzd3DJcRNw4Bw7+gg9Uxz\r\nxpckuyteMhECet+HccOBmjFotie/q6SGnmT2qb99R1qiLgYCR7aPXe2Z3m8U\r\nnB1XBaAAxE2T1a5XLlUnSzelyRkzGkd8xoHhrMQhmbdMT5R5I6jJKvjL4hDs\r\n3iSX2PN0m/LhB7OWIZOv12+TmihVe6pnZwIJ2mi2OLpBAjFBlCahir7d3e0n\r\nVGHjP31sNwFhkhLuyfE9QR3Yc+VFjWH8+XQCqoXrG5cyJMRjWIveVNCoUL1b\r\n0CFJtsbrNcRduJ9ly1/+azw7Yh8QlKrbWrM=\r\n=Fu8j\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDdiZzQwadsyaqQrI5iV13RZVxwBxF75S/Biam289jtLAiEAi0ECcR871AHl6o8aZG8PVhlSbW7MhzLmYRkx0lTOBok="}]},"_npmUser":{"name":"alu0101163970","email":"alu0101163970@ull.edu.es"},"directories":{},"maintainers":[{"name":"alu0101163970","email":"alu0101163970@ull.edu.es"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/constant-folding_1.0.1_1646858469636_0.7698897759970162"},"_hasShrinkwrap":false},"1.1.0":{"name":"@alu0101163970/constant-folding","author":{"name":"Francisco Jesús Mendes Gómez - alu0101163970","email":"alu0101163970@ull.edu.es"},"description":"Constant Folding javascript code","scripts":{"test":"mocha","prod-test":"cd ../constant-folding-production-test-alu0101163970 && npm test","cov":"nyc npm run test","full-cov":"npm run clean && npm i && npm run cov","clean":"rm -rf node_modules package-lock.json","doc":"jsdoc ./src/constant-folding.js -d ./docs -R ./README.md"},"repository":{"type":"git","url":"git+https://github.com/ULL-ESIT-PL-2021/constant-folding-module-alu0101163970.git"},"keywords":["ULL","constant-folding","javascript"],"license":"Unlicense","dependencies":{"commander":"^7.1.0","escodegen":"^1.14.3","espree":"^9.3.1"},"version":"1.1.0","main":"src/constant-folding.js","bin":{"cf":"bin/constant-folding-cli.js"},"devDependencies":{"chai":"latest","jison":"latest","jsdoc":"latest","mocha":"latest","nyc":"latest"},"gitHead":"474a6514fcc54f96a595f0efcfbbc09d2628138f","bugs":{"url":"https://github.com/ULL-ESIT-PL-2021/constant-folding-module-alu0101163970/issues"},"homepage":"https://github.com/ULL-ESIT-PL-2021/constant-folding-module-alu0101163970#readme","_id":"@alu0101163970/constant-folding@1.1.0","_nodeVersion":"17.5.0","_npmVersion":"8.4.1","dist":{"integrity":"sha512-zEh989xz5G8eOLsxRP/WlzGZ7Zq14Svw32ijYA5giXoAaywTA0pQRwKhKKlLi7UCmBNNz2JeuYjgOqluSigADQ==","shasum":"9bbd4713a541887ee9066f75523f7a6ecb540c64","tarball":"https://registry.npmjs.org/@alu0101163970/constant-folding/-/constant-folding-1.1.0.tgz","fileCount":38,"unpackedSize":1052456,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiKT0sACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqLPw//UMfEwqwYdNSq9VRtH2/Boa7yLMjRAfweQmr+TMPC321YVdI2\r\nt2217CzWP+fFdK6+wPDBsDYkDXBFCtkVisMlaXPIgsZyJKk7vvt/XJftJD6f\r\nFxXMlgIZ/yatmUJngCK8fHKNcEFWKUvQ010h2cpDNf1gq2uBUm4v1KI+yL+t\r\n49+jw1ojX5uWETW3JukFs2ThI2nTDvAj3fTlo7z7FvW8x7VRp4pne5f28PoC\r\nncxRFxBiiPzXfqS7LoPA6Nv/UNH8JA3r+vgLCesOoqTwQFd02RArdW2CG9w+\r\nWzJdeQ+a8ZgOyh+TSFN1ZS/iNJpp//rFouGhTAYRm7vCB0DrlQluzF0juWwP\r\nuBr4Swz2KbAKeeW1Drv1tUG6CdqOM8/IgdfVz4hCVM3ui2DwRllye65bK5Yz\r\nSwkG8BuhAoqEDByZuusTS6hGN1P8mNPHNdHbp+IvksF/RVziI7aPflNMn+ui\r\nWS9r9GEPiFuF3BS5wGJgB0wzfyn7vDv47Cd96J9jyIMeZWVsO9mhjUlB0Q81\r\nSY7QwiI5jT8B3OHl/Ek1cNKY/f0GgjnA3ztllHjteUNgc3s8UpUKp4xlHXUr\r\n56Uj/JzMqukwzeYfghyCT3QrsRgvnTCHq49ePhIxovNkr4ePLxNCbiX/zgBj\r\n63S/+6DrNIHpCWKSjX1nZMLWoh1vUfXLfkI=\r\n=EC1F\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCt4IMz20QXSGkocBzOVDgqRaA/aIetJCdarODMA4pivgIhAKbLV9XWBxclCyXXCwskhdEBFV7opXbn88dud6IUumdt"}]},"_npmUser":{"name":"alu0101163970","email":"alu0101163970@ull.edu.es"},"directories":{},"maintainers":[{"name":"alu0101163970","email":"alu0101163970@ull.edu.es"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/constant-folding_1.1.0_1646869804705_0.28733002198229696"},"_hasShrinkwrap":false}},"time":{"created":"2022-03-08T20:48:44.938Z","1.0.0":"2022-03-08T20:48:45.176Z","modified":"2022-04-04T13:41:05.331Z","1.0.1":"2022-03-09T20:41:09.843Z","1.1.0":"2022-03-09T23:50:04.942Z"},"maintainers":[{"name":"alu0101163970","email":"alu0101163970@ull.edu.es"}],"description":"Constant Folding javascript code","homepage":"https://github.com/ULL-ESIT-PL-2021/constant-folding-module-alu0101163970#readme","keywords":["ULL","constant-folding","javascript"],"repository":{"type":"git","url":"git+https://github.com/ULL-ESIT-PL-2021/constant-folding-module-alu0101163970.git"},"author":{"name":"Francisco Jesús Mendes Gómez - alu0101163970","email":"alu0101163970@ull.edu.es"},"bugs":{"url":"https://github.com/ULL-ESIT-PL-2021/constant-folding-module-alu0101163970/issues"},"license":"Unlicense","readme":"[![npm version](https://badge.fury.io/js/%40alu0101163970%2Fconstant-folding.svg)](https://badge.fury.io/js/%40alu0101163970%2Fconstant-folding)\n[![CI for constant-folding](https://github.com/ULL-ESIT-PL-2122/constant-folding-module-francisco-mendes-gomez-alu0101163970/actions/workflows/nodejs.yml/badge.sv)](https://github.com/ULL-ESIT-PL-2122/constant-folding-module-francisco-mendes-gomez-alu0101163970/actions/workflows/nodejs.yml)\n\n## constant-folding\nConstant folding is the process of recognizing and evaluating constant expressions at compile time rather than computing them at runtime. Terms in constant expressions are typically simple literals, such as the integer literal 2, but they may also be variables whose values are known at compile time. Consider the statement:  \n\n  i = 320 * 200 * 32;  \n\nMost compilers would not actually generate two multiply instructions and a store for this statement. Instead, they identify constructs such as these and substitute the computed values at compile time (in this case, 2,048,000). \n\nIn this module we have a program which makes the constant folding of a js code.\n## Installation\nTo install execute:\n```\nnpm install @alu0101163970/constant-folding --save\n```\n## Usage as executable:\n+ Version\n```\nuser (master) $ cf -V\n1.0.0\n```  \n+ Usage\n```\nuser (master) $ cf -h\nUsage: constant-folding-js cf <input> <output>\n\nConstant Folding javascript code\n\nArguments:\n  input          file with the original code\n  output         file which its write the output code\n\nOptions:\n  -V, --version  output the version number\n  -h, --help     display help for command\n```  \n+ Excute program\n```\nuser (master) $ cat examples/examples.js \nvar f = 3+null;\nvar e = 4 | 3;\nvar d = 3+\"c\";\nvar b = 9 +1;\nvar a = 2+3*5+b;\n\nuser (master) $ cf examples/examples.js output.js\nFile read succesfully\nOutput written succesfully in output.js\n\nuser (master) $ cat output.js \nvar f = 3;\nvar e = 7;\nvar d = '3c';\nvar b = 10;\nvar a = 17 + b;\n```\n\n## Usage from code:\n\n```javascript\n//Export function\nconst constantFolding = require('constant-folding');\n\n//Create a string with js code\nconst input = \n              `var f = 3+null;\n               var e = 4 | 3;\n               var d = 3+\"c\";\n               var b = 9 +1;\n               var a = 2+3*5+b;`;\n\n//call function\nconst output = constantFolding(input); \n\nconsole.log(output);\n/* OUTPUT\nvar f = 3;\nvar e = 7;\nvar d = '3c';\nvar b = 10;\nvar a = 17 + b;\n*/\n```\n\n[The documentation of the function](https://ull-esit-pl-2122.github.io/constant-folding-module-francisco-mendes-gomez-alu0101163970/).\n\n## Author\n\nalu0101163970 - Francisco Jesús Mendes Gómez\n\n## Tests\n\nTo execute tests use:\n\n```\nnpm test\n```\n\nYou will see:\n\n```\nuser (master) $ npm test\n\n> @alu0101163970/constant-folding@1.0.1 test\n> mocha\n\n\n\n  constantFolding tests\n    ✔ works correctly with normal functions -> a=2*3;\n    ✔ works correctly with normal functions -> a=3+null\n    ✔ works correctly with normal functions -> a=4 | 3\n    ✔ works correctly with normal functions -> a=3+\"c\"\n    ✔ works correctly with normal functions -> a=9 +1\n    ✔ works correctly with normal functions -> a=2+3*5+b\n{\n  \"type\": \"Program\",\n  \"start\": 0,\n  \"end\": 9,\n  \"body\": [\n    {\n      \"type\": \"ExpressionStatement\",\n      \"start\": 0,\n      \"end\": 9,\n      \"expression\": {\n        \"type\": \"AssignmentExpression\",\n        \"start\": 0,\n        \"end\": 9,\n        \"operator\": \"=\",\n        \"left\": {\n          \"type\": \"Identifier\",\n          \"start\": 0,\n          \"end\": 1,\n          \"name\": \"a\"\n        },\n        \"right\": {\n          \"type\": \"BinaryExpression\",\n          \"start\": 2,\n          \"end\": 9,\n          \"left\": {\n            \"type\": \"Literal\",\n            \"start\": 2,\n            \"end\": 7,\n            \"operator\": \"+\",\n            \"value\": 17,\n            \"raw\": \"17\"\n          },\n          \"operator\": \"+\",\n          \"right\": {\n            \"type\": \"Identifier\",\n            \"start\": 8,\n            \"end\": 9,\n            \"name\": \"b\"\n          }\n        }\n      }\n    }\n  ],\n  \"sourceType\": \"script\"\n}\n    ✔ Debug Test -> a=2+3*5+b Befere we looked the AST\n    ✔ works correctly with Extension functions -> [\"a\", \"b\", \"c\"].concat([\"d\", \"e\"], \"f\", \"g\", [\"h\"])\n    ✔ works correctly with Extension functions -> length = [1, 2, 3].length;\n    ✔ works correctly with Extension functions -> var chuchi = [a, b, c].pop()\n    ✔ works correctly with Extension functions -> var chuchi = ['a', 'b', 'c'].pop()\n\n\n  11 passing (47ms)\n```\n## Versions\n\n+ 1.0.0 Initial release.\n+ 1.0.1 Documentation fix\n+ 1.1.0 new features added \n  + [\"a\", \"b\", \"c\"].concat([\"d\", \"e\"], \"f\", \"g\", [\"h\"]); ---> [\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\"];\n  + [1, 2, 3].length; ---> 3;\n  + [a, b, c].pop(); ---> c;\n\n\n\n","readmeFilename":"README.md"}