{"_id":"@asleepace/try","_rev":"7-8b875ce6f1609ce354ef9ed52275f887","name":"@asleepace/try","dist-tags":{"latest":"0.2.1"},"versions":{"0.1.0":{"name":"@asleepace/try","version":"0.1.0","author":{"name":"Colin Teahan"},"license":"MIT","_id":"@asleepace/try@0.1.0","maintainers":[{"name":"asleepace","email":"colin_teahan@yahoo.com"}],"dist":{"shasum":"d75be534002b945233dd63cfa32490e7e50c3aa5","tarball":"https://registry.npmjs.org/@asleepace/try/-/try-0.1.0.tgz","fileCount":4,"integrity":"sha512-iClZxBK7beL3MRfE9x/dwq+yrus2TkgZkND3IKt2LqED/QAIuk/ujoAPFzq553+KRQPWY/6v0bWh5YaD0cBKvQ==","signatures":[{"sig":"MEUCIDvKD87gL0CXwQDT9NA3U6DqsXCZwJct55Lkz/IUy3oxAiEArdgOz3I4082KtHBuWqJIkkGqEkWlz9yzrDGHY/OI/Zg=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":6784},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","source":"./src/index.ts","gitHead":"0b7fcb8841db7e32a569765b8068576477ca08bf","scripts":{"test":"bun test","build":"bun build ./src/index.ts --outdir ./dist --target node","npm:publish":"bun run npm publish --access=public","prepublishOnly":"bun run build","npm:publish:dry":"bun run npm publish --dry-run --access=public"},"_npmUser":{"name":"asleepace","email":"colin_teahan@yahoo.com"},"_npmVersion":"11.0.0","description":"TypeScript utilities for error handling.","directories":{},"_nodeVersion":"22.9.0","_hasShrinkwrap":false,"devDependencies":{"@types/bun":"latest"},"peerDependencies":{"typescript":"^5"},"_npmOperationalInternal":{"tmp":"tmp/try_0.1.0_1745515910481_0.5558126433614017","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@asleepace/try","version":"0.1.1","author":{"name":"Colin Teahan"},"license":"MIT","_id":"@asleepace/try@0.1.1","maintainers":[{"name":"asleepace","email":"colin_teahan@yahoo.com"}],"dist":{"shasum":"0a4247d2b7af935d741cb8f75fd9a677c145edac","tarball":"https://registry.npmjs.org/@asleepace/try/-/try-0.1.1.tgz","fileCount":11,"integrity":"sha512-vTY6Y4jPOiC0VDVFVmTxxOKQNWj2aG3lQMhAh8cEzrVCZwiScIGmCAwEgJds4xAZPGeEuDAxMPIuRBHIE9SqBw==","signatures":[{"sig":"MEUCIQCOdngAAfbKYUzEZk2yqK1tt7487DQpaQlrqEY1IGftyQIgaUgrXaUHAz5jMoGjyCWv7Y7DBian2lBJWDJZlaHSHhQ=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":12032},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","source":"./src/index.ts","gitHead":"bd8f583760df92144b387d33b2147ca149997806","scripts":{"test":"bun test","build":"bun run tsc && bun build ./src/index.ts --outdir ./dist --target node","npm:publish":"bun run npm publish --access=public","prepublishOnly":"bun run build","npm:publish:dry":"bun run npm publish --dry-run --access=public"},"_npmUser":{"name":"asleepace","email":"colin_teahan@yahoo.com"},"_npmVersion":"11.0.0","description":"TypeScript utilities for error handling.","directories":{},"_nodeVersion":"22.9.0","_hasShrinkwrap":false,"devDependencies":{"@types/bun":"latest"},"peerDependencies":{"typescript":"^5"},"_npmOperationalInternal":{"tmp":"tmp/try_0.1.1_1745516609083_0.13259424895966387","host":"s3://npm-registry-packages-npm-production"}},"0.1.2":{"name":"@asleepace/try","version":"0.1.2","author":{"name":"Colin Teahan"},"license":"MIT","_id":"@asleepace/try@0.1.2","maintainers":[{"name":"asleepace","email":"colin_teahan@yahoo.com"}],"dist":{"shasum":"08c4f8a098d74e02e9876e9f298c4a5ccf5dab31","tarball":"https://registry.npmjs.org/@asleepace/try/-/try-0.1.2.tgz","fileCount":11,"integrity":"sha512-wUizPHEef9719U7s5irBvKdepSPf/Sz0fqctpsiBbRps3qRusy6iW7aoUvZMWFymG2JI2RZxtVE5CrIW3au76A==","signatures":[{"sig":"MEUCIB5JY26IXWY+B8EeH8QqB8675BklpPZwYWzYqpbBZigvAiEAlAOCOZgckRHUB1BmHsttL/Te5htkKm6zEHOyG6CW7IY=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":12271},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","source":"./src/index.ts","gitHead":"226f7f9caf2e48c27bfcaa5d4a9dfbd4014d6eb4","scripts":{"test":"bun test","build":"bun run tsc && bun build ./src/index.ts --outdir ./dist --target node","npm:publish":"bun run npm publish --access=public","prepublishOnly":"bun run build","npm:publish:dry":"bun run npm publish --dry-run --access=public"},"_npmUser":{"name":"asleepace","email":"colin_teahan@yahoo.com"},"_npmVersion":"11.0.0","description":"TypeScript utilities for error handling.","directories":{},"_nodeVersion":"22.9.0","_hasShrinkwrap":false,"devDependencies":{"@types/bun":"latest"},"peerDependencies":{"typescript":"^5"},"_npmOperationalInternal":{"tmp":"tmp/try_0.1.2_1745544888083_0.7979304920903876","host":"s3://npm-registry-packages-npm-production"}},"0.1.3":{"name":"@asleepace/try","version":"0.1.3","keywords":["try","catch","helper","error","handling","utility","asleepace","isomorphic","ergonomic"],"author":{"name":"Colin Teahan"},"license":"MIT","_id":"@asleepace/try@0.1.3","maintainers":[{"name":"asleepace","email":"colin_teahan@yahoo.com"}],"dist":{"shasum":"5a6dac8b9c133ed1161a4e3173e2a95b9a9655c0","tarball":"https://registry.npmjs.org/@asleepace/try/-/try-0.1.3.tgz","fileCount":11,"integrity":"sha512-xGNycnay1k6zumbL66IRiz0+qauIkriemCtonNByv5TVe7pfyR8EuF+hCXdMtszKoXTWlnqQqyVH4M1WePbbyA==","signatures":[{"sig":"MEUCIGqhzJ0mQ140BOXi4dQB9V3E76ZhItbGujvIM/FfENG7AiEAzm/eoaKGYeeO5jWMYuYY+QaM1jiPv6I9EpkZA/7ep4c=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":12425},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","source":"./src/index.ts","gitHead":"a19fe1a5e84a9f11155ff2220989ec5defa9648f","scripts":{"test":"bun test","build":"bun run tsc && bun build ./src/index.ts --outdir ./dist --target node","npm:publish":"bun run npm publish --access=public","prepublishOnly":"bun run build","npm:publish:dry":"bun run npm publish --dry-run --access=public"},"_npmUser":{"name":"asleepace","email":"colin_teahan@yahoo.com"},"_npmVersion":"11.0.0","description":"TypeScript utilities for error handling.","directories":{},"_nodeVersion":"22.9.0","_hasShrinkwrap":false,"devDependencies":{"@types/bun":"latest"},"peerDependencies":{"typescript":"^5"},"_npmOperationalInternal":{"tmp":"tmp/try_0.1.3_1745545069915_0.09568248382394584","host":"s3://npm-registry-packages-npm-production"}},"0.1.4":{"name":"@asleepace/try","version":"0.1.4","keywords":["try","catch","helper","error","handling","utility","asleepace","isomorphic","ergonomic"],"author":{"name":"Colin Teahan"},"license":"MIT","_id":"@asleepace/try@0.1.4","maintainers":[{"name":"asleepace","email":"colin_teahan@yahoo.com"}],"dist":{"shasum":"ba1d249d4bc658016720acc94e2f0c020f7e369e","tarball":"https://registry.npmjs.org/@asleepace/try/-/try-0.1.4.tgz","fileCount":11,"integrity":"sha512-jj1VIIIayXPdpOgmS1L16xmW51bdU3Y1gYPl0Sy/qVvbnO5H/hXHXJFnWf6J5Mi9eHwz0VHvVU8IABt4E4ggwg==","signatures":[{"sig":"MEUCIBoPDgg4aqpgZWkWd5AS2CKt0YuUgjPPEX7BI4ot3wa3AiEA0NSxhTqCIzZeUlnO8oW9YccgcJS0zYc5MKQH0ZLuPzY=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":12610},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","source":"./src/index.ts","gitHead":"b927009174ee702b8870820733bbd92425b9744e","scripts":{"test":"bun test","build":"bun run tsc && bun build ./src/index.ts --outdir ./dist --target node","npm:patch":"bun run npm version patch","npm:publish":"bun run npm publish --access=public","prepublishOnly":"bun run build","npm:publish:dry":"bun run npm publish --dry-run --access=public"},"_npmUser":{"name":"asleepace","email":"colin_teahan@yahoo.com"},"_npmVersion":"11.0.0","description":"TypeScript utilities for error handling.","directories":{},"_nodeVersion":"22.9.0","_hasShrinkwrap":false,"devDependencies":{"@types/bun":"latest"},"peerDependencies":{"typescript":"^5"},"_npmOperationalInternal":{"tmp":"tmp/try_0.1.4_1745545975241_0.16356174242555288","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"name":"@asleepace/try","version":"0.2.0","keywords":["try","catch","helper","error","handling","utility","asleepace","isomorphic","ergonomic","vet","unwrap","result"],"author":{"name":"Colin Teahan"},"license":"MIT","_id":"@asleepace/try@0.2.0","maintainers":[{"name":"asleepace","email":"colin_teahan@yahoo.com"}],"dist":{"shasum":"033658c0874ecfe700dfca2a89c1582d16653f76","tarball":"https://registry.npmjs.org/@asleepace/try/-/try-0.2.0.tgz","fileCount":23,"integrity":"sha512-Zps6DSDh7FZZVDgtPwRXDc0sis+ytvMtq0cYnToWGdvPJK9xkiCzXpcN9ruIulN1RAk/ep91Vyv09nKhZjSvNg==","signatures":[{"sig":"MEQCICYLXvoqXub74TxwFLlWghQ6DV23wY8Y2NzfXWjkSLIEAiAFqcTidfDgLP+RbAjQD5O3dRn7bJr9G49HFsQ7a101zw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":34455},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","source":"./src/index.ts","gitHead":"4fa82d5ee87d152372d77bcddd399cae155c81f8","scripts":{"test":"bun test","build":"bun run tsc && bun build ./src/index.ts --outdir ./dist --target node","npm:patch":"bun run npm version patch","npm:publish":"bun run npm publish --access=public","prepublishOnly":"bun run build","npm:publish:dry":"bun run npm publish --dry-run --access=public"},"_npmUser":{"name":"asleepace","email":"colin_teahan@yahoo.com"},"_npmVersion":"11.0.0","description":"TypeScript utilities for error handling.","directories":{},"_nodeVersion":"22.9.0","_hasShrinkwrap":false,"devDependencies":{"@types/bun":"latest"},"peerDependencies":{"typescript":"^5"},"_npmOperationalInternal":{"tmp":"tmp/try_0.2.0_1745654021728_0.27487922846205226","host":"s3://npm-registry-packages-npm-production"}},"0.2.1":{"name":"@asleepace/try","version":"0.2.1","description":"TypeScript utilities for exception handling and errors-as-values.","keywords":["try","catch","helper","error","handling","utility","asleepace","isomorphic","ergonomic","vet","unwrap","result","exceptions"],"author":{"name":"Colin Teahan"},"license":"MIT","type":"module","source":"./src/index.ts","main":"./dist/index.js","module":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"build":"bun run tsc && bun build ./src/index.ts --outdir ./dist --target node","npm:publish:dry":"bun run npm publish --dry-run --access=public","npm:publish":"bun run npm publish --access=public","npm:patch":"bun run npm version patch","test":"bun test","prepublishOnly":"bun run build"},"devDependencies":{"@types/bun":"latest"},"peerDependencies":{"typescript":"^5"},"_id":"@asleepace/try@0.2.1","gitHead":"043e78fd1f1506e76d3cd7f54a6b4559e19ae176","_nodeVersion":"22.9.0","_npmVersion":"11.0.0","dist":{"integrity":"sha512-0lqcXCkrubACXhCkSaWiFEYnfIDodh8n/Ivr7N8i23EmmG9lucc7awzpBTGPWApqKefMbZx+PSHwnJKDiYbSlA==","shasum":"a3f76333ac3ec54ce9074efbf51933f84896a373","tarball":"https://registry.npmjs.org/@asleepace/try/-/try-0.2.1.tgz","fileCount":7,"unpackedSize":22918,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIBEGV9g+KBCpO4gLYdCJVVvUtlqpB1kx1BgSQguHKvpDAiAdGk/TD0zMCiky1FMYoDA6bbph4U6BTkimOqRp0cWbCg=="}]},"_npmUser":{"name":"asleepace","email":"colin_teahan@yahoo.com"},"directories":{},"maintainers":[{"name":"asleepace","email":"colin_teahan@yahoo.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/try_0.2.1_1745717132141_0.10888016934363853"},"_hasShrinkwrap":false}},"time":{"created":"2025-04-24T17:31:50.361Z","modified":"2025-04-27T01:25:32.474Z","0.1.0":"2025-04-24T17:31:50.658Z","0.1.1":"2025-04-24T17:43:29.249Z","0.1.2":"2025-04-25T01:34:48.368Z","0.1.3":"2025-04-25T01:37:50.109Z","0.1.4":"2025-04-25T01:52:55.428Z","0.2.0":"2025-04-26T07:53:41.937Z","0.2.1":"2025-04-27T01:25:32.313Z"},"author":{"name":"Colin Teahan"},"license":"MIT","keywords":["try","catch","helper","error","handling","utility","asleepace","isomorphic","ergonomic","vet","unwrap","result","exceptions"],"description":"TypeScript utilities for exception handling and errors-as-values.","maintainers":[{"name":"asleepace","email":"colin_teahan@yahoo.com"}],"readme":"# Try\n\n![try-catch-cover](https://github.com/user-attachments/assets/043b452a-56c5-4697-aa79-c5a059c5f6c6)\n\nType-safe error handling primitives for modern JavaScript & TypeScript projects.\n\n## Installation\n\nUsing npm:\n\n```bash\nnpm install @asleepace/try\n```\n\nUsing Yarn:\n\n```bash\nyarn add @asleepace/try\n```\n\nUsing Bun:\n\n```bash\nbun add @asleepace/try\n```\n\n## Quick Start\n\nThe goal of this package is to provide concise, type-safe and easy to use tools for handling exceptions.\n\n```ts\nimport { Try } from '@asleepace/try'\n\nconst [url, error] = Try.catch(() => new URL(userInput))\n\nif (error) return console.warn(error.message)\n\nconst [response, networkError] = await Try.catch(() => fetch(url))\nconst [jsonData, parsingError] = await Try.catch(() => response!.json())\n\nif (parsingError) return console.warn(parsingError.message)\n\nreturn jsonData.userName\n```\n\n## Result Type\n\nThe `Try.catch(fn)` utility returns a special result type `Res` which is a class that extends a result tuple. The `Res` class provides\nsome helpful utilities for handling results:\n\n```ts\nconst result = await Try.catch(() => response.json())\n\n// includes powerful type-guards\nif (result.isErr()) return console.warn(result.error.message)\n\n// and convenience methods\nconst json = result.unwrap()\n\n// supports array destructuring\nconst [user, error] = await Try.catch(async () => {\n  const profileUrl = new URL(json.user!.profile)\n  return fetch(profileUrl).then((res) => res.json())\n})\n\nif (!error) {\n  console.log(`Hello, ${user.name}!`)\n} else {\n  console.warn(error.message)\n}\n```\n\nThe can be used in conjunction with the array destructuring syntax, which can help if you are only interested in the value or error.\n\n```ts\nconst result = await Try.catch(() =>\n  fetch('https://api.users.com/me')\n    .then((res) => res.json())\n    .then((usr) => usr as User)\n)\n\nconsole.log(result.value) // User  | undefined\nconsole.log(result.error) // Error | undefined\n\n// automatically narrows the type for you!\n\nif (result.isOk()) {\n  const user = result.value // User!\n} else {\n  const fail = result.error // Error!\n}\n\n// in some cases you may just want the value or to throw again:\n\nconst user = result.unwrap() // User | never\n\n// or you may want the value or a fallback:\n\nconst user = result.unwrapOr(cachedUser) // User\n```\n\n## API\n\n```ts\nTry.catch<T>(fn: () => Promise<T>): Promise<[T, undefined] | [undefined, Error]>\n```\n\nExecutes a function and returns a tuple containing either:\n\n- `[value, undefined]` if the function executes successfully\n- `[undefined, error]` if the function throws an error\n\nWorks with both synchronous and asynchronous functions, automatically returning a Promise for async operations.\n\n## Shorthand\n\nThis package also exports a shorthand utility called **vet** which stands for _value / error tuple_ and provides a more concise way to interact with this api.\n\n```ts\n// Add more examples of the VET shorthand\nimport { vet } from '@asleepace/try'\n\n// Simple usage\nconst [value] = vet(() => JSON.parse(data))\n\n// Only get the error\nconst [, error] = vet(() => JSON.parse(data))\n\n// With TypeScript generics for better type inference\nconst [user] = vet<User>(() => getUserFromAPI())\n```\n\n## Benefits\n\n- **No Try/Catch Blocks**: Clean, readable code without nested try/catch structures\n- **Type Safety**: Full TypeScript support with proper type inference\n- **Consistent Pattern**: Uniform error handling for both sync and async code\n- **Zero Dependencies**: Lightweight and dependency-free\n- **Isomorphic**: Works in both browser and Node.js environments\n- **Powerful Results**: Type safe, tested and versatile result class\n\n## Testing\n\nThis package includes a comprehensive test suite. To run the tests:\n\n```bash\n# Clone the repository\ngit clone https://github.com/asleepace/try.git\ncd try\n\n# Install dependencies\nbun install\n\n# Build project & generate types\nbun run build\n\n# Run tests\nbun test\n```\n\n## Examples\n\n### Making Network Requests\n\n```ts\n// handle synchronous operations which can throw with ease...\nconst encoded = Try.catch(() => JSON.stringify(userInput))\n\nif (!encoded.ok) return encoded.error\n\nconst [response, networkError] = await Try.catch(() =>\n  fetch('https://api.com/create', {\n    method: 'POST',\n    body: encoded.value,\n  })\n)\n\nif (networkError) return networkError\n\nconst [user, jsonError] = await Try.catch(response.json)\n\nif (jsonError) return jsonError\n\nreturn user\n```\n\n### Error Handling in a React Component\n\n```tsx\nimport React, { useEffect, useState } from 'react'\nimport { Try } from '@asleepace/try'\n\nfunction UserProfile({ userId }) {\n  const [user, setUser] = useState(null)\n  const [loading, setLoading] = useState(true)\n  const [error, setError] = useState(null)\n\n  useEffect(() => {\n    async function loadUser() {\n      setLoading(true)\n\n      const [userData, fetchError] = await Try.catch(async () => {\n        const response = await fetch(`/api/users/${userId}`)\n        if (!response.ok) throw new Error(`HTTP error ${response.status}`)\n        return response.json()\n      })\n\n      setUser(userData)\n      setError(fetchError)\n      setLoading(false)\n    }\n\n    loadUser()\n  }, [userId])\n\n  if (loading) return <div>Loading...</div>\n  if (error) return <div>Error: {error.message}</div>\n\n  return (\n    <div>\n      <h1>{user.name}</h1>\n      <p>{user.email}</p>\n    </div>\n  )\n}\n```\n\n### Chaining Operations\n\n```ts\nimport { Try } from '@asleepace/try'\n\nasync function processData(rawData): object | undefined {\n  // Step 1: Parse the data\n  const [parsed, parseError] = Try.catch(() => JSON.parse(rawData))\n  if (parseError) return console.warn(parseError.message)\n\n  // Step 2: Transform the data\n  const [transformed, transformError] = Try.catch(() => {\n    return parsed.items.map((item) => ({\n      id: item.id,\n      name: item.name.toUpperCase(),\n      value: item.value * 2,\n    }))\n  })\n  if (transformError) return console.warn(transformError.message)\n\n  // Step 3: Save the data\n  const saveResult = await Try.catch(async () => {\n    const response = await fetch('/api/save', {\n      body: JSON.stringify(transformed),\n      method: 'POST',\n    })\n    return response.json()\n  })\n\n  if (saveResult.isErr()) return console.warn(saveResult.error)\n  return saveResult.unwrap()\n}\n```\n\n# Specification\n\n## Overview\n\nThe `Try.catch` utility provides a type-safe way to handle errors in both synchronous and asynchronous functions, returning a result tuple that contains either a value or an error, but never both.\n\n## Return Values\n\n- `Try.catch` always returns either a `ResultOk<T>` or `ResultError` type, which extends the tuple types `[T, undefined]` or `[undefined, Error]` respectively.\n- The returned object is guaranteed to have exactly two elements, with either index 0 or index 1 being undefined.\n- If the function completes successfully, index 0 will contain the return value and index 1 will be undefined.\n- If the function throws an error, index 0 will be undefined and index 1 will contain the error.\n\n## Error Handling\n\n- If a non-Error value is thrown (such as a string, number, or object), it will be automatically converted to an instance of the built-in `Error` class.\n- Thrown values that aren't already errors will first be coerced to strings and then used to construct a new `Error` instance.\n- If the function returns an `Error` object as its value (not thrown), it will be treated as a successful result with the `Error` as the value at index 0, not as an error case.\n\n## Properties and Methods\n\nThe returned result object includes several convenience properties and methods:\n\n- `.value`: Returns the value at index 0 (the success value) or undefined if an error occurred.\n- `.error`: Returns the error at index 1 or undefined if the operation was successful.\n- `.ok`: A boolean property that is `true` when `.error === undefined` and `false` otherwise.\n- `.unwrap()`: Returns the value if present, or throws the captured error if no value is present.\n- `.unwrapOr(fallback)`: Returns the value if present, or the provided fallback value if no value is present.\n- `.toString()`: Returns a string representation of the result, displaying either the successful value or the error message.\n\n## Type Safety\n\n- The returned result type correctly narrows in type-guard contexts:\n  - When checking `if (result.ok)`, TypeScript will narrow the type to `ResultOk<T>`.\n  - When checking `if (!result.ok)`, TypeScript will narrow the type to `ResultError`.\n- In `ResultOk<T>` contexts, `result.value` is typed as `T` and `result.error` is typed as `undefined`.\n- In `ResultError` contexts, `result.value` is typed as `undefined` and `result.error` is typed as `Error`.\n\n## Async Support\n\n- `Try.catch` supports both synchronous and asynchronous functions.\n- When passed a function that returns a Promise, `Try.catch` returns a Promise that resolves to a result tuple.\n- Rejected promises are captured and converted to error results, following the same rules as thrown errors.\n\n## Instanceof Support\n\n- The returned result object is an instance of `TryResultClass`, enabling `instanceof` checks.\n- This allows for easier type checking and integration with existing code patterns.\n\n# Changelog\n\n## 0.2.1\n\n- add `Res.ok(value)` and `Res.err(error)` initializers\n- add `isOk()` and `isErr()` type guards to result\n- move all code into `src/index.ts`\n- remove junks files and reduce package size\n- remove internal `Try.#handler` method\n- simplify `Try.catch` logic\n- simplify types\n\n## 0.2.0\n\n- add `vet(fn)` shorthand\n- add convenience methods\n- Update `Result` class\n- Update test suite\n\n## 0.14.0\n\n- Update `README.md`\n- Update `Try.catch` functionality\n\n## 0.13.0\n\n- Initial release\n\n## License\n\nMIT\n","readmeFilename":"README.md"}