{"_id":"@crown-channel/ioredis-mock","_rev":"2-a4216d4c278b564e3ddc7c7ff2c5eebb","name":"@crown-channel/ioredis-mock","dist-tags":{"latest":"5.6.2"},"versions":{"5.6.1":{"name":"@crown-channel/ioredis-mock","description":"This library emulates ioredis by performing all operations in-memory.","version":"5.6.1","license":"MIT","author":{"name":"Griffin Hammer","email":"grhammer@amazon.com"},"homepage":"https://github.com/Twitch-Prime-Live/ioredis-mock#readme","repository":{"type":"git","url":"git+https://github.com/Twitch-Prime-Live/ioredis-mock.git"},"bugs":{"url":"https://github.com/Twitch-Prime-Live/ioredis-mock/issues"},"main":"./lib","scripts":{"build:babel":"npx rimraf lib && npx mkdirp lib && babel src --out-dir lib","build:jest.js":"esbuild src/index.js --bundle --external:fengari --external:fengari-interop --external:lodash --external:minimatch --external:standard-as-callback --outfile=jest.js --platform=node --target=node10","codeclimate":"codeclimate-test-reporter < ./coverage/lcov.info","precoverage":"npx rimraf coverage && npx mkdirp coverage","coverage":"npm test -- --coverage","coveralls":"cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js","lint":"eslint .","prepublishOnly":"npm run build:babel && npm run build:jest.js","semantic-release":"semantic-release pre && npm publish && semantic-release post","test":"jest","test:jest.js":"jest --config jest.config.jest.js","test:e2e":"jest --config jest.config.redis.js","update-compat":"node scripts/update-compat && git add compat.md README.md && git commit --quiet -m \"docs: Update feature compat table\" &> /dev/null || true"},"dependencies":{"crypto":"^1.0.1","fengari":"^0.1.4","fengari-interop":"^0.1.2","lodash":"^4.17.21","standard-as-callback":"^2.1.0"},"peerDependencies":{"ioredis":"4.x","redis-commands":"1.x"},"devDependencies":{"@babel/cli":"^7.13.14","@babel/core":"^7.13.15","@babel/preset-env":"^7.13.15","@babel/register":"^7.13.14","babel-eslint":"^10.1.0","bluebird":"^3.7.2","chance":"^1.1.7","codeclimate-test-reporter":"^0.5.1","coveralls":"^3.1.0","esbuild":"^0.11.12","eslint":"^7.24.0","eslint-config-airbnb-base":"^14.2.1","eslint-config-prettier":"^8.2.0","eslint-plugin-import":"^2.22.1","eslint-plugin-jest":"^24.3.5","husky":"^6.0.0","ioredis":"^4.19.2","jest":"^26.6.3","jest-circus":"^26.6.3","lint-staged":"^11.0.0","prettier":"^2.2.1","prettier-package-json":"^2.1.3","redis-commands":"^1.7.0","stream-mock":"^2.0.5"},"keywords":["fakeredis","in-memory","ioredis","ioredis-mock","mock-ioredis","mock-redis","redis","redis fake","redis inmemory","redis js","redis memory","redis mock","redis standalone","redis test","redis testing","redis-js","redis-mock","redisjs"],"engines":{"node":">=10"},"husky":{"hooks":{"pre-commit":"lint-staged"}},"lint-staged":{"*.js":["eslint --fix","prettier --write","git add"],"*.json":["prettier --write","git add"],"*.md":["prettier --write","git add"],"package.json":["prettier-package-json --write","git add"]},"prettier":{"singleQuote":true,"trailingComma":"es5"},"release":{"prepare":["@semantic-release/npm"]},"runkitExampleFilename":"example.js","gitHead":"92e17cdc81368df1c23a762f85f849c2520101ce","_id":"@crown-channel/ioredis-mock@5.6.1","_nodeVersion":"16.6.1","_npmVersion":"7.20.3","dist":{"integrity":"sha512-0UBiDuDgnJGZDOkg729cFTYYCXTWl92VEnU8CKzggZ+OQFvdU3Jlp8R5YO2rxeSe3GX5XxUSa1xNFPuRBJnErw==","shasum":"8bce396903fb5f98d8ed1f870a6df0cad07e7e33","tarball":"https://registry.npmjs.org/@crown-channel/ioredis-mock/-/ioredis-mock-5.6.1.tgz","fileCount":161,"unpackedSize":505782,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhDFNPCRA9TVsSAnZWagAArsQP+gMoAOM1gbLpNQDIBO5u\nKGuvpeMZ9Njg/5PJIa8DFxuphuT+CPCm4WrJrchQj80Dr9mHToBwOSABvYuZ\nq+eMZtsvXAM4lZ6EJkihzjGwK1p92BbvaNI5wX4uHHr8Wx7I/CjHMEpwKTkG\n6uHxpB2jprJX7S/Sr9LYOIkjzlVn/JrResbiH7cSMLVJxv+c8jI3RjcXwgqA\nsQBcIQG94GOTA1z19TibButfo281IXxnWbZUxS4sa24awq3jxFNe/CUSSQI9\nZNhd7HwcotPpzjpf7uZuOnY63duEWAOeJbLTz8AylKqOjhMDOVJgI6hkp78b\n3ddN77d0w7WviQE4FNfjJgvpfREvSOr37tWvrqhU3ddeICLc0VapIa/qGEG1\n5sQrdRVUrJLXWPNJPSl34jysfhd7p5YKSj/dxbJKc8N4LdwuhLVOTqUdvcWJ\nG1lzWHu4XO7sadUzX29k1QN2XjUM5G6HkoszZ8pPDpvnOXEoDzPLUGNDh8gM\nMzuN5gZm0jbyvjpePBsMLPCCNV/HThFprGOZH2xkgr7bfiYso+t3kz6JaPZy\nw6GJNcw6UBK6WnkmNwaBq4GVkbGyK4S5Z3JrQiMeQendQf3NVzYVD40GYi+S\n2EDrKSNpMeeu0HsiS2DnhkgBSjQZWTDcl+Vt32Lqq3DqbNnMU5xbjdVCodSC\n88o4\r\n=f3cW\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICMTfJbEwVuSlRKi8ZdkEYMjfwF0QXuYeRc6UDqT0G5tAiAVQkH/qN7Lf5Cszikw79e9AY49lBMvF1lGKXpYP6iEXA=="}]},"_npmUser":{"name":"grhammer","email":"grhammer@amazon.com"},"directories":{},"maintainers":[{"name":"grhammer","email":"grhammer@amazon.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ioredis-mock_5.6.1_1628197711010_0.1802800767276067"},"_hasShrinkwrap":false},"5.6.2":{"name":"@crown-channel/ioredis-mock","description":"This library emulates ioredis by performing all operations in-memory.","version":"5.6.2","license":"MIT","author":{"name":"Griffin Hammer","email":"grhammer@amazon.com"},"homepage":"https://github.com/Twitch-Prime-Live/ioredis-mock#readme","repository":{"type":"git","url":"git+https://github.com/Twitch-Prime-Live/ioredis-mock.git"},"bugs":{"url":"https://github.com/Twitch-Prime-Live/ioredis-mock/issues"},"main":"./lib","scripts":{"build:babel":"npx rimraf lib && npx mkdirp lib && babel src --out-dir lib","build:jest.js":"esbuild src/index.js --bundle --external:fengari --external:fengari-interop --external:lodash --external:minimatch --external:standard-as-callback --outfile=jest.js --platform=node --target=node10","codeclimate":"codeclimate-test-reporter < ./coverage/lcov.info","precoverage":"npx rimraf coverage && npx mkdirp coverage","coverage":"npm test -- --coverage","coveralls":"cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js","lint":"eslint .","prepublishOnly":"npm run build:babel && npm run build:jest.js","semantic-release":"semantic-release pre && npm publish && semantic-release post","test":"jest","test:jest.js":"jest --config jest.config.jest.js","test:e2e":"jest --config jest.config.redis.js","update-compat":"node scripts/update-compat && git add compat.md README.md && git commit --quiet -m \"docs: Update feature compat table\" &> /dev/null || true"},"dependencies":{"crypto":"^1.0.1","fengari":"^0.1.4","fengari-interop":"^0.1.2","lodash":"^4.17.21","standard-as-callback":"^2.1.0"},"peerDependencies":{"ioredis":"4.x","redis-commands":"1.x"},"devDependencies":{"@babel/cli":"^7.13.14","@babel/core":"^7.13.15","@babel/preset-env":"^7.13.15","@babel/register":"^7.13.14","babel-eslint":"^10.1.0","bluebird":"^3.7.2","chance":"^1.1.7","codeclimate-test-reporter":"^0.5.1","coveralls":"^3.1.0","esbuild":"^0.11.12","eslint":"^7.24.0","eslint-config-airbnb-base":"^14.2.1","eslint-config-prettier":"^8.2.0","eslint-plugin-import":"^2.22.1","eslint-plugin-jest":"^24.3.5","husky":"^6.0.0","ioredis":"^4.19.2","jest":"^26.6.3","jest-circus":"^26.6.3","lint-staged":"^11.0.0","prettier":"^2.2.1","prettier-package-json":"^2.1.3","redis-commands":"^1.7.0","stream-mock":"^2.0.5"},"keywords":["fakeredis","in-memory","ioredis","ioredis-mock","mock-ioredis","mock-redis","redis","redis fake","redis inmemory","redis js","redis memory","redis mock","redis standalone","redis test","redis testing","redis-js","redis-mock","redisjs"],"engines":{"node":">=10"},"husky":{"hooks":{"pre-commit":"lint-staged"}},"lint-staged":{"*.js":["eslint --fix","prettier --write","git add"],"*.json":["prettier --write","git add"],"*.md":["prettier --write","git add"],"package.json":["prettier-package-json --write","git add"]},"prettier":{"singleQuote":true,"trailingComma":"es5"},"release":{"prepare":["@semantic-release/npm"]},"runkitExampleFilename":"example.js","gitHead":"92e17cdc81368df1c23a762f85f849c2520101ce","_id":"@crown-channel/ioredis-mock@5.6.2","_nodeVersion":"16.6.1","_npmVersion":"7.20.3","dist":{"integrity":"sha512-x54gNOtwP49F70SAa5DCZMSX6leSYYpivkq5pV3QudYj0v4o85xLsUp48lQLE7/liqek9snYwADViFgvX2GMbQ==","shasum":"fb222c5fc3dbb4c663c9285f01fac1311a51f474","tarball":"https://registry.npmjs.org/@crown-channel/ioredis-mock/-/ioredis-mock-5.6.2.tgz","fileCount":161,"unpackedSize":505782,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhDFncCRA9TVsSAnZWagAA7icP/jlGmkQKpP9kYWLiK7kA\nXgWEjFJ/xkdqzVLSWASwgHP6UMxjZHgAEIdWvdMnlvcr4d4SC2n4C1NB0/yV\njxYwJMdYycPsb4nUAUfksPe/qViiGUgKVfMGS3+jn225IgGjM7ErSU0k2qzs\nMGE4pnaoQJT6ZB2RxJDW+Q8kqcs7kjFG+tqbM15vp0pht50u9a3LBqpgzpbq\nCPR5OocIVgjRAmG3CKnFc9IiMmnMwgbnFkGZf28uQTxsYF8anXdDdDsPTn6V\n2Z/hagbmVi6rqbrcJ6wCLyEoPIl5M28WaPvU5w1IeTDbVDfmSO7pRyLBGURW\n2kBnghjufwb3vRM9RtEpnssxWnEaQN1RfYS0Tgo5Gg8FaJG3fQTVe96y1Slm\nyYe2LDxVf8zqohqbAT059cjJf1W51LOVZbOVLRIuNDkQ2J5B+DpOCvkYGAm6\naK+0SnYNcGghavLSB4mHZm0ZwqpuqatUdtm6xj3hNtfR7/KDD5NoROEYukpo\n5pFTGdligfdGYJB+11RC3Dn+6zYiIxSzkO0mMnBboA3xavrNuvOqj1Cd0TWi\nUkIPQOdtMhLQXfCuOGxoJ2PCVCuQO9KiSHC38jHaIbO25TY810aa5DL7IjgO\nr81Gr84Ou341h4odhMOUkCp7TS2VkMjEPXoNeO+e3Ol4nDUKwolaNj9yqzAj\nd5Oa\r\n=wCbA\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDU2xQnNqPRKk9LEc9HM2rBiuUjPZ0PUSyIUzun5D8lsQIhAJgW4zwIS1kvDz1QI8nizALDh7hnWfWa9uDE/5Hd/eNr"}]},"_npmUser":{"name":"grhammer","email":"grhammer@amazon.com"},"directories":{},"maintainers":[{"name":"grhammer","email":"grhammer@amazon.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ioredis-mock_5.6.2_1628199388706_0.3424538855784498"},"_hasShrinkwrap":false}},"time":{"created":"2021-08-05T21:08:30.910Z","5.6.1":"2021-08-05T21:08:31.136Z","modified":"2022-04-05T01:56:24.640Z","5.6.2":"2021-08-05T21:36:28.925Z"},"maintainers":[{"name":"grhammer","email":"grhammer@amazon.com"}],"description":"This library emulates ioredis by performing all operations in-memory.","homepage":"https://github.com/Twitch-Prime-Live/ioredis-mock#readme","keywords":["fakeredis","in-memory","ioredis","ioredis-mock","mock-ioredis","mock-redis","redis","redis fake","redis inmemory","redis js","redis memory","redis mock","redis standalone","redis test","redis testing","redis-js","redis-mock","redisjs"],"repository":{"type":"git","url":"git+https://github.com/Twitch-Prime-Live/ioredis-mock.git"},"author":{"name":"Griffin Hammer","email":"grhammer@amazon.com"},"bugs":{"url":"https://github.com/Twitch-Prime-Live/ioredis-mock/issues"},"license":"MIT","readme":"# ioredis-mock &middot; [![npm](https://img.shields.io/npm/dm/ioredis-mock.svg?style=flat-square)](https://npm-stat.com/charts.html?package=ioredis-mock) [![npm version](https://img.shields.io/npm/v/ioredis-mock.svg?style=flat-square)](https://www.npmjs.com/package/ioredis-mock) [![Redis Compatibility: 29%](https://img.shields.io/badge/redis-29%25-orange.svg?style=flat-square)](compat.md) [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square)](https://github.com/semantic-release/semantic-release)\n\nThis library emulates [ioredis](https://github.com/luin/ioredis) by performing\nall operations in-memory. The best way to do integration testing against redis\nand ioredis is on a real redis-server instance. However, there are cases where\nmocking the redis-server is a better option.\n\nCases like:\n\n- Your workflow already use a local redis-server instance for the dev server.\n- You're on a platform\n  [without an official redis release](https://github.com/MSOpenTech/redis),\n  that's even worse than using an emulator.\n- You're running tests on a CI, setting it up is complicated. If you combine it\n  with CI that also run selenium acceptance testing it's even more complicated,\n  as two redis-server instances on the same CI build is hard.\n- The GitHub repo have bots that run the testing suite and is limited through\n  npm package.json install scripts and can't fire up servers. (Having\n  [Greenkeeper](https://greenkeeper.io/) notifying you when a new release of\n  ioredis is out and wether your code breaks or not is awesome).\n\nCheck the [compatibility table](compat.md) for supported redis commands.\n\n## Usage ([try it in your browser](https://runkit.com/npm/ioredis-mock))\n\n```js\nvar Redis = require('ioredis-mock');\nvar redis = new Redis({\n  // `options.data` does not exist in `ioredis`, only `ioredis-mock`\n  data: {\n    user_next: '3',\n    emails: {\n      'clark@daily.planet': '1',\n      'bruce@wayne.enterprises': '2',\n    },\n    'user:1': { id: '1', username: 'superman', email: 'clark@daily.planet' },\n    'user:2': { id: '2', username: 'batman', email: 'bruce@wayne.enterprises' },\n  },\n});\n// Basically use it just like ioredis\n```\n\n### Configuring Jest\n\nUse the jest specific bundle when setting up mocks:\n\n```js\njest.mock('ioredis', () => require('ioredis-mock/jest'));\n```\n\nThe `ioredis-mock/jest` bundle inlines imports from `ioredis` that `ioredis-mock` rely on. Thus you can map `ioredis` import identifiers to `ioredis-mock/jest` [without dealing with circular issues](https://github.com/stipsan/ioredis-mock/issues/568).\n\n### Pub/Sub channels\n\nWe also support redis publish/subscribe channels (just like ioredis).\nLike ioredis, you need two clients:\n\n- the pubSub client for subcriptions and events, [which can only be used for subscriptions](https://redis.io/topics/pubsub)\n- the usual client for issuing 'synchronous' commands like get, publish, etc\n\n```js\nvar Redis = require('ioredis-mock');\nvar redisPubSub = new Redis();\n// create a second Redis Mock (connected to redisPubSub)\nvar redisSync = redisPubSub.createConnectedClient();\nredisPubSub.on('message', (channel, message) => {\n  expect(channel).toBe('emails');\n  expect(message).toBe('clark@daily.planet');\n  done();\n});\nredisPubSub.subscribe('emails');\nredisSync.publish('emails', 'clark@daily.planet');\n```\n\n### Promises\n\nBy default, ioredis-mock uses the native Promise library. If you need (or prefer) [bluebird](http://bluebirdjs.com/) promises, set `Redis.Promise`:\n\n```js\nvar Promise = require('bluebird');\nvar Redis = require('ioredis-mock');\n\nRedis.Promise = Promise;\n```\n\n### Lua scripting\n\nYou can use the `defineCommand` to define custom commands using lua or `eval` to directly execute lua code.\n\nIn order to create custom commands, using [lua](http://lua.org) scripting, [ioredis exposes the defineCommand method](https://github.com/luin/ioredis#lua-scripting).\n\nYou could define a custom command `MULTIPLY` which accepts one\nkey and one argument. A redis key, where you can get the multiplicand, and an argument which will be the multiplicator:\n\n```js\nvar Redis = require('ioredis-mock');\nconst redis = new Redis({ data: { 'k1': 5 } });\nconst commandDefinition: { numberOfKeys: 1, lua: 'return KEYS[1] * ARGV[1]' };\nredis.defineCommand('MULTIPLY', commandDefinition) // defineCommand(name, definition)\n  // now we can call our brand new multiply command as an ordinary command\n  .then(() => redis.multiply('k1', 10));\n  .then(result => {\n    expect(result).toBe(5 * 10);\n  })\n```\n\nYou can also achieve the same effect by using the `eval` command:\n\n```js\nvar Redis = require('ioredis-mock');\nconst redis = new Redis({ data: { k1: 5 } });\nconst result = redis.eval(`return redis.call(\"GET\", \"k1\") * 10`);\nexpect(result).toBe(5 * 10);\n```\n\nnote we are calling the ordinary redis `GET` command by using the global `redis` object's `call` method.\n\nAs a difference from ioredis we currently don't support:\n\n- dynamic key number by passing the number of keys as the first argument of the command.\n- automatic definition of the custom command buffer companion (i.e. for the custom command `multiply` the `multiplyBuffer` which returns values using `Buffer.from(...)`)\n- the `evalsha` command\n- the `script` command\n\n### Cluster(Experimental)\n\nWork on Cluster support has started, the current implementation is minimal and PRs welcome #359\n\n```js\nvar Redis = require('ioredis-mock');\n\nconst cluster = new Redis.Cluster(['redis://localhost:7001']);\nconst nodes = cluster.nodes;\nexpect(nodes.length).toEqual(1);\n```\n\n## Roadmap\n\nThis project started off as just an utility in\n[another project](https://github.com/stipsan/epic) and got open sourced to\nbenefit the rest of the ioredis community. This means there's work to do before\nit's feature complete:\n\n- [x] Setup testing suite for the library itself.\n- [x] Refactor to bluebird promises like ioredis, support node style callback\n      too.\n- [x] Implement remaining basic features that read/write data.\n- [x] Implement ioredis\n      [argument and reply transformers](https://github.com/luin/ioredis#transforming-arguments--replies).\n- [ ] Connection Events\n- [ ] Offline Queue\n- [x] Pub/Sub\n- [ ] Error Handling\n- [ ] Implement [remaining](compat.md) commands\n\n## I need a feature not listed here\n\nJust create an issue and tell us all about it or submit a PR with it! 😄\n","readmeFilename":"README.md"}