{"_id":"@aux4/facilitator","name":"@aux4/facilitator","dist-tags":{"latest":"2.0.0"},"versions":{"2.0.0":{"name":"@aux4/facilitator","version":"2.0.0","type":"module","description":"Natural language as a programming language","main":"index.js","scripts":{"test":"node --experimental-vm-modules ./node_modules/.bin/jest --coverage"},"preferGlobal":"true","bin":{"facilitator":"bin/executable.js"},"repository":{"type":"git","url":"git+https://github.com/aux4/facilitator.git"},"keywords":["test","automation","story","behavior"],"author":{"name":"aux4"},"license":"Apache-2.0","bugs":{"url":"https://github.com/aux4/facilitator/issues"},"devDependencies":{"jest":"^29.7.0"},"_id":"@aux4/facilitator@2.0.0","gitHead":"a6b1643a529a02042759098d68655e4fe59f1a05","homepage":"https://github.com/aux4/facilitator#readme","_nodeVersion":"20.10.0","_npmVersion":"10.8.3","dist":{"integrity":"sha512-H2S9zc/kTsAUb8MTWlxPXFmihKx/qsVFS1/bvNqDtWWgSBZ32UwyXNnngMU3dCKL3RFg3Ieqbd9vkome2pOOAg==","shasum":"8a7dc06a833d6067ebb7e0060db8eb32fd47a67f","tarball":"https://registry.npmjs.org/@aux4/facilitator/-/facilitator-2.0.0.tgz","fileCount":8,"unpackedSize":28243,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGE+nAV6MbOu8+OEPBneuWbSUCk4s49DIvReR6kLDyjMAiBn6yHTqEMzbCnwU3d4wfyQOy88L1AhN0R3HGPd1yUFDA=="}]},"_npmUser":{"name":"aux4-dev","email":"contact@aux4.io"},"directories":{},"maintainers":[{"name":"aux4-dev","email":"contact@aux4.io"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/facilitator_2.0.0_1730359456556_0.26453982789424013"},"_hasShrinkwrap":false}},"time":{"created":"2024-10-31T07:24:16.412Z","2.0.0":"2024-10-31T07:24:16.753Z","modified":"2024-10-31T07:24:17.020Z"},"maintainers":[{"name":"aux4-dev","email":"contact@aux4.io"}],"description":"Natural language as a programming language","homepage":"https://github.com/aux4/facilitator#readme","keywords":["test","automation","story","behavior"],"repository":{"type":"git","url":"git+https://github.com/aux4/facilitator.git"},"author":{"name":"aux4"},"bugs":{"url":"https://github.com/aux4/facilitator/issues"},"license":"Apache-2.0","readme":"# 💬 facilitator\n\nNatural language as a programming language\n\n## Installation\n\n```bash\nnpm install --global facilitator\n```\n\n## Usage\n\n### Command-line\n\ntest.txt\n\n```txt\nset \"firstName\" to \"John\"\nset \"lastName\" to \"Doe\"\nprint \"Hello {{firstName}} {{lastName}}\"\n```\n\n```bash\nfacilitator execute test.txt\n```\n\n[See all commands](wiki/all-commands.md)\n\n### Node.js\n\n#### Create custom expression\n\n```js\nimport Facilitator, { install } from \"facilitator\";\n\nconst facilitator = new Facilitator();\ninstall(facilitator);\n\nfacilitator.register(\"say hello to {firstName} {lastName}\", (firstName, lastName) => {\n  console.log(`Hello ${firstName} ${lastName}!`);\n});\n\nconst script = `\nsay hello to \"John\" \"Doe\"\n`;\n\nfacilitator.exec(script, { currentDate: new Date() });\n```\n\nOutput:\n\n```\nHello John Doe\n```\n\n#### Use optional variable with custom regex\n\nTo make the variable optional you can include the `?` as suffix of the variable. e.g.: `{count?}`\n\nBy default the variables are represented by quoted text (e.g.: `\"value\"`), you can redefine the variable,\nthe third parameter of register receives an object with the regular expression to represent the variable:\n\n```js\n{\n  count: /\\d+/\n}\n```\n\n```js\nimport Facilitator, { install } from \"facilitator\";\n\nconst facilitator = new Facilitator();\ninstall(facilitator);\n\nfacilitator.register(\"increment\\\\s*{count?}\", (count, context) => {\n  let value = context.count || parseInt(count);\n  value += 1;\n  context.count = value;\n  console.log(\"increment\", value);\n}, {\n  count: /\\d+/\n});\n\nconst script = `\nincrement 5\nincrement\nincrement\nincrement\nincrement\n`;\n\nfacilitator.exec(script, {});\n```\n\nOutput:\n\n```\nincrement 6\nincrement 7\nincrement 8\nincrement 9\nincrement 10\n```\n","readmeFilename":"README.md"}