{"name":"camaro","version":"5.0.1-alpha.0","description":"Transforming XML to JSON using Node.js binding to native pugixml parser library","homepage":"https://github.com/tuananh/camaro","bugs":{"url":"https://github.com/tuananh/camaro/issues"},"main":"index.js","typings":"index.d.ts","scripts":{"test":"tape test/*.test.js","bench":"node benchmark/transform.js","install-deps":"napa","build":"docker run --rm -v $(pwd):/src trzeci/emscripten ./build.sh","gen-esm":"gen-esm-wrapper . ./index.mjs"},"exports":{".":{"require":"./index.js","import":"./index.mjs"},"./":"./"},"repository":{"type":"git","url":"git+https://github.com/tuananh/camaro.git"},"keywords":["xpath","json","transform","pugixml","xml","parser","n-api","xml2json","webassembly","wasm"],"author":{"name":"Tuan Anh Tran","email":"me@tuananh.org","url":"https://tuananh.org"},"license":"MIT","napa":{"pugixml":"tuananh/pugixml#develop","json":"nlohmann/json#develop","fifo_map":"nlohmann/fifo_map#master"},"napa-config":{"cache":false},"devDependencies":{"gen-esm-wrapper":"^1.0.4","napa":"^3.0.0","tape":"^5.0.0"},"readme":"# camaro\n\n> camaro is an utility to transform XML to JSON, using Node.js binding to native XML parser [pugixml](http://pugixml.org/), one of the fastest XML parser around.\n\n[![npm](https://badgen.net/npm/v/camaro)](https://npm.im/camaro)\n![npm bundle size](https://badgen.net/packagephobia/publish/camaro)\n[![Build Status](https://dev.azure.com/me0499/camaro/_apis/build/status/tuananh.camaro?branchName=develop)](https://dev.azure.com/me0499/camaro/_build/latest?definitionId=1&branchName=develop)\n[![Travis](https://badgen.net/travis/tuananh/camaro/master)](https://travis-ci.org/tuananh/camaro)\n[![AppVeyor](https://badgen.net/appveyor/ci/tuananh/camaro/master)](https://ci.appveyor.com/project/tuananh/camaro)\n[![TypeScript definitions on DefinitelyTyped](https://badgen.net/badge/DefinitelyTyped/.d.ts)](http://definitelytyped.org)\n[![npm](https://badgen.net/npm/dt/camaro)](https://npm.im/camaro)\n\n[Demo on CodeSandbox.io](https://codesandbox.io/s/static-deg9w?fontsize=14)\n\n## 🤘 Features\n\n* Transform XML to JSON. Only take properties that you're interested in.\n* Output is a ready to use JS object.\n* Written in C++ and compiled down to WebAssembly so no compilation needed.\n* Work on all major platforms (OS X, Linux and Windows and the web). See Travis CI and AppVeyor build status for details.\n* No need to build binary whenever a new Node version released.\n* AWS Lambda friendly (or serverless in general).\n* SUPER FAST!! We're using [pugixml](http://pugixml.org/) underneath. It's one of the fastest xml parser around.\n* Small footprint (Zero dependencies).\n* Pretty print XML.\n\n## 🚧 Upgrading notes from version 3 🚧\n\n- camaro v4 slows down quite a bit since switching to WebAssembly. It's still the fastest but slower by big margin. WebAssembly and Emscripten are rather new to me so bare with me while I'm figuring out the performance issue. If you need pure speed, just use camaro v3.\n- 🚨BREAKING: `transform()` is now an async function.\n- 🚨BREAKING: change the way transform is imported `const { transform } = require('camaro')`\n- plan to add `toJson()` function to convert the whole XML input.\n- DONE: plan to add `prettyPrint()` to pretty print XML.\n\n## 🔥 Benchmark\n\n```\ncamaro x 362 ops/sec ±0.31% (87 runs sampled)\nrapidx2j x 226 ops/sec ±0.27% (88 runs sampled)\nxml2json x 46.32 ops/sec ±1.39% (61 runs sampled)\nxml2js x 50.51 ops/sec ±7.22% (68 runs sampled)\nfast-xml-parser x 256 ops/sec ±0.63% (86 runs sampled)\nxml-js x 45.05 ops/sec ±6.19% (61 runs sampled)\n```\n\n* Please note that **this is an unfair game for camaro** because it only transform those fields specified in template.\nThe whole reason of me creating this is because most of the time, I'm just interested in some of the data in the whole XML mess.\n\n* Benchmark run on MacBookPro14,1 - Intel Core i5 CPU @ 2.30GHz using Node v8.10.0.\n\n* I may expose another method to transform the whole XML tree so that the benchmark will better reflect the real performance.\n\nFor complete benchmark, see [benchmark/index.md](benchmark/index.md).\n\n![intro](intro.png)\n\n## Installation\n\n```sh\nyarn add camaro\n# npm install camaro\n```\n\n## Usage\n\nYou can use our custom template format powered by [XPath](https://developer.mozilla.org/en-US/docs/Web/XPath).\n\nWe also introduce some custom syntax such as:\n\n* if a path start with `#`, that means it's a constant. E.g: `#1234` will return `1234`\n* if a path is empty, return blank\n* Some string manipulation functions which are not availble in XPath 1.0 such as `lower-case`, `upper-case`, `title-case`, `camel-case`, `snake-case` and `string-join`. Eventually, I'm hoping to add all XPath 2.0 functions but these are all that I need for now. PRs welcome.\n\nThe rest are pretty much vanilla XPath 1.0.\n\nFor complete API documentation, please see [API.md](API.md)\n\n```js\nconst { ready, transform, prettyPrint } = require('camaro')\nconst fs = require('fs')\n\nconst xml = fs.readFileSync('examples/ean.xml', 'utf-8')\nconst template = {\n    cache_key: '/HotelListResponse/cacheKey',\n    hotels: ['//HotelSummary', {\n        hotel_id: 'hotelId',\n        name: 'name',\n        rooms: ['RoomRateDetailsList/RoomRateDetails', {\n            rates: ['RateInfos/RateInfo', {\n                currency: 'ChargeableRateInfo/@currencyCode',\n                non_refundable: 'boolean(nonRefundable = \"true\")',\n                price: 'number(ChargeableRateInfo/@total)'\n            }],\n            room_name: 'roomDescription',\n            room_type_id: 'roomTypeCode'\n        }]\n    }],\n    session_id: '/HotelListResponse/customerSessionId'\n}\n\n;(async function () {\n    await ready()\n    const result = await transform(xml, template)\n    console.log(result)\n\n    const prettyStr = await prettyPrint(xml, { indentSize: 4})\n    console.log(prettyStr)\n})()\n\n\n```\n\n## Licence\n\n[The MIT License](LICENSE)\n","readmeFilename":"README.md","gitHead":"c9c5ffcb4598945ad091c474889355f726046de4","_id":"camaro@5.0.1-alpha.0","_nodeVersion":"12.16.1","_npmVersion":"6.13.4","dist":{"integrity":"sha512-repw3ij8wU0OkMuo7857UdQoJZ7o1rlt9bQ/CRmwA2JTVNAmVOt7u/RYoFJdo3xhXXC+OX9X9Ua1D7w/5R/1YQ==","shasum":"58ec5b636456d6341e52423c1d22980cf2b5a87e","tarball":"http://registry-npm.ywwl.com/camaro/download/camaro-5.0.1-alpha.0.tgz","fileCount":7,"unpackedSize":212762,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJesRw0CRA9TVsSAnZWagAARzQP/1xUtz/DUBtfIDFea8WT\nT+lrVZJd+gjI1L9/7vPVa2WN2gdDu6vfEo+g+0ZRKL445jx9PSXJFkcHTsCY\nbnZ8bgPiIYl2ZKswwGn/kn2anMhTBR/1Z+yVfHY7ocQCpo/XTrDHbspkDyoU\nC7aBpIcSbir74Lo78lnSk4ddReV0MsYQjQQFmGsAXgdINgfQRIqY1g1nOPWQ\noGpzcSTf2m3ZgpJfCBWymQCISzuXFRGKKpCZ6oZEr2OvWyj/rhmvRhhjkzvJ\nvq9CJVU1V6QjF4nRbsGOOEawFxrSLRIPFJsHaV/yX7TQ8NNNKDzkMA4ucD+J\nNviMWSHCw36vdcgsU1D58/fEhiVIcK/6W+lUo3aurGp8IdWLvmg/eaTniaPJ\nUymxRispIxL6CgjSaT2ieObmiAMXt5iVdS9lF9mXX+0zfMiwdAA76EjN98KO\nqtQTHRhj0Skvt3udzZENLDYm/RcQzrJDDDv+ga2pfWd+eNHbXPfA8sAmfr9I\ntX6XewVwBy3eLsxiF9nABoDeaZXXQgsQXUbSjb1pj95G2v13UiJ763nh2OB8\n5m0lVVKXNga2sIn34AOLElkoCQ/lP+4Zrn0mKIqCw3W0cUyjSMAMH8S9Q/xs\nW+El4OyQhwmHwOMy+A0P7o0eXGIUAix9hNf3NUJlqoX4cuwg+FVdn1/2MNOJ\n5mD1\r\n=FIhe\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDx9izFB+8+35VVfmIWMS2jIJeGWuTXRndsLOI9loHg5AIgQyD1ltp1CFm9dcbRgrbh3cMLXrnENirjIc44klvhX5M="}],"size":74447,"noattachment":false,"key":"/camaro/-/camaro-5.0.1-alpha.0.tgz"},"maintainers":[{"name":"tuananh","email":"me@tuananh.org"}],"_npmUser":{"name":"tuananh","email":"me@tuananh.org"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/camaro_5.0.1-alpha.0_1588665396095_0.8856123371762421"},"_hasShrinkwrap":false,"publish_time":1588665396213,"_cnpm_publish_time":1588665396213,"dist-tags":{"latest":"6.7.3","legacy-v3":"3.0.20","next":"6.5.0-rc4","oldv3":"3.0.19"}}