{"_id":"@alexghr/stats","_rev":"2-28029ccf0f89cad8f2bfb480061931eb","name":"@alexghr/stats","dist-tags":{"latest":"0.1.1"},"versions":{"0.1.0":{"name":"@alexghr/stats","main":"./dist","license":"MIT","dependencies":{"tslib":"^1.9.3"},"scripts":{"clean":"rm -rf dist","prepublish":"tsc --build","test":"jest"},"devDependencies":{"@types/jest":"^23.3.12","@types/node":"^10.12.18","jest":"^23.6.0","ts-jest":"^23.10.5","typescript":"^3.2.2"},"version":"0.1.0","description":"Track your functions in style!","licenseText":"MIT License\n\nCopyright (c) 2019 Alex Gherghisan\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.","_id":"@alexghr/stats@0.1.0","dist":{"shasum":"c570d1d7ad7625712e22a52b702eee0213754a0e","integrity":"sha512-QsWwf9xW9E1+U9ueuW/fQ6oEnwrVrRJufyP2idP36E3JNqmhi1sLXcKPShdAV1p4OEaDYF7wlYZcDKRk8jvipA==","tarball":"https://registry.npmjs.org/@alexghr/stats/-/stats-0.1.0.tgz","fileCount":17,"unpackedSize":9738,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcQ24pCRA9TVsSAnZWagAAi/oP+gNgW+8GX3q0PGOga7Ak\nSXf0WpFH/lIgoO3xumH5efSla4LP5tf/1+G7iIBopOFTp7oiNDLHfFkEpXdj\n0KDWz9A3XXYX6pku/QIAqe5wZ9JSBdS1Sfei7FttbvPrdVHpoLYzhf/Ha1p5\ni7l1QOqtbe1EEki3D3Sp5KwE3n6Ky8RD1L19lkN2Yh476iNOPN6ab+iwlmKs\nxOVDGFLsk1PNjY3YuS0v26g3fVwYIdzMgf+AwMp2unYT3besqUpC0DiXxJUV\nV2nFLPmWvxFBQ6uWuC6vtsjkUCy6o+s9OsCAVsndDTVlYWqlFEf7+jOruZYh\nsZp6ZLiG5gGMjp6FQ8vKmeETivjqHkEmCXBN+kiby0lVn7vrJ7OQ8xRDc845\ncKKcplN7rMOiTSvs/nlWMCAjrjpKaj4jLDHbwKF64vgdibO55pZ915Hci6+w\nkGbhYqFovn/BdKiBVYiRqmateID4npfrO7Y0xNsm1EwTI+8pgRnEnJwB1Lqj\n8iQHwpF792TnrNcZC4WpkPazUlq1UtToLLCtNAXrfbIYs8CNILdyACC0zy86\nS2iawQgAZdry6tl4ADOnok9uKOGLrz/ItPCdyi52KdE7CVIYg4DeXF/hWABl\nT/S97LkFHMzJF3IxUgyLCKQJCatuJWbhS6IoPIhSwwyJ1XyreERwo2kca+G9\nKZXT\r\n=Hw5Q\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCxMKsguKqG+b9v81BoChSMGnd9K7BLUL3lEZEok/anZAIhALz+f03GMOeBNn3eJ75eH3f7yBDRcvV/TmNSFeCVqgUa"}]},"maintainers":[{"name":"alexghr","email":"alex@alexghr.me"}],"_npmUser":{"name":"alexghr","email":"alex@alexghr.me"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/stats_0.1.0_1547922984525_0.3794807942463021"},"_hasShrinkwrap":false},"0.1.1":{"name":"@alexghr/stats","version":"0.1.1","main":"./dist","types":"./dist","license":"MIT","homepage":"https://github.com/alexghr/node-stats","scripts":{"clean":"rm -rf dist","prepublish":"tsc --build","test":"jest"},"dependencies":{"tslib":"^1.9.3"},"devDependencies":{"@types/jest":"^23.3.12","@types/node":"^10.12.18","jest":"^23.6.0","ts-jest":"^23.10.5","typescript":"^3.2.2"},"author":{"name":"Alex Gherghisan","email":"alexghr@users.noreply.github.com","url":"https://www.alexghr.me"},"repository":{"type":"git","url":"https://github.com/alexghr/node-stats.git"},"bugs":{"url":"https://github.com/alexghr/node-stats/issues"},"description":"Track your functions in style!","licenseText":"MIT License\n\nCopyright (c) 2019 Alex Gherghisan\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.","_id":"@alexghr/stats@0.1.1","dist":{"shasum":"136291814287ecce99e8dc367d5184c9d9ca84ea","integrity":"sha512-YhcZHbLpnXS7726QoMnqRWZlLADi70vgp6O/YzIvVzg64rP1+drQHAng64v9fNPdEhsotpHIttXmomTTViRO8A==","tarball":"https://registry.npmjs.org/@alexghr/stats/-/stats-0.1.1.tgz","fileCount":17,"unpackedSize":10121,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcREdSCRA9TVsSAnZWagAA7awP/RBOA5Act1nl8nw+E4KP\nrbSVhvJejKD65YSbRwWd5wnCnivqeERxAMUbdTjSwTrExXR3Rq8kslJhEJ/j\nOWXVanQv80pBflX3rDQTzYBJYqjLEOb3PyQyxkqSKBb4fOFqbUwSX37LX1By\nhNzU1qcLw/eZvWAIaUmegjctQZxyqdTNskja4gTZhED+CNs8mtwItPPMth6p\neUXwKnCEOn4eQytKelLfJT/TTuFaZq98BqphnbfsuZ7IXBPOt+j6EZrVrThU\nqOSkUFb5bWYKls+pvKwVC/LjZvJSmyIPHFVe8A1b49idUXG9HBrvrPUeioUH\nZCeOCFEy0BJJijxMMZLBetyt3EYWrm2Nx6P6jsRhgplQiPNbveXtpxb/cwgL\nK4oDp8R46OOSF8FlE3vbJ9hol70m/XR0EX61Gg3+0ThHxLMKZbCeAqAiHhVj\nbMVgZ5EGmFdwhhbm0PcM+B4hgtzZrdOLG76WUXW3EP3ThUwmOjy8wOhkt+xq\nS/bbJwKVZCBNjoL8DHw3koOsK9DLphM+JD/BgfODv6m12QjHCaRgCB4FUjwg\n+kRkGq2ayqZzIcKIusSaKWqewdcdmtgvnrX9SI8wAoJotL+Q8MOf9CHhaWYl\nWsuxehctMWAJtnTFA0h/GqduJy8cEoei/H6uI7/n1W4WfH8geut5OlD/n87T\nvc3k\r\n=7Xy6\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCRJ7EUjI7z2/RNGG0pKOJCtUdFm4mmBt2/Ae3Y7HIPwgIgJ1dktebCVljN+3E7ABHyIcARKPLgIhbrdP9k5xfhQ24="}]},"maintainers":[{"name":"alexghr","email":"alex@alexghr.me"}],"_npmUser":{"name":"alexghr","email":"alex@alexghr.me"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/stats_0.1.1_1547978578272_0.9348720305421228"},"_hasShrinkwrap":false}},"time":{"created":"2019-01-19T18:36:24.339Z","0.1.0":"2019-01-19T18:36:24.602Z","modified":"2022-04-04T12:40:06.254Z","0.1.1":"2019-01-20T10:02:58.366Z"},"maintainers":[{"name":"alexghr","email":"alex@alexghr.me"}],"description":"Track your functions in style!","license":"MIT","readme":"# stats\n\nTrack your functions in style!\n\n## Example\n\n```js\nconst { createStatsTracker } = require('@alexghr/stats');\nconst { trackStats, stats } = createStatsTracker();\n\n// Setup stats collection\nstats.on('call', (name) => console.log(`${name} was called`));\nstats.on('call_resolved', (name, time) => console.log(`${name} took ${time}ms to run`));\nstats.on('call_rejected', (name, time) => console.log(`Oh no! ${name} crashed after ${time}ms`));\n\nclass AwesomeService {\n  doWork() {\n    return new Promise((resolve, reject) => {\n      console.log('working on something important....');\n      setTimeout(() => resolve(42), 1000);\n    });\n  }\n}\n\n// this an example of tracking all of the functions on an object\n// but it works in the same way when `target` is just a function\nconst service = trackStats({ target: new AwesomeService(), name: 'awesome_service' });\nservice.doWork().then((result) => console.log(`result is: ${result}`));\n\n// Prints:\n// working on something important....\n// awesome_service.doWork was called\n// result is: 42\n// awesome_service.doWork took 1003.0209ms to run\n```\n\nYou can easily connect it to metrics-collecting services. Here's an example using it with `node-statsd`:\n\n```js\nconst { createStatsTracker } = require('@alexghr/stats');\n// push stats into a StatsD server\nconst StatsD = require('node-statsd');\n\nconst statsd = new StatsD({\n  host: 'localhost',\n  port: 8125,\n  prefix: 'example.'\n});\n\nconst { trackStats, stats } = createStatsTracker();\n\nstats.on('call', (name) => statsd.increment(name));\nstats.on('call_resolved', (name, time) => statsd.timing(name, time));\nstats.on('call_rejected', (name, time) => {\n  statsd.increment(`${name}.error`);\n  statsd.timing(`${name}.error`, time);\n});\n```","readmeFilename":"README.md","homepage":"https://github.com/alexghr/node-stats","repository":{"type":"git","url":"https://github.com/alexghr/node-stats.git"},"author":{"name":"Alex Gherghisan","email":"alexghr@users.noreply.github.com","url":"https://www.alexghr.me"},"bugs":{"url":"https://github.com/alexghr/node-stats/issues"}}