{"_id":"@adaptive-ds/result","_rev":"6-22e634e0a67bf04fd8f11aae3bddf776","name":"@adaptive-ds/result","dist-tags":{"latest":"0.6.0"},"versions":{"0.1.0":{"name":"@adaptive-ds/result","version":"0.1.0","keywords":["typescript","result","error-handling","either","functional-programming"],"license":"MIT","_id":"@adaptive-ds/result@0.1.0","maintainers":[{"name":"david1gp","email":"david1gruppenplan@gmail.com"}],"homepage":"https://github.com/david1gp/result","bugs":{"url":"https://github.com/david1gp/result/issues"},"dist":{"shasum":"6be527273c4dead6d7895dc1749a34cdde458754","tarball":"https://registry.npmjs.org/@adaptive-ds/result/-/result-0.1.0.tgz","fileCount":43,"integrity":"sha512-xpOZ95FB02jNW0+meDwY5dBfWnBH7U1i3ZSeDPXPSMIjR5Wr1N/o4vEM2SQ387ymPngiucKnVZTnsYjMKPtP0A==","signatures":[{"sig":"MEYCIQCtgwEAG9ReNHXABhTSNL0/5Jj5BZ/N1GStwyNBwPznTQIhAOHfmCjSa5I8ZOZ062iv1I2kUW6dt+8h9U+SwmwhQb2h","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":16028},"type":"module","exports":{"./*":"./dist/*"},"gitHead":"2ad8bc10cc62f577ebfcaaa9f036531da407a64a","private":false,"scripts":{"test":"bun test","build":"rm -rf ./dist && bun tsc -p ./tsconfig.lib.json","clean":"rm -rf ./dist","reset":"rm -rf ./node_modules","test:w":"bun test --watch","update":"bun update","release":"bash ./ops/release.sh","update:commit":"bun update && git add package.json && bun run tsc && git commit -m \"chore(deps): update dependencies\" && git push"},"_npmUser":{"name":"david1gp","email":"david1gruppenplan@gmail.com"},"prettier":{"semi":false,"printWidth":120,"trailingComma":"all"},"repository":{"url":"git+https://github.com/david1gp/result.git","type":"git"},"_npmVersion":"10.9.4","description":"A simple, type-safe Result type for TypeScript. Handle errors gracefully without try-catch soup.","directories":{},"_nodeVersion":"22.21.1","_hasShrinkwrap":false,"devDependencies":{"@types/bun":"^1.3.0"},"peerDependencies":{"typescript":"^5"},"_npmOperationalInternal":{"tmp":"tmp/result_0.1.0_1773496961688_0.7134573232860506","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"name":"@adaptive-ds/result","version":"0.2.0","keywords":["typescript","result","error-handling","either","functional-programming"],"license":"MIT","_id":"@adaptive-ds/result@0.2.0","maintainers":[{"name":"david1gp","email":"david1gruppenplan@gmail.com"}],"homepage":"https://github.com/david1gp/result","bugs":{"url":"https://github.com/david1gp/result/issues"},"dist":{"shasum":"b8ea7fb8353a314d9fcc95b8a21402e5869421aa","tarball":"https://registry.npmjs.org/@adaptive-ds/result/-/result-0.2.0.tgz","fileCount":43,"integrity":"sha512-7qKJDnKc5Fd9pg7lWOGVvHQPtlLNcu1vlTIlG7HLY57PgfnP0yPLBY/x0/QQ/u29uxDRhnTLmDyGO+Gnhdvzkg==","signatures":[{"sig":"MEQCIGjope74ZM5uektQVirLywCUgjtQP2AQldopvgNIWDfHAiABdY/XAZOolIikPNqKjgpQbqwMXvdZzLnJezjt4qqeTw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@adaptive-ds%2fresult@0.2.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":16028},"type":"module","exports":{"./*":"./dist/*"},"gitHead":"f566f2ffb0e7b3c48fb8f606c17e66133c76bc26","private":false,"scripts":{"test":"bun test","build":"rm -rf ./dist && bun tsc -p ./tsconfig.lib.json","clean":"rm -rf ./dist","reset":"rm -rf ./node_modules","test:w":"bun test --watch","update":"bun update","release":"bash ./ops/release.sh","update:commit":"bun update && git add package.json && bun run tsc && git commit -m \"chore(deps): update dependencies\" && git push"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:75a96360-29fd-4584-b74c-e1e62de6b2a2"}},"prettier":{"semi":false,"printWidth":120,"trailingComma":"all"},"repository":{"url":"git+https://github.com/david1gp/result.git","type":"git"},"_npmVersion":"11.11.1","description":"A simple, type-safe Result type for TypeScript. Handle errors gracefully without try-catch soup.","directories":{},"_nodeVersion":"20.20.1","_hasShrinkwrap":false,"devDependencies":{"@types/bun":"^1.3.0"},"peerDependencies":{"typescript":"^5"},"_npmOperationalInternal":{"tmp":"tmp/result_0.2.0_1773497129798_0.6366429362538728","host":"s3://npm-registry-packages-npm-production"}},"0.3.0":{"name":"@adaptive-ds/result","version":"0.3.0","keywords":["typescript","result","error-handling","either","functional-programming"],"license":"MIT","_id":"@adaptive-ds/result@0.3.0","maintainers":[{"name":"david1gp","email":"david1gruppenplan@gmail.com"}],"homepage":"https://github.com/david1gp/result","bugs":{"url":"https://github.com/david1gp/result/issues"},"dist":{"shasum":"2ed48fa624e7a2d3f85a7c8e9db41cade1e862b7","tarball":"https://registry.npmjs.org/@adaptive-ds/result/-/result-0.3.0.tgz","fileCount":79,"integrity":"sha512-mC78YczH8gPpe5ImcJ6JYEob44jtBr0J0Ifc3ynuVQLrp07ixFfKDs2Fd89hmzqlJ6Xba+StsdjBdSCYWzHaRg==","signatures":[{"sig":"MEYCIQC0J/iuioGnrWTYIAsHlZczEkSLoLHmnMRq968vX57EgwIhAIeeb40gvq0cnxXJhft0Nz5+J4yV6dnkOQ7T8gHkR0qK","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@adaptive-ds%2fresult@0.3.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":26400},"type":"module","exports":{"./*":"./dist/*"},"gitHead":"07d964e1587a420de47b2d277300079923d26630","private":false,"scripts":{"test":"bun test","build":"rm -rf ./dist && bun tsc -p ./tsconfig.lib.json","clean":"rm -rf ./dist","reset":"rm -rf ./node_modules","test:w":"bun test --watch","update":"bun update","release":"bash ./ops/release.sh","update:commit":"bun update && git add package.json && bun run tsc && git commit -m \"chore(deps): update dependencies\" && git push"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:75a96360-29fd-4584-b74c-e1e62de6b2a2"}},"prettier":{"semi":false,"printWidth":120,"trailingComma":"all"},"repository":{"url":"git+https://github.com/david1gp/result.git","type":"git"},"_npmVersion":"11.11.1","description":"A simple, type-safe Result type for TypeScript. Handle errors gracefully without try-catch soup.","directories":{},"_nodeVersion":"20.20.1","_hasShrinkwrap":false,"devDependencies":{"@types/bun":"^1.3.10","typescript":"^5.9.3"},"peerDependencies":{"valibot":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/result_0.3.0_1773551811890_0.1740190522490761","host":"s3://npm-registry-packages-npm-production"}},"0.4.0":{"name":"@adaptive-ds/result","version":"0.4.0","keywords":["typescript","result","error-handling","either","functional-programming"],"license":"MIT","_id":"@adaptive-ds/result@0.4.0","maintainers":[{"name":"david1gp","email":"david1gruppenplan@gmail.com"}],"homepage":"https://github.com/david1gp/result","bugs":{"url":"https://github.com/david1gp/result/issues"},"dist":{"shasum":"fedfb3d0409b0b6d0584e225c52c062461625035","tarball":"https://registry.npmjs.org/@adaptive-ds/result/-/result-0.4.0.tgz","fileCount":79,"integrity":"sha512-swE5jNToqrmnOo/WR/6UZSUe9C0RmgXVxkvnK2bCsnQdBTQIJ6qMGz73bWZcJERsL8rQWWcC5ULqWk40Rz0uSw==","signatures":[{"sig":"MEQCIAL0VZnDCsjJblNu+ILgacOYx6jKL+vkN0Z9VE2jib0MAiAoj0/4V6BTWNjuTIxs5weySoQuCJrQVSu2IxXoERgI6w==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@adaptive-ds%2fresult@0.4.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":26455},"main":"dist/index.js","type":"module","types":"./dist/index.d.ts","exports":{".":"./dist/index.js","./*":"./dist/*"},"gitHead":"ff929a01280865706a7a85cd80475e6a051bd2ab","private":false,"scripts":{"test":"bun test","build":"rm -rf ./dist && bun tsc -p ./tsconfig.lib.json","clean":"rm -rf ./dist","reset":"rm -rf ./node_modules","test:w":"bun test --watch","update":"bun update","release":"bash ./ops/release.sh","update:commit":"bun update && git add package.json && bun run tsc && git commit -m \"chore(deps): update dependencies\" && git push"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:75a96360-29fd-4584-b74c-e1e62de6b2a2"}},"prettier":{"semi":false,"printWidth":120,"trailingComma":"all"},"repository":{"url":"git+https://github.com/david1gp/result.git","type":"git"},"_npmVersion":"11.11.1","description":"A simple, type-safe Result type for TypeScript. Handle errors gracefully without try-catch soup.","directories":{},"_nodeVersion":"20.20.1","_hasShrinkwrap":false,"devDependencies":{"@types/bun":"^1.3.10","typescript":"^5.9.3"},"peerDependencies":{"valibot":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/result_0.4.0_1773617957897_0.19975313040300913","host":"s3://npm-registry-packages-npm-production"}},"0.5.0":{"name":"@adaptive-ds/result","version":"0.5.0","keywords":["typescript","result","error-handling","either","functional-programming"],"license":"MIT","_id":"@adaptive-ds/result@0.5.0","maintainers":[{"name":"david1gp","email":"david1gruppenplan@gmail.com"}],"homepage":"https://github.com/david1gp/result","bugs":{"url":"https://github.com/david1gp/result/issues"},"dist":{"shasum":"af8933a03090c4825a58ef1fb728bc7ec1d2abc9","tarball":"https://registry.npmjs.org/@adaptive-ds/result/-/result-0.5.0.tgz","fileCount":79,"integrity":"sha512-jHdlSErbCUEBSCryVhSDe33waQpK/vtGNxPWBRnwCZgG+0kjjDWX9OMTiI6PJ+H9giTbCbKLjM2z6Mao1GfY/w==","signatures":[{"sig":"MEUCIQDHdBp0dUmsqUPjzzYwuTIbmwmWwEH8TeLhXtqIAoND3gIgIKrByBCT3T/5aewV3idkhKvhgOx7YZxheeH549ydAoY=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@adaptive-ds%2fresult@0.5.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":26797},"main":"dist/index.js","type":"module","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./*.js":{"types":"./dist/*.d.ts","import":"./dist/*.js"}},"gitHead":"16ca54145a53ea0638b83f7e9f4feb9be152fa79","private":false,"scripts":{"test":"bun test","build":"rm -rf ./dist && bun tsc -p ./tsconfig.lib.json","clean":"rm -rf ./dist","reset":"rm -rf ./node_modules","test:w":"bun test --watch","update":"bun update","release":"bash ./ops/release.sh","update:commit":"bun update && git add package.json && bun run tsc && git commit -m \"chore(deps): update dependencies\" && git push"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:75a96360-29fd-4584-b74c-e1e62de6b2a2"}},"prettier":{"semi":false,"printWidth":120,"trailingComma":"all"},"repository":{"url":"git+https://github.com/david1gp/result.git","type":"git"},"_npmVersion":"11.12.0","description":"A simple, type-safe Result type for TypeScript. Handle errors gracefully without try-catch soup.","directories":{},"_nodeVersion":"20.20.1","_hasShrinkwrap":false,"devDependencies":{"@types/bun":"^1.3.10","typescript":"^5.9.3"},"peerDependencies":{"valibot":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/result_0.5.0_1774165860750_0.31021218667798967","host":"s3://npm-registry-packages-npm-production"}},"0.6.0":{"name":"@adaptive-ds/result","version":"0.6.0","scripts":{"build":"rm -rf ./dist && bun tsc -p ./tsconfig.lib.json","test":"bun test","test:w":"bun test --watch","release":"bash ./ops/release.sh","update":"bun update","update:commit":"bun update && git add package.json && bun run tsc && git commit -m \"chore(deps): update dependencies\" && git push","clean":"rm -rf ./dist","reset":"rm -rf ./node_modules"},"peerDependencies":{"valibot":"^1.2.0"},"devDependencies":{"@types/bun":"^1.3.13","typescript":"^6.0.3"},"prettier":{"semi":false,"printWidth":120,"trailingComma":"all"},"type":"module","main":"dist/index.js","private":false,"license":"MIT","description":"A simple, type-safe Result type for TypeScript. Handle errors gracefully without try-catch soup.","keywords":["typescript","result","error-handling","either","functional-programming"],"homepage":"https://github.com/david1gp/result","repository":{"type":"git","url":"git+https://github.com/david1gp/result.git"},"bugs":{"url":"https://github.com/david1gp/result/issues"},"types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./*.js":{"types":"./dist/*.d.ts","import":"./dist/*.js"}},"gitHead":"a306092d52db500308864a253f8ddc797f0fb838","_id":"@adaptive-ds/result@0.6.0","_nodeVersion":"24.18.0","_npmVersion":"11.18.0","dist":{"integrity":"sha512-4N70Kfnyya4NG5AXgdtHlT7gkWbnIEElst+NV2D7vJkxfNeZvd5ustkByTQtjfWn5F6UiJBef1S1g4Fi9mrzNA==","shasum":"d00bd3e86ed3100dd27b8b37a8f3376a60bfed99","tarball":"https://registry.npmjs.org/@adaptive-ds/result/-/result-0.6.0.tgz","fileCount":83,"unpackedSize":31309,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@adaptive-ds%2fresult@0.6.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIG3ssxjio+7AklKzQqSOLuYb6PbXqH7zogzQW1SaSOymAiB3ZIb62BYDvLQnNL8WxzcgeT2qbI6Ns5iWvSfsMMziSA=="}]},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:75a96360-29fd-4584-b74c-e1e62de6b2a2"}},"directories":{},"maintainers":[{"name":"david1gp","email":"david1gruppenplan@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/result_0.6.0_1783059468077_0.6762015863065662"},"_hasShrinkwrap":false}},"time":{"created":"2026-03-14T14:02:41.313Z","modified":"2026-07-03T06:17:48.490Z","0.1.0":"2026-03-14T14:02:41.827Z","0.2.0":"2026-03-14T14:05:29.934Z","0.3.0":"2026-03-15T05:16:52.031Z","0.4.0":"2026-03-15T23:39:18.033Z","0.5.0":"2026-03-22T07:51:00.877Z","0.6.0":"2026-07-03T06:17:48.210Z"},"bugs":{"url":"https://github.com/david1gp/result/issues"},"license":"MIT","homepage":"https://github.com/david1gp/result","keywords":["typescript","result","error-handling","either","functional-programming"],"repository":{"type":"git","url":"git+https://github.com/david1gp/result.git"},"description":"A simple, type-safe Result type for TypeScript. Handle errors gracefully without try-catch soup.","maintainers":[{"name":"david1gp","email":"david1gruppenplan@gmail.com"}],"readme":"# @adaptive-ds/result\n\nStop letting errors crash your parties.\nHandle them gracefully with a simple, type-safe Result type that tells you exactly what went wrong and where.\n\n## Features\n\n- **Type-safe** - Full TypeScript inference, no more `any`\n- **Explicit errors** - Know exactly which operation failed and why\n- **No try-catch soup** - Clean, readable error handling\n- **Chainable** - Transform results with `resultMap`, `resultMapErr`\n- **Safe fetches** - Wrap `fetch` responses and validate JSON with Valibot schemas\n- **Lightweight** - Zero dependencies, tree-shakable\n\n## The Problem\n\n```typescript\n// Traditional error handling? No thanks.\nasync function fetchUser(id: string) {\n  try {\n    const user = await api.getUser(id)\n    return user\n  } catch (e) {\n    // Wait, was it a network error? Validation? Database?\n    console.log(e) // \"Something went wrong\" 😩\n    throw e // Re-throwing loses context\n  }\n}\n```\n\n## The Solution\n\n```typescript\nimport { createResult, createResultError, type PromiseResult } from \"@adaptive-ds/result\"\n\nasync function fetchUser(id: string): PromiseResult<User> {\n  const validation = validateId(id)\n  if (!validation.success) return createResultError(\"fetchUser\", \"Invalid ID\", validation.error)\n\n  try {\n    const user = await api.getUser(id)\n    return createResult(user)\n  } catch (e) {\n    return createResultError(\"fetchUser\", \"API failed\", e.message)\n  }\n}\n\n// Usage is explicit and safe\nconst result = await fetchUser(\"123\")\nif (!result.success) {\n  console.log(result.op, result.errorMessage) // Exactly what went wrong\n  return\n}\nconsole.log(result.data) // TypeScript knows this is User\n```\n\n## Installation\n\n```bash\nbun add @adaptive-ds/result\n# or\nnpm install @adaptive-ds/result\n```\n\n## Quick Start\n\n```typescript\nimport { createResult, createResultError, resultIsOk, resultMap } from \"@adaptive-ds/result\"\n\n// Create success\nconst ok = createResult({ name: \"Alice\" })\n// { success: true, data: { name: \"Alice\" } }\n\n// Create error\nconst err = createResultError(\"saveUser\", \"Email already taken\")\n// { success: false, op: \"saveUser\", errorMessage: \"Email already taken\" }\n\n// Type guard\nif (resultIsOk(ok)) {\n  console.log(ok.data) // TypeScript knows it's valid\n}\n\n// Transform data\nconst mapped = resultMap(ok, (user) => user.name.toUpperCase())\n```\n\n## API\n\n### Types\n\n- `ResultOk<T>` - Success state with data\n- `ResultErr` - Failure state with operation, message, optional code/data\n- `Result<T>` - Union of Ok and Err\n- `PromiseResult<T>` - Async Result\n\n### Functions\n\n- `createResult(data)` - Create a success result\n- `createError(op, message, data?)` - Create an error result\n- `createResultError(op, message, data?)` - Alias for createError\n- `createResultErrorCode(op, message, code)` - Create error with error code\n- `resultIsOk(r)` - Type guard for success\n- `resultIsErr(r)` - Type guard for failure\n- `resultGetOrElse(r, default)` - Get data or return default\n- `resultMap(r, fn)` - Transform data if success\n- `resultMapErr(r, fn)` - Transform error if failure\n- `fetchResult(op, input, init?, schema?)` - Fetch text or validate JSON into a Result\n\n### Fetch Result\n\n```typescript\nimport { fetchResult } from \"@adaptive-ds/result\"\nimport * as a from \"valibot\"\n\nconst userSchema = a.object({ id: a.string(), name: a.string() })\n\nconst result = await fetchResult(\"loadUser\", \"/api/user\", { method: \"GET\" }, userSchema)\nif (!result.success) return result\n\nconsole.log(result.data.name)\n```\n\n## License\n\nMIT\n","readmeFilename":"README.md"}