{"_id":"@aikar/dpromise","_rev":"2-061218bb19e0ed5b36dcbf0ea8a608ce","name":"@aikar/dpromise","dist-tags":{"latest":"1.1.0"},"versions":{"1.0.0":{"name":"@aikar/dpromise","version":"1.0.0","description":"Deferred Promises. Create a promise that allows deferring completion of the promise for more flexible control.","main":"dpromise.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/aikar/dpromise.git"},"keywords":["deferred","promise","dpromise","defer-promise","promise.defer"],"author":{"name":"Daniel Ennis","email":"aikar@aikar.co"},"license":"MIT","bugs":{"url":"https://github.com/aikar/dpromise/issues"},"homepage":"https://github.com/aikar/dpromise#readme","gitHead":"41a046e3e5e2069dd675e4ff7dd82187f74b51f3","_id":"@aikar/dpromise@1.0.0","_npmVersion":"6.4.1","_nodeVersion":"8.16.2","_npmUser":{"name":"aikar","email":"aikar@aikar.co"},"dist":{"integrity":"sha512-ErRAh/sw2XNVetn+ASjsqoZNAO/lIq+u4FZ300IF2HBxF5mz779SqZr/hL9FX+jl8QljNyjLjmXdKfyhLAVZ+Q==","shasum":"347025dda29f35ece88632acd7376b2797ca0617","tarball":"https://registry.npmjs.org/@aikar/dpromise/-/dpromise-1.0.0.tgz","fileCount":5,"unpackedSize":6241,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdv3JRCRA9TVsSAnZWagAAISsQAJrfsucAZETnIXn1e6F9\nL/7abId0vxI60xw2FovpOb/tFBpoykI10Q9mozNm2BhEwlGdOTvNBXDLqWZv\nPeTzIysv9YoZycOjm83nhfc701TMb8XT3oA7Yyu4AAbcx07qvWoksUiXwHFs\n/UCF4iJ6/dQFAYXJO6K7NIPByZP9oxDPQ8TEJNfNvqYOcXpUzlU26zlFVpPM\nbV5+Z8k3uozUjvxz41ITFX3o/4mQK4KP6H8U2OULxl4aGEq+/LnCm2eg7fMK\nWDq8pcul8Ql3OSYTJAUwAXihHNsA6jWRcIpbSgF/SiV1XdPtTvBioWBt6ukI\nczmT0AvPZef6t4P/jbyofPS/WGJvg5+4dz41aVf3IcOlCZ1WZuyG5I76yNNz\np1hLgv5zZG78PlWlny4XG9bn8Uv+OKsbgkf48d63wzn6jbSiqII9fCY3bFTq\nmWu7LeHkXW/ZPBK8bkeGo20V8HlNtuSK5P0TwfDuy7jcleNw9IlJBC3lFwxB\ny7wGvjYjpSe8JrtXGmZIFfTPebshXakFaQnrhvMJfoeN75lg6oMAmZq/kYp4\nw6ivwMop29692W1jbM1mBxpn9SzaifR/a2wxZm+fqZ+URZY5Cqi953Tw/c1J\nPUEfgzyQ2qFyPx7PrrHGY4XiTI7Mt4GpZQuCchXRS9byOzmuz/MeM8hUvTnW\nKBJQ\r\n=qF3X\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC6qf7BnkVAQQ/IwdhzncchxmrJrBRyPcCZh+LMeVX1mAIhALxa1WkPY4gFPLQyt2XrNYGW1AzegWG+kjbyPP2xb8Q3"}]},"maintainers":[{"name":"aikar","email":"aikar@aikar.co"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/dpromise_1.0.0_1572827728766_0.8386058295455261"},"_hasShrinkwrap":false},"1.1.0":{"name":"@aikar/dpromise","version":"1.1.0","description":"Deferred Promises. Create a promise that allows deferring completion of the promise for more flexible control.","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/aikar/dpromise.git"},"keywords":["deferred","promise","dpromise","defer-promise","promise.defer"],"author":{"name":"Daniel Ennis","email":"aikar@aikar.co"},"license":"MIT","bugs":{"url":"https://github.com/aikar/dpromise/issues"},"homepage":"https://github.com/aikar/dpromise#readme","gitHead":"08df77a78c1200ba1bebb0f82aff72810df905e0","_id":"@aikar/dpromise@1.1.0","_npmVersion":"6.4.1","_nodeVersion":"8.16.2","_npmUser":{"name":"aikar","email":"aikar@aikar.co"},"dist":{"integrity":"sha512-A9sUjaVnI/j+VVyK6JInscKOwKiQkZPDcpe2DHTbZxTU01q/WmOkrr9DT+5JdGMbF7cdHslvKeE/H2humMnClw==","shasum":"951f2240d755f6c67432e98b0a80c29e7afa034e","tarball":"https://registry.npmjs.org/@aikar/dpromise/-/dpromise-1.1.0.tgz","fileCount":5,"unpackedSize":6238,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdv3M+CRA9TVsSAnZWagAAI+MP/2iYIFV9BIukqEjwtnUs\nhwY2lQKeN5IxLhpZ/6dSh0N0Wis8jirCwLDsmBy3TYhmSm6yCRxRr9Ch2gXv\n+pM2BY1V5lRPWWQ7cMwHI13x1PClha9cI74ICOCIV6fJN4D/AUgWLGVDGthc\ntKZq5qYoob1/gpQm5HHDYvUwi/z6g/Tj6hC5VWQZvGTBkNeEPCO8TwTjq0eD\njt4rezYnMIUtO+Bg59Py7a+HALjxwfLtDB8gwV2672LdI6/nLJJvfwrCKIcc\n6BZPyOKAKrE29ziHY8xOU7kqIquIm8jgzP1f5wJCaCZ5INkvbXMwLm1vfPrE\nJuaSyDZIQYh9fmDT/Pf9roK0yYNEBK2N3/72vUOnTa3kx3WBb/VYXVXgSp12\nlJFazxpO/VcfAvLEIem5CSIF03C66OVTBy7WrOlHWJQRxlfdRZZhQtskkIHO\nB6wxOzCwyWa6EL3KYhIIHTLdhPDD4cVyn1aAHTPW9Nn5FFYh13PnnK4cMxcO\n/9q9giokiGpoIOB+H+B15hbAac7j3JWj7afpxrf+f0eA97mdE/Oo6j1wg2YK\nJ9GHo6o+VnfvvK6lGPbpra6KXRlnZaG2GnM97hTzYjdLMLyDf0K9Uxmkj1Cy\nIqjNTZ0jr4IFiPxx87K3dYyZamQ6knMtlCG+JOiuWe8U9Wt+V9lrkBPNeOyU\nTqcx\r\n=bC3J\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIG+/7Qx9EHkhfSm2TjBjIfJMt9fTeQoZIekTlZ6kSYSCAiEA4AVkh8OSaA/YG66pJchZJ0JUedk3m7KIm+OWwLfDTUg="}]},"maintainers":[{"name":"aikar","email":"aikar@aikar.co"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/dpromise_1.1.0_1572827966439_0.26532798390287904"},"_hasShrinkwrap":false}},"time":{"created":"2019-11-04T00:35:28.543Z","1.0.0":"2019-11-04T00:35:28.903Z","modified":"2022-04-04T12:18:12.561Z","1.1.0":"2019-11-04T00:39:26.576Z"},"maintainers":[{"name":"aikar","email":"aikar@aikar.co"}],"description":"Deferred Promises. Create a promise that allows deferring completion of the promise for more flexible control.","homepage":"https://github.com/aikar/dpromise#readme","keywords":["deferred","promise","dpromise","defer-promise","promise.defer"],"repository":{"type":"git","url":"git+https://github.com/aikar/dpromise.git"},"author":{"name":"Daniel Ennis","email":"aikar@aikar.co"},"bugs":{"url":"https://github.com/aikar/dpromise/issues"},"license":"MIT","readme":"# dpromise\nDeferred Promises. Create a promise that allows deferring completion of the promise for more flexible control.\n\n## Usage\n\n```javascript\nimport {deferPromise} from \"@aikar/dpromise\";\n// or\nconst {deferPromise} = require(\"@aikar/dpromise\");\n\nconst promise = deferPromise();\npromise.resolve();\npromise.reject(new Error());\n```\n\n## Flexibility of control.\nStandard promise creation implies that the creator of the promise will begin the process of how to fulfill the promise.\n\nBut what if that is not what you want? What if you want something else to fulfill the promise?\n\nDeferred promises accomplish this by decoupling Promise creation from Promise fulfillment. \n\n## Anti Pattern rumours\n**\"Isn't this an anti pattern?\"**\nYou may of heard that Promise.defer() and the like in Bluebird is an \"anti-pattern\", but rest assured, it is not.\n\nJust because an experienced person says something, does not make it true. Anyone declaring that this is an anti pattern\nis expressing an **OPINION**.\n\nAnd here I am expressing my opinion that they are wrong and used very poor reasoning for declaring such a statement.\n\nBoth the reasons stated at [Bluebird](https://github.com/petkaantonov/bluebird/wiki/Promise-anti-patterns) are invalid.\n\n1. The defer library did not encourage this flawed code nor enable it. \nThere are numerous ways that flawed logic could of surfaced, including using non deferred promises.\n2. This is a very poor argument \"Because another solution is already available\".\\\n\\\nAgain, the defer functionality did not encourage this use, and it's also not fair to say it's an inappropriate use.\\\n\\\nWhat if you are in an environment that does not have a promisify method supplied? \\\n\\\nWhat if you have a more complicated API you are interfacing that does not use standard callbacks? \nThis would be all valid use cases. \n\nIf we are going to accuse a specific pattern to be an anti pattern because some developer used it when a better\nsolution was available, then we might as well call the entire language an anti pattern.\n\nLet's also mention that this pattern is part of the core system for Java 8+ Promise/Future support. \nTo say this is an anti pattern, would be saying the same for the entire CompletableFuture system in Java.\n\nThis is a tool. There are many tools in your toolbox. Misusing a tool is not the tools fault.\n\n## Aren't there a few other deferred promise libraries out there?\nYes, they all return an object wrapper requiring you to do await result.promise;\n\nThis library returns an actual extended Promise object.\n\n## How can I change what Promise is used\nOverride the Promise export this module exports (Not recommended)\n```javascript\nrequire(\"@aikar/dpromise\").Promise = require(\"bluebird\");\n````\n\n## License\ndpromise (c) Daniel Ennis (Aikar) 2019-present.\ndpromise is licensed [MIT](https://tldrlegal.com/license/mit-license). See [LICENSE](LICENSE)\n\n","readmeFilename":"README.md"}