{"name":"preprocessor","version":"1.1.0","author":{"name":"Daniel Wirtz","email":"dcode@dcode.io"},"description":"Preprocessor.js: A JavaScript source file preprocessor, e.g. to build different versions of a library.","main":"Preprocessor.js","bin":{"preprocess":"./bin/preprocess"},"repository":{"type":"git","url":"https://github.com/dcodeIO/Preprocessor.js.git"},"bugs":{"url":"https://github.com/dcodeIO/Preprocessor.js/issues"},"keywords":["source","source code","JavaScript","ECMAScript","preprocessor","pre-processor","pre processor","processor","utility"],"dependencies":{},"devDependencies":{"nodeunit":">=0.7","closurecompiler":">=1.1"},"license":"Apache License, Version 2.0","engines":{"node":">=0.8"},"scripts":{"prepublish":"npm test","test":"nodeunit tests/suite.js","make":"npm run-script compile && npm test && npm run-script jsdoc","compile":"ccjs Preprocessor.js --create_source_map=Preprocessor.min.map --compilation_level=ADVANCED_OPTIMIZATIONS --externs=node > Preprocessor.min.js","jsdoc":"jsdoc -c jsdoc.json"},"_id":"preprocessor@1.1.0","dist":{"shasum":"80978a333ead985c1afa9ad5fa7d3b9480a2746a","tarball":"http://registry-npm.ywwl.com/preprocessor/download/preprocessor-1.1.0.tgz","integrity":"sha512-XMzKIFZB3z6xPVMN3gYxjWlSBx6ZlR0h23Zf54mu8pSzORTUC42Ynat0B8GOvCGx+qPdXNHHHErK4RFY8NfsMQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBQZKnuaVsOfK85zXttdzfg3/TaAueqc3GcWKTPRTYWmAiBSYa2wvKApxFVJ/yJKFzhFBdhYwiK+rsJUjrlvu9GTvg=="}],"size":38304,"noattachment":false,"key":"/preprocessor/-/preprocessor-1.1.0.tgz"},"_from":".","_npmVersion":"1.2.32","_npmUser":{"name":"dcode","email":"dcode@dcode.io"},"maintainers":[{"name":"dcode","email":"dcode@dcode.io"}],"directories":{},"readme":"![Preprocessor.js - A JavaScript preprocessor](https://raw.github.com/dcodeIO/Preprocessor.js/master/Preprocessor.png)\r\n===========================================\r\nProvides a JavaScript source file preprocessor, e.g. to build different versions of a library. It's for example used to\r\nbuild [ProtoBuf.js](https://github.com/dcodeIO/ProtoBuf.js) (its [build](https://github.com/dcodeIO/ProtoBuf.js/blob/master/build.js)\r\nand [main script](https://github.com/dcodeIO/ProtoBuf.js/blob/master/src/ProtoBuf.js) are quite good examples).\r\n\r\nDirectives\r\n----------\r\n* Includes (always relative to the `baseDirectory`, defaults to \".\"):\r\n\r\n ```javascript\r\n ...\r\n // #include \"path/to/file.js\"\r\n ...\r\n ```\r\n\r\n* Static conditions:\r\n\r\n ```javascript\r\n // #ifdef FULL\r\n console.log(\"Including extension\");\r\n // #include \"path/to/extension.js\"\r\n // #else\r\n console.log(\"Not including extension\");\r\n // #endif\r\n ```\r\n \r\n* Inverse static conditions:\r\n\r\n ```javascript\r\n // #ifndef FULL\r\n console.log(\"Not including extension\");\r\n // #else\r\n console.log(\"Including extension\");\r\n // #include \"path/to/extension.js\"\r\n // #endif\r\n ```\r\n \r\n* Evaluable conditions:\r\n \r\n ```javascript\r\n // #if 1==2\r\n console.log(\"1==2\");\r\n // #elif 2==2\r\n console.log(\"2==2\");\r\n // #endif\r\n ```\r\n\r\n* Inline variables and functions:\r\n\r\n ```js\r\n // #define var PI=Math.PI\r\n // #define function RADTODEG(x){return x*180/PI}\r\n var angle = // #put RADTODEG(3)+\";\"\r\n ```\r\n \r\n* Writing the result of evaluated expressions:\r\n\r\n  ```javascript\r\n  var version = // #put '\"'+VERSION+'\";\"'\r\n  var str = // #put \"\\\"Hello world!\\\";\"\r\n  var onePlusOne = // #put (1+1)+\";\"\r\n  ```\r\n \r\nFeatures\r\n--------\r\n* [CommonJS](http://www.commonjs.org/) compatible\r\n* [RequireJS](http://requirejs.org/)/AMD compatible\r\n* Shim compatible (include the script, then use var ByteBuffer = dcodeIO.ByteBuffer;)\r\n* [node.js](http://nodejs.org) compatible, also available via [npm](https://npmjs.org/package/preprocessor)\r\n* [Closure Compiler](https://developers.google.com/closure/compiler/) ADVANCED_OPTIMIZATIONS compatible (fully annotated,\r\n`Preprocessor.min.js` has been compiled this way, `Preprocessor.min.map` is the source map)\r\n* Fully documented using [jsdoc3](https://github.com/jsdoc3/jsdoc)\r\n* Well tested through [nodeunit](https://github.com/caolan/nodeunit)\r\n* Zero production dependencies\r\n* Small footprint\r\n\r\nCommand line utility\r\n--------------------\r\nInstall via npm: `npm -g install preprocessor`\r\n\r\n#### Command line ####\r\n\r\nUsage: `preprocess sourceFile [baseDirectory] [-myKey[=myValue], ...] [> outFile]`\r\n\r\n```bash\r\npreprocess Source.js . -FULL=true > Source.full.js\r\n```\r\n\r\nAPI\r\n---\r\nThe API is quite simple:\r\n\r\n```javascript\r\nvar result = new Preprocessor(\r\n    mainFileSource,\r\n    baseDirectoryOrIncludes\r\n).process(defines);\r\n```\r\n\r\nwith `baseDirectoryOrIncludes` being either a string containing the path to the base directory or an object of included\r\nsources by filename. When running in a browser, only the later is supported.\r\n\r\n#### node.js / CommonJS ####\r\n\r\n```javascript\r\nvar Preprocessor = require(\"preprocessor\");\r\nvar source = \"...\"; // e.g. through fs.readFile\r\nvar pp = new Preprocessor(source, \".\");\r\nconsole.log(pp.process({\r\n    FULL: true\r\n}));\r\n```\r\n\r\n#### RequireJS / AMD ####\r\n\r\n```javascript\r\nrequire([\"/path/to/Preprocessor.js\"], function(Preprocessor) {\r\n    var source = \"...\"; // e.g. through fs.readFile / $.ajax\r\n    var pp = new Preprocessor(source, \".\");\r\n    console.log(pp.process({\r\n        FULL: true\r\n    }));\r\n});\r\n```\r\n\r\n#### Browser / shim ####\r\n**Note:** To use the `#include` directive in the browser, do not specify the base directory but an object of included\r\nsources by filename:\r\n\r\n```html\r\n<script src=\"//raw.github.com/dcodeIO/Preprocessor.js/master/Preprocessor.min.js\"></script>\r\n```\r\n\r\n```javascript\r\nvar Preprocessor = dcodeIO.Preprocessor;\r\nvar source = \"...\"; // e.g. through. $.ajax\r\nvar pp = new Preprocessor(source, {\r\n    \"./includes/extension.js\": \"var myVar = 2;\" // <- #include \"includes/extension.js\"\r\n});\r\nalert(pp.process({\r\n    FULL: true\r\n}));\r\n```\r\n\r\nUsing includes instead of a base directory like shown in the example above is supported regardless of the platform you\r\nare on.\r\n\r\nDownloads\r\n---------\r\n* [ZIP-Archive](https://github.com/dcodeIO/Preprocessor.js/archive/master.zip)\r\n* [Tarball](https://github.com/dcodeIO/Preprocessor.js/tarball/master)\r\n\r\nDocumentation\r\n-------------\r\n* [View documentation](http://htmlpreview.github.com/?http://github.com/dcodeIO/Preprocessor.js/master/docs/Preprocessor.html)\r\n\r\nTests (& Examples) [![Build Status](https://travis-ci.org/dcodeIO/Preprocessor.js.png?branch=master)](https://travis-ci.org/dcodeIO/Preprocessor.js)\r\n------------------\r\n* [View source](https://github.com/dcodeIO/Preprocessor.js/blob/master/tests/suite.js)\r\n* [View report](https://travis-ci.org/dcodeIO/Preprocessor.js)\r\n\r\nLicense\r\n-------\r\nApache License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.html\r\n","publish_time":1381369329142,"_cnpm_publish_time":1381369329142,"dist-tags":{"latest":"1.4.0"}}