{"_id":"@api3/promise-utils","_rev":"14-dea3b98ca26c44a55e993b79ad13fedc","name":"@api3/promise-utils","dist-tags":{"latest":"0.4.0"},"versions":{"0.1.0":{"name":"@api3/promise-utils","version":"0.1.0","license":"MIT","_id":"@api3/promise-utils@0.1.0","maintainers":[{"name":"aquarat","email":"blue@aquarat.co.za"},{"name":"bbenligiray","email":"bbenligiray@gmail.com"},{"name":"andreogle","email":"ogleandre@gmail.com"}],"dist":{"shasum":"bc0678a5d19b32274192656dc787a131e22d82dc","tarball":"https://registry.npmjs.org/@api3/promise-utils/-/promise-utils-0.1.0.tgz","fileCount":20,"integrity":"sha512-hel2yq9p9d5Yki9nf+9S7XNDzko+FVzYUps5JGwl6XvV5eBaEUDkEeTG5ulyUORzJdplfT+KyE1zxwIMG/ZfhQ==","signatures":[{"sig":"MEYCIQDQNmNc5iw6jC7r3SChnKvQv/xtbezDN+9UxJyXnzrVTAIhAKlnPfVRqbwL6uMD/C61BpdEWAkmp0kdvHPK+3C3CTof","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":47056,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiMHPJACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmo9CA/8D6kFW331ltio8v7HI4nU2WXl/16qbDj0HwVQH1vVA1fhypM+\r\nGVS/0rCUguBXmCce3VxTuU9tnnSlTQ3YBG9P2KCwTmI486hsc4uU+9CxEPKv\r\nT/p8Hq2xebVbwJo0DCJR46s1Id71GjkTnQUYM5DlyLRp088gLCSMqFsU5RqO\r\nuGxF0BAdMU8pzdxpJCDuKcMRLbnsjN4+LaTYVBUQVNovKo+FeDWyr67x0ocU\r\nRqH5IsetLuHgTz3Ilw/YDkAqlKYBZfqF9FkIvTkrNqhrmsADbm4QxyI/xat0\r\na83zcyY8WdOokakwUj+ZOGoS6pgK/C+Lew8KXgv+szTBrmphcWv9rr5xl2Ea\r\nlvIpU3VTlAK6ne8FuBC6PzOHYTlH8ynh/jzheIl9DMTfNnfAvchhtYHetpFB\r\nSFbyYp0ddYwpEuMhYOI5nh8pSA0+pLVlQF5B0qiKlQnKm5wKqDEKLbuwoXEg\r\n7snJ0v1c4thqtKsm9m+1aFXYZ58jFQO/b8lrEtb4lNgRsuhVeoNoYo3rOmxH\r\nJXlFXd5tC5awF+y03d7Ve4mTzomtkLJ6BfR4zm0e58pHFkbI+8c/2YxoA7yI\r\nodcEERXgN6ZGPfJpdGIw9pIwdaLiHQAdogjXkyYZJu90/0Zui53mlC4CR0qS\r\nypuYmXE55dmlijk7glwr2gWu2a8S/Cl8Dm0=\r\n=MML0\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./build/cjs/index.js","module":"./build/esm/index.js","browser":"./build/es6/index.js","scripts":{"lint":"yarn lint:tsc && yarn lint:prettier","test":"jest","build":"yarn clean && yarn build:cjs && yarn build:es6 && yarn build:esm","clean":"rm -rf build","prepare":"husky install","lint:tsc":"yarn tsc -p .","build:cjs":"yarn tsc -p tsconfig.build-cjs.json","build:es6":"yarn tsc -p tsconfig.build-es6.json","build:esm":"yarn tsc -p tsconfig.build-esm.json","test:watch":"jest --watch","lint:prettier":"yarn prettier --check \"./**/*.{js,ts,md,yml}\"","prepublishOnly":"yarn && yarn build","lint:prettier:fix":"yarn prettier --write \"./**/*.{js,ts,md,yml}\""},"_npmUser":{"name":"bbenligiray","email":"bbenligiray@gmail.com"},"repository":{"url":"git@github.com:api3dao/promise-utils","type":"git"},"description":"> A simple package for a functional and typesafe error handling","directories":{},"licenseText":"MIT License\n\nCopyright (c) 2022 API3 Foundation\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.\n","dependencies":{"@lifeomic/attempt":"^3.0.2"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^27.5.1","husky":"^7.0.0","ts-jest":"^27.1.3","prettier":"^2.5.1","type-plus":"^4.0.1","typescript":"^4.6.2","@types/jest":"^27.4.1"},"_npmOperationalInternal":{"tmp":"tmp/promise-utils_0.1.0_1647342536814_0.7259205733553069","host":"s3://npm-registry-packages"}},"0.2.0":{"name":"@api3/promise-utils","version":"0.2.0","license":"MIT","_id":"@api3/promise-utils@0.2.0","maintainers":[{"name":"aquarat","email":"blue@aquarat.co.za"},{"name":"bbenligiray","email":"bbenligiray@gmail.com"},{"name":"andreogle","email":"ogleandre@gmail.com"}],"dist":{"shasum":"3484aa945af5695da046b0aaf482af6aafeed327","tarball":"https://registry.npmjs.org/@api3/promise-utils/-/promise-utils-0.2.0.tgz","fileCount":20,"integrity":"sha512-pIkB9rh/rrOhwJtnWUoq/v6LNfNQygn9TE8DRL+FJOlcOUgocCR6hxjpiEnrP2noU+2KmNJxCvx+E/L7Nhs/uQ==","signatures":[{"sig":"MEQCICtl2rGdRXNhXhdvGEYmXBayt1cAfL1ifno5XwIc3zKPAiA8f5GSm4+5EkUZwkAYB1mzB/BYAjepJABsXDMdKApayg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":59848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiUDA2ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpEBg/+M6ot5vMMZiu5IicKIo3688Ez8w/Fxm2cNMWHoKKtkiE+c84A\r\nCbi6oWMgJDxeco1RfERK1VP0GZ/hS3+EDnQice6JcPAvxDuVg1h37oUVN14b\r\nqV8/aC8yj6sQdE6GrLQWw88YkDgWOL1ZH+nKG3pkkn+PZOP1BY4Lz9ZLU8CG\r\nOq2x6G9Cj/ll1M/Bm9KISIqFpHnMgVDwKkqO62YAvJZe9wLBxQQLLquGXQqm\r\n0iRiTkbsWtyLeTFMqffpSnAXjbGULqHjMkKZd9llgfqET+L6jL61gy1siq9w\r\ng0njH1ahvG/3pLTBdrv3iufgxA28rRS3SmkVEF+I/B0mr8meyk7iteLpkOZt\r\nGQnCWgnq9lp52aX6syTjr8/URfwAJAxulX5UtcaoZY8pSQdXkChjI4C0Xo+O\r\nfc94r/ejVSCOMZbdfDuZYGTV3GtU75UjRLOqS83IBfuALpaS9wG9xiLsJREn\r\nqaYdJ5sdu/TQ8o22Vuydiu4fF8qDgFC7DURR68c43TA8oBM+2R2mStYUhWk2\r\n24friEj4Ii9ojN9iqANQ9bntbsm4gdLuNd4ArQ02AMHPW+CTi2XMJCKJMQmd\r\nVuq2mQo5XvIN9wD9MR1zVebcI5Bli4igCKhJtwTYBoZworC8neKiEMSveVrX\r\n6b3/r0d0jwpuzLi+2SZZi/1TNHFJ+3flxs4=\r\n=UYvB\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./build/cjs/index.js","module":"./build/esm/index.js","browser":"./build/es6/index.js","scripts":{"lint":"yarn lint:tsc && yarn lint:prettier","test":"jest","build":"yarn clean && yarn build:cjs && yarn build:es6 && yarn build:esm","clean":"rm -rf build","prepare":"husky install","lint:tsc":"yarn tsc -p .","build:cjs":"yarn tsc -p tsconfig.build-cjs.json","build:es6":"yarn tsc -p tsconfig.build-es6.json","build:esm":"yarn tsc -p tsconfig.build-esm.json","test:watch":"jest --watch","lint:prettier":"yarn prettier --check \"./**/*.{js,ts,md,yml}\"","prepublishOnly":"yarn && yarn build","lint:prettier:fix":"yarn prettier --write \"./**/*.{js,ts,md,yml}\""},"_npmUser":{"name":"bbenligiray","email":"bbenligiray@gmail.com"},"repository":{"url":"git@github.com:api3dao/promise-utils","type":"git"},"description":"> A simple package for a functional and typesafe error handling with zero dependencies","directories":{},"licenseText":"MIT License\n\nCopyright (c) 2022 API3 Foundation\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.\n","dependencies":{},"_hasShrinkwrap":false,"devDependencies":{"jest":"^27.5.1","husky":"^7.0.0","ts-jest":"^27.1.4","prettier":"^2.6.2","type-plus":"^4.7.0","typescript":"^4.6.3","@types/jest":"^27.4.1"},"_npmOperationalInternal":{"tmp":"tmp/promise-utils_0.2.0_1649422390513_0.9352154099922638","host":"s3://npm-registry-packages"}},"0.3.0":{"name":"@api3/promise-utils","version":"0.3.0","license":"MIT","_id":"@api3/promise-utils@0.3.0","maintainers":[{"name":"aquarat","email":"blue@aquarat.co.za"},{"name":"bbenligiray","email":"bbenligiray@gmail.com"},{"name":"andreogle","email":"ogleandre@gmail.com"}],"dist":{"shasum":"e7ebf92bfd8c1d39983321fc5445070c51fce176","tarball":"https://registry.npmjs.org/@api3/promise-utils/-/promise-utils-0.3.0.tgz","fileCount":20,"integrity":"sha512-fH3CzEcsCQjoX6BZ5M+3yRIXZ2zz4/nFdzKUB4wvn3KjvvzvroHFZrzhbKa4mB9E4AS0xnou1AXhlrnN5Fcy+A==","signatures":[{"sig":"MEUCICXddERn5GA252PJSRNmn86UbVn90JEeHrkNbM/fwufiAiEAnFZQ1La7PDh5gnjjf0Fwn6Ew5pGljRqxpjLnYlXzYwE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":76849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiYuKwACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmohqg/5AAuISeXvE20DCkyP4E+AvqXqqK0BU2D9R1vF3YUmBlX4Cl2l\r\nBpJBnF3XJ+nmvsxVH/SbFL3z2kJ0clvUc+LOuKOBWthxxcCrrxsFMST2VAfF\r\nILzR3vbps4zTlX/cNVfkxMvwlUxzaqOCKVAnSc7kRkB4Kj3JfIckSfB0tqK2\r\ncNOpM0K2n/V/GqCxNpFYMOLUFJf7wbsY1slLXIAzZYEHGkHQDDop6KuAn9dy\r\nIFe/tLFyr8Vd/kUxEbmztxdcXAn/MuZ2C0beJNAFqa5PzfYMqPHyeG2Gji1z\r\nvWFOJMsN/qfQV2WwjjGwJVw1rZoKjeYY6hovMuEMEpdM1L0Txvc2QUdsab/D\r\n1hiUX8VrE6+nm1GHkIhTyZTWwSV79C2zdxummDoHyMbj0exr0se6SYZTigAP\r\nCZ3y4zQ0wkAiVPXRzPFIFcDfeC68FG9AU+TVEfqHx1epe0rEN2lzMRqpQFp8\r\ncHZaO7R6HS2DRH8dac+zrDlQJbLUopDf3aXTgPlfqEOnnuThcWJUaLMEmouJ\r\ntcgspRBAF+gQxOJIDaBoRYRB6NSof7kH/5GAC9BGe7hVFYJeuZb8hZM+E21a\r\nnYeYxGkJ89swoZdXwF5fVUoRXHl/efhNp1zBr/lX5bdVCxTPPpKLftu2QG1l\r\nEgfvSQVCTL6gjxI1xKKqwStL25nSSwo1twE=\r\n=e5Ai\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./build/cjs/index.js","module":"./build/esm/index.js","browser":"./build/es6/index.js","scripts":{"lint":"yarn lint:tsc && yarn lint:prettier","test":"jest","build":"yarn clean && yarn build:cjs && yarn build:es6 && yarn build:esm","clean":"rm -rf build","prepare":"husky install","lint:tsc":"yarn tsc -p .","build:cjs":"yarn tsc -p tsconfig.build-cjs.json","build:es6":"yarn tsc -p tsconfig.build-es6.json","build:esm":"yarn tsc -p tsconfig.build-esm.json","test:watch":"jest --watch","lint:prettier":"yarn prettier --check \"./**/*.{js,ts,md,yml}\"","prepublishOnly":"yarn && yarn build","lint:prettier:fix":"yarn prettier --write \"./**/*.{js,ts,md,yml}\""},"_npmUser":{"name":"bbenligiray","email":"bbenligiray@gmail.com"},"repository":{"url":"git@github.com:api3dao/promise-utils","type":"git"},"description":"> A simple package for a functional and typesafe error handling with zero dependencies","directories":{},"licenseText":"MIT License\n\nCopyright (c) 2022 API3 Foundation\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.\n","dependencies":{},"_hasShrinkwrap":false,"devDependencies":{"jest":"^27.5.1","husky":"^7.0.0","ts-jest":"^27.1.4","prettier":"^2.6.2","type-plus":"^4.9.0","typescript":"^4.6.3","@types/jest":"^27.4.1"},"_npmOperationalInternal":{"tmp":"tmp/promise-utils_0.3.0_1650647728167_0.42232432946935816","host":"s3://npm-registry-packages"}},"0.4.0":{"name":"@api3/promise-utils","version":"0.4.0","license":"MIT","_id":"@api3/promise-utils@0.4.0","maintainers":[{"name":"amarthadan","email":"kimle.michal@gmail.com"},{"name":"aquarat","email":"blue@aquarat.co.za"},{"name":"bbenligiray","email":"bbenligiray@gmail.com"},{"name":"andreogle","email":"ogleandre@gmail.com"}],"dist":{"shasum":"d1dcd77d74377b4fdb3071d2cc76d98c9151309c","tarball":"https://registry.npmjs.org/@api3/promise-utils/-/promise-utils-0.4.0.tgz","fileCount":20,"integrity":"sha512-+8fcNjjQeQAuuSXFwu8PMZcYzjwjDiGYcMUfAQ0lpREb1zHonwWZ2N0B9h/g1cvWzg9YhElbeb/SyhCrNm+b/A==","signatures":[{"sig":"MEQCIDWMaOdiAIPgQEWnLlFQD+R3D+XEPbVmRc9UmMPlysbyAiBMDzW6ZYRIfhy890VKhBVmd2w5Bg2MRPkIP5TPPx616Q==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":83968,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkGaLXACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmojLg//RwePQQkHK9GRHfozoJ6phK6Xo/Dc9cmZ0jfjKdH/HPnBW1mc\r\nf4s4VCBfm/AFM+9Z3NHTStLTesf291elg6sNAtzUxMx/LC6wqMQYj8gW8HtZ\r\neWXmDUlsmXhQuLDtNXluBIc645ofJfZx7m9MMRXufaOnqmGDBfAq3mvxKL/2\r\nSESMWhC+iSyA7OAP1xq36bCuDTcAZr6zk/lKwJa+dSTzpaDj6GgBN0L+9Eoe\r\nlLn+gquOB/T0VQIH9TBj+H6Cob169gTnA8Ahj6jMMyb6S93eEiK3uz8IuRyz\r\nbrBQgXx+1pHf0teTClt9gq/sqgHLeFaP80zqDO1dComKM4C7i7hpm8yDrC7o\r\nYi38Z3AZN04n5W98+CySDRDqdOmcRGvUZbg/OsKrYyeKMTq44XkDgxepGoCE\r\nD5SXCgkqn2rt3p+2iVjVgYkRudlnGAd/qhRaeBxdlLmxu8xfuitGscjPcSPO\r\nvpuZxWmj/MOdFHM9qDpEoJGChICEL3uuo9gjo25C6nTqW06OQ6oGzGcrCtpc\r\nyFUbra1qv3tzfzK1hUINuJ1uRP591SQkvBf7KH66Z1mSG5xXk61GEEL80qtB\r\nLNq8NvP/11U1dA8/SzVINHZz4tb+zFmtbM/bTz/sEAVj6B26lUL1X2HabIA2\r\nkxcEoKG7F6CbHPEJ7xjQ0xPAN9HEcVRiJWc=\r\n=ZzHj\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./build/cjs/index.js","module":"./build/esm/index.js","browser":"./build/es6/index.js","scripts":{"lint":"yarn lint:tsc && yarn lint:prettier","test":"jest","build":"yarn clean && yarn build:cjs && yarn build:es6 && yarn build:esm","clean":"rm -rf build","prepare":"husky install","lint:tsc":"yarn tsc -p .","build:cjs":"yarn tsc -p tsconfig.build-cjs.json","build:es6":"yarn tsc -p tsconfig.build-es6.json","build:esm":"yarn tsc -p tsconfig.build-esm.json","test:watch":"jest --watch","lint:prettier":"yarn prettier --check \"./**/*.{js,ts,md,yml}\"","prepublishOnly":"yarn && yarn build","lint:prettier:fix":"yarn prettier --write \"./**/*.{js,ts,md,yml}\""},"_npmUser":{"name":"bbenligiray","email":"bbenligiray@gmail.com"},"repository":{"url":"git@github.com:api3dao/promise-utils","type":"git"},"description":"> A simple package for a functional and typesafe error handling with zero dependencies","directories":{},"licenseText":"MIT License\n\nCopyright (c) 2022 API3 Foundation\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.\n","dependencies":{},"_hasShrinkwrap":false,"devDependencies":{"jest":"^28.1.3","husky":"^8.0.3","ts-jest":"^28.0.8","prettier":"^2.8.4","type-plus":"^5.6.0","typescript":"^4.9.5","@types/jest":"^28.1.7"},"_npmOperationalInternal":{"tmp":"tmp/promise-utils_0.4.0_1679401686955_0.7849449089065523","host":"s3://npm-registry-packages"}}},"time":{"created":"2022-03-15T11:08:56.754Z","modified":"2026-04-07T10:33:25.139Z","0.1.0":"2022-03-15T11:08:57.200Z","0.2.0":"2022-04-08T12:53:10.669Z","0.3.0":"2022-04-22T17:15:28.498Z","0.4.0":"2023-03-21T12:28:07.167Z"},"license":"MIT","repository":{"url":"git@github.com:api3dao/promise-utils","type":"git"},"description":"> A simple package for a functional and typesafe error handling with zero dependencies","maintainers":[{"email":"bbenligiray@gmail.com","name":"bbenligiray"},{"email":"e.tesarr@gmail.com","name":"siegrift"}],"readme":"# promise-utils [![ContinuousBuild](https://github.com/api3dao/promise-utils/actions/workflows/main.yml/badge.svg?branch=main)](https://github.com/api3dao/promise-utils/actions/workflows/main.yml)\n\n> A simple package for a functional and typesafe error handling with zero dependencies\n\n## Installation\n\nTo install this package run either:\n\n`yarn add @api3/promise-utils`\n\nor if you use npm:\n\n`npm install @api3/promise-utils --save`\n\n## Usage\n\nThe API is small and well focused on providing [more concise error handling](#motivation). The main functions of this\npackage are `go` and `goSync` functions. They accept a function to execute, and additionally `go` accepts an optional\n`GoAsyncOptions` object as the second parameter. If the function executes without an error, a success response with the\ndata is returned, otherwise an error response is returned.\n\n<!-- NOTE: Keep in sync with the \"documentation snippets are valid\" test -->\n\n```ts\n// Imagine an async function for fetching API data\nconst goFetchData = await go(() => fetchData('users'));\n// The \"goFetchData\" value is either: {success: true, data: ...} or {success: false, error: ...}\nif (goFetchData.success) {\n  const data = goFetchData.data\n  ...\n}\n```\n\nor:\n\n```ts\n// Imagine an async function for fetching API data\n// If the fetch data is a non class function returning a promise, you can drop the arrow function\nconst goFetchData = await go(() => fetchData('users'));\n// The \"goFetchData\" value is either: {success: true, data: ...} or {success: false, error: ...}\nif (!goFetchData.success) {\n  const error = goFetchData.error\n  ...\n}\n```\n\nand with `GoAsyncOptions`:\n\n```ts\n// The `fetchData` function will be retried a maximum of 2 times on error, with each attempt having\n// a timeout of 5 seconds and a total timeout 10 seconds (shared among all attempts and delays).\nconst goFetchData = await go(() => fetchData('users'), { retries: 2, attemptTimeoutMs: 5_000, totalTimeoutMs: 10_000 });\n...\n```\n\nand for synchronous functions:\n\n```ts\nconst someData = ...\n// Imagine a synchronous function for parsing data\nconst goParseData = goSync(() => parseData(someData));\n// The goParseData value is either: {success: true, data: ...} or {success: false, error: ...}\nif (goParseData.success) {\n  const data = goParseData.data\n  ...\n}\n```\n\nThe return value from the promise utils functions works very well with TypeScript inference. When you check the the\n`success` property, TypeScript will infer the correct response type.\n\n## API\n\nThe full `promise-utils` API consists of the following functions:\n\n- `go(asyncFn, options)` - Executes the `asyncFn` and returns a response of type `GoResult`\n- `goSync(fn)` - Executes the `fn` and returns a response of type `GoResult`\n- `assertGoSuccess(goRes)` - Verifies that the `goRes` is a success response (`GoResultSuccess` type) and throws\n  otherwise.\n- `assertGoError(goRes)` - Verifies that the `goRes` is an error response (`GoResultError` type) and throws otherwise.\n- `success(value)` - Creates a successful result value, specifically `{success: true, data: value}`\n- `fail(error)` - Creates an error result, specifically `{success: false, error: error}`\n\nand the following Typescript types:\n\n- ```ts\n  type GoResult<T> = { data: T; success: true };\n  ```\n- ```ts\n  type GoResultSuccess<E extends Error = Error> = { error: E; success: false };\n  ```\n- ```ts\n  type GoResultError<T, E extends Error = Error> = GoResultSuccess<T> | GoResultError<E>;\n  ```\n- ```ts\n  interface GoAsyncOptions<E extends Error = Error> {\n    retries?: number; // Number of retries to attempt if the go callback is unsuccessful.\n    attemptTimeoutMs?: number | number[]; // The timeout for each attempt. Can provide an array for different timeouts for each attempt. If the array is shorter than the number of retries, the last value is used for all remaining attempts, if the length of the array is longer than the number of retries, the extra values are ignored.\n    totalTimeoutMs?: number; // The maximum timeout for all attempts and delays. No more retries are performed after this timeout.\n    delay?: StaticDelayOptions | RandomDelayOptions; // Type of the delay before each attempt. There is no delay before the first request.\n    onAttemptError?: (goRes: GoResultError<E>) => void; // Callback invoked after each failed attempt is completed. This callback does not fire for the last attempt or when a \"totalTimeoutMs\" is exceeded (these should be handled explicitly with the result of \"go\" call).\n  }\n  ```\n- ```ts\n  interface StaticDelayOptions {\n    type: 'static';\n    delayMs: number;\n  }\n  ```\n- ```ts\n  interface RandomDelayOptions {\n    type: 'random';\n    minDelayMs: number;\n    maxDelayMs: number;\n  }\n  ```\n\nCareful, the `attemptTimeoutMs` value of `0` means timeout of 0 ms. If you want to have infinite timeout omit the key or\nset it to `undefined`.\n\nThe last exported value is a `GoWrappedError` class which wraps an error which happens in go callback. The difference\nbetween `GoWrappedError` and regular `Error` class is that you can access `GoWrappedError.reason` to get the original\nvalue which was thrown by the function.\n\nTake a look at the [implementation](https://github.com/api3dao/promise-utils/blob/main/src/index.ts) and\n[tests](https://github.com/api3dao/promise-utils/blob/main/src/index.test.ts) for detailed examples and usage.\n\n## Motivation\n\n### Verbosity and interoperability of try-catch pattern\n\n```ts\n// Verbose try catch\ntry {\n  const data = await someAsyncCall();\n  ...\n} catch (e) {\n  // The \"e\" is \"unknown\" because any value can be thrown in Javascript so casting is needed\n  return logError((e as MyError).reason);\n}\n\n// Compare it to simpler version using go\nconst goRes = await go<MyData, MyError>(someAsyncCall);\nif (!goRes.success) return logError(goRes.error.reason);\n// At this point TypeScript infers that the error was handled and \"goRes\" must be a success response\nconst data = goRes.data;\n...\n```\n\nAlso, think about what happens when you want to handle multiple \"can fail\" operations in a single function call. You can\neither:\n\n1. Have them in a same try catch block - but then it's difficult to differentiate between what error has been thrown.\n   Also this usually leads to a lot of code inside a try block and the catch clause acts more like \"catch anything\".\n2. Use nested try catch blocks - but this hurts readability and forces you into the\n   [callback hell pattern](http://callbackhell.com/).\n\n### Consistent throwing of an `Error` instance\n\nJavaScript supports throwing any expression, not just `Error` instances. This is also a reason why TypeScript infers the\nerror as `unknown` or `any` (see:\n[useUnknownInCatchVariables](https://www.typescriptlang.org/tsconfig#useUnknownInCatchVariables)).\n\nThe error response from `go` and `goSync` always return an instance of the `Error` class. Of course, throwing custom\nerrors (derived from `Error`) is supported.\n\n### Intentionally limited feature set\n\nThe go utils by design offer only very basic timeout and retry capabilities as these are often application specific and\ncould quickly result in bloated configuration. If you are looking for more complex features, consider using one of the\nalternatives, e.g. https://github.com/lifeomic/attempt\n\n## Limitations\n\nThere is a limitation when using class functions due to how javascript\n[this](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/this) works.\n\n```ts\nclass MyClass {\n  constructor() {}\n  get() {\n    return this._get();\n  }\n  _get() {\n    return '123';\n  }\n}\n\nconst myClass = new MyClass();\nconst resWorks = goSync(() => myClass.get()); // This works\n// However, seeing the line above it may be tempting to rewrite it to\nconst resFails = goSync(myClass.get); // This doesn't work\n```\n\nThe problem is that the `this` keyword is determined by how a function is called and in the second example, the `this`\ninside the `get` function is `undefined` which makes the `this._get()` throw an error.\n\n## Developer documentation\n\n### Release\n\nTo release a new version follow these steps:\n\n1. `yarn && yarn build`\n2. `yarn version` and choose the version to be released\n3. `yarn publish --access public`\n4. `git push --follow-tags`\n","readmeFilename":"README.md"}