{"_id":"promise-try","_rev":"95243","name":"promise-try","description":"wraps a synchronously executing function and returns a promise","dist-tags":{"latest":"1.0.1"},"maintainers":[{"name":"wbinnssmith","email":"wbinnssmith@gmail.com"}],"time":{"modified":"2021-06-03T10:31:45.000Z","created":"2015-09-19T05:29:06.044Z","1.0.1":"2015-09-19T05:29:06.044Z"},"users":{},"author":{"name":"Will Binns-Smith","email":"wbinnssmith@gmail.com"},"repository":{"type":"git","url":"git+https://github.com/wbinnssmith/promise-try.git"},"versions":{"1.0.1":{"name":"promise-try","version":"1.0.1","description":"wraps a synchronously executing function and returns a promise","repository":{"type":"git","url":"git+https://github.com/wbinnssmith/promise-try.git"},"main":"index.js","scripts":{"test":"semistandard && node test.js"},"keywords":["promise"],"author":{"name":"Will Binns-Smith","email":"wbinnssmith@gmail.com"},"license":"MIT","devDependencies":{"blue-tape":"^0.1.10","pinkie":"^1.0.0","semistandard":"^7.0.2"},"gitHead":"4ddd75a6c6f1fd8233d0b6ce3ba3fdd88713eca4","bugs":{"url":"https://github.com/wbinnssmith/promise-try/issues"},"homepage":"https://github.com/wbinnssmith/promise-try#readme","_id":"promise-try@1.0.1","_shasum":"7b20b38ce23400bd09dd7ebbbe9f1d0a4a34a248","_from":".","_npmVersion":"3.3.4","_nodeVersion":"4.0.0","_npmUser":{"name":"wbinnssmith","email":"wbinnssmith@gmail.com"},"dist":{"shasum":"7b20b38ce23400bd09dd7ebbbe9f1d0a4a34a248","size":2028,"noattachment":false,"key":"/promise-try/-/promise-try-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/promise-try/download/promise-try-1.0.1.tgz"},"maintainers":[{"name":"wbinnssmith","email":"wbinnssmith@gmail.com"}],"directories":{},"publish_time":1442640546044,"_cnpm_publish_time":1442640546044,"_hasShrinkwrap":false}},"readme":"# promise-try\n\nWraps a synchronously executing function and returns a promise that resolves to its return value and rejects its exceptions. API-compatible with [Bluebird](https://github.com/petkaantonov/bluebird)'s `Promise.try`.\n\nAccepts an alternate Promise implementation as input if the environment doesn't natively support them.\n\nThis module is meant to be a convenient standalone implementation of a Promise utility, but it doesn't provide an alternate Promise constructor and is less than 500 bytes minified and gzipped.\n\n## API\n\n```js\nfunction promiseTry(fn, args, ctx, Promise)\n```\n\n`fn` - a synchronously executed function that may return or throw synchronously. This will be wrapped and returned as a promise.\n\n`args` - arguments to applied to the passed function. If not an array, it will be passed as a single argument to the function. If an array, it will be spread across the function's parameters.\n\n<small>I personally don't like this API since one could never achieve passing the function a single argument that is an array, but this is here for compatibility with bluebird. Instead, one could just use something like `.bind(null, [1, 2, 3])` when passing the function.</small>\n\n`ctx` - the context (`this`) to be used when the function is executed.\n\n<small>Again, one could just use `.bind(ctx)` on the original function</small>\n\n`Promise` an alternate Promise implementation to use (perhaps if a global one doesn't exist)\n","_attachments":{},"homepage":"https://github.com/wbinnssmith/promise-try#readme","bugs":{"url":"https://github.com/wbinnssmith/promise-try/issues"},"license":"MIT"}