{"_id":"@brillout/wildcard-intercept","_rev":"1-e38f90cd68334da8ec71b9a04bc9f216","name":"@brillout/wildcard-intercept","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@brillout/wildcard-intercept","version":"0.1.0","main":"index.js","peerDependencies":{"@wildcard-api/server":"^0.2.10"},"dependencies":{"@brillout/assert":"^0.1.1"},"scripts":{"docs":"mdocs"},"devDependencies":{"@brillout/mdocs":"^0.1.30","@wildcard-api/client":"^0.2.10","@wildcard-api/server":"^0.2.10","express":"^4.17.1"},"publishConfig":{"access":"public"},"gitHead":"6bbbd38d5f94f9d55e53e30ac411e26e0339c6c8","description":"<!---","_id":"@brillout/wildcard-intercept@0.1.0","_nodeVersion":"12.2.0","_npmVersion":"6.9.0","dist":{"integrity":"sha512-UdYEqR86JJpT44lx65WOZYry4JgrLKQF62XvdRhOQnGmaFz0kB3xsCb9f4sQeabtAa76/zCwnv3fH/PAWgC98g==","shasum":"31dab1929686afdd053ab2afd188ac67d02c6a0f","tarball":"https://registry.npmjs.org/@brillout/wildcard-intercept/-/wildcard-intercept-0.1.0.tgz","fileCount":7,"unpackedSize":7626,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJebLv8CRA9TVsSAnZWagAAvLgP/i6sB5lnZxa6fWa8+SKM\nRx7gmmWRDU8ee8FSdeGCXvYlHuL/8EgkGLKeu13x/kgjEH9JvuyXPRm0uQt4\nul/f1yxg14m6uuCzLJZ5XSVbB4O/FrGZVapNVhtBjQ7L4WkGSenqHogb+z/L\n+u0YonwBE0dzX8wk3uKTn3ZmlhhTq9oFWCeq1clU7b3hj+WDkyd8JhlecSnr\nH7KqucIU1SHZPOAhVccdlDrypS+LL3mlfuQnRXvb6chIoaK4ErSMm+YPt9Qx\nT4O6Sv6P7Sexb69LA5+exWZdNR3QAfWWMeq5RyX8LQHLYYpGYfihYpGwoLpG\neb66mp0V4ZA4B86sZyt+S5l8bXwgFpL6YkLXbWTVhBu99zC+llNtCXm+K55o\nvdkHJFxMmvvMt7B7K0sKOFf1KGKXpCMWdTs1MZsXG9X/6vzJ8okgQY3vQIgH\nHEWoDGnsc1d6YZ4Pf1UY0ClOVZLxD64mQYPkin+udBrO6r6bBOvx1n1aM6pJ\nr9aZ0xstBZgG0twgl0e4B2E1U/Wx0H9F18areWZn2YAt/0zjEQc1Dc7CFV1y\n2D66pI8VJv6g+sUp3WYbc/R2P+48c9lAO9cfdJsyERZyIuqzpy/1K8LYSjEb\niPfF4NDG9uC2OsoMT/AeGGIvUWfiaP4oZwATEcKbVhmnvf+WY1THfREPwrSt\nPjUv\r\n=JCTJ\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCVhSPqUqg19pF0Xw9HcPChfpYTVaYx8i8RvK37d0VU1QIhALYl9QxXAo/VsrDrJ2VgJf1kg0momg1TRZhBQokDUU+j"}]},"maintainers":[{"name":"brillout","email":"npm@brillout.com"}],"_npmUser":{"name":"brillout","email":"npm@brillout.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/wildcard-intercept_0.1.0_1584184316482_0.7633398408493004"},"_hasShrinkwrap":false}},"time":{"created":"2020-03-14T11:11:56.256Z","0.1.0":"2020-03-14T11:11:56.643Z","modified":"2022-04-04T20:41:38.410Z"},"maintainers":[{"name":"brillout","email":"npm@brillout.com"}],"description":"<!---","readme":"<!---\n\n\n\n\n\n\n    WARNING, READ THIS.\n    This is a computed file. Do not edit.\n    Instead, edit `/readme.template.md` and run `npm run docs` (or `yarn docs`).\n\n\n\n\n\n\n\n\n\n\n\n\n    WARNING, READ THIS.\n    This is a computed file. Do not edit.\n    Instead, edit `/readme.template.md` and run `npm run docs` (or `yarn docs`).\n\n\n\n\n\n\n\n\n\n\n\n\n    WARNING, READ THIS.\n    This is a computed file. Do not edit.\n    Instead, edit `/readme.template.md` and run `npm run docs` (or `yarn docs`).\n\n\n\n\n\n\n\n\n\n\n\n\n    WARNING, READ THIS.\n    This is a computed file. Do not edit.\n    Instead, edit `/readme.template.md` and run `npm run docs` (or `yarn docs`).\n\n\n\n\n\n\n\n\n\n\n\n\n    WARNING, READ THIS.\n    This is a computed file. Do not edit.\n    Instead, edit `/readme.template.md` and run `npm run docs` (or `yarn docs`).\n\n\n\n\n\n\n-->\n# Wildcard Intercept\n\nLibrary for [Wildcard API](https://github.com/reframejs/wildcard-api) to intercept calls.\n\n~~~js\n// ./example/endpoints.js\n\nconst {endpoints} = require('@wildcard-api/server');\nconst intercept = require('@brillout/wildcard-intercept'); // npm install @brillout/wildcard-intercept\n\nendpoints.hello = intercept(function(name) {\n  return 'Hi '+name+'!';\n}, myListener);\n\nendpoints.mirror = intercept(function(msg) {\n  return msg.split('').reverse().join('');\n}, myListener);\n\nfunction myListener({endpointName, endpointArgs, endpointResult, endpointError, context}) {\n  console.log({endpointName, endpointArgs, endpointResult, endpointError, context});\n}\n~~~\n~~~js\n// ./example/client.js\n\nconst {endpoints} = require('@wildcard-api/client');\nconst wildcard = require('@wildcard-api/client');\n\nwildcard.serverUrl = 'http://localhost:3000';\n\n(async function() {\n  let greeting = await endpoints.hello('Johnson');\n  console.log(greeting);\n  greeting = await endpoints.mirror(greeting);\n  console.log(greeting);\n})();\n~~~\nClient `console.log` result:\n~~~shell\nHi Johnson!\n!nosnhoJ iH\n~~~\nServer `console.log` result:\n~~~js\n{\n  endpointName: 'hello',\n  endpointArgs: [ 'Johnson' ],\n  endpointResult: 'Hi Johnson!',\n  endpointError: undefined,\n  context: {\n    headers: {\n      'content-type': 'application/json',\n      'accept-encoding': 'gzip,deflate',\n      'user-agent': 'node-fetch/1.0 (+https://github.com/bitinn/node-fetch)',\n      connection: 'close',\n      accept: '*/*',\n      'content-length': '0',\n      host: 'localhost:3000'\n    }\n  }\n}\n{\n  endpointName: 'mirror',\n  endpointArgs: [ 'Hi Johnson!' ],\n  endpointResult: '!nosnhoJ iH',\n  endpointError: undefined,\n  context: {\n    headers: {\n      'content-type': 'application/json',\n      'accept-encoding': 'gzip,deflate',\n      'user-agent': 'node-fetch/1.0 (+https://github.com/bitinn/node-fetch)',\n      connection: 'close',\n      accept: '*/*',\n      'content-length': '0',\n      host: 'localhost:3000'\n    }\n  }\n}\n~~~\n\nThe [source code of `@brillout/wildcard-intercept`](/index.js) is only 42 LOC; you may want to implement your own interceptor!\n\n<!---\n\n\n\n\n\n\n    WARNING, READ THIS.\n    This is a computed file. Do not edit.\n    Instead, edit `/readme.template.md` and run `npm run docs` (or `yarn docs`).\n\n\n\n\n\n\n\n\n\n\n\n\n    WARNING, READ THIS.\n    This is a computed file. Do not edit.\n    Instead, edit `/readme.template.md` and run `npm run docs` (or `yarn docs`).\n\n\n\n\n\n\n\n\n\n\n\n\n    WARNING, READ THIS.\n    This is a computed file. Do not edit.\n    Instead, edit `/readme.template.md` and run `npm run docs` (or `yarn docs`).\n\n\n\n\n\n\n\n\n\n\n\n\n    WARNING, READ THIS.\n    This is a computed file. Do not edit.\n    Instead, edit `/readme.template.md` and run `npm run docs` (or `yarn docs`).\n\n\n\n\n\n\n\n\n\n\n\n\n    WARNING, READ THIS.\n    This is a computed file. Do not edit.\n    Instead, edit `/readme.template.md` and run `npm run docs` (or `yarn docs`).\n\n\n\n\n\n\n-->\n","readmeFilename":"readme.md"}