{
  "_id": "rust-result",
  "maintainers": [
    {
      "name": "mmalecki",
      "email": "me@mmalecki.com"
    },
    {
      "name": "raynos",
      "email": "raynos2@gmail.com"
    }
  ],
  "dist-tags": {
    "latest": "1.0.0"
  },
  "author": {
    "name": "Maciej Małecki",
    "email": "me@mmalecki.com"
  },
  "_rev": "8-7fd31ec1cc45bb2f86fc06fdd45588a0",
  "description": "Mimic Rust's `std::result`",
  "readme": "# rust-result.js\n\nMimic Rust's [`std::result`][result].\n\n## Installation\n\n```sh\nnpm install rust-result\n```\n\n## Usage\n\n```js\nvar fs = require('fs');\nvar Result = require('./');\n\n\n// If you want async just get a promise or something.\nvar readFile = function (path, encoding) {\n  try {\n    return Result.Ok(fs.readFileSync(path, encoding))\n  }\n  catch (ex) {\n    return Result.Err(ex)\n  }\n}\n\nvar result = readFile(__filename);\nvar v, err;\n\nif (Result.isOk(result)) {\n  v = Result.Ok(result);\n  console.log('got ' + v.length + ' bytes')\n}\nelse if (Result.isErr(result)) {\n  err = Result.Err(result);\n  console.error('oops!', err.message)\n}\n\nresult = readFile(__filename + 'I do not exist')\nif (Result.isOk(result)) {\n  v = Result.Ok(result)\n  console.log('got ' + v.length + ' bytes')\n}\nelse if (Result.isErr(result)) {\n  err = Result.Err(result)\n  console.error('oops!', err.message)\n}\n\n```\n\n## Documentation\n\n```jsig\ntype OkResult<T> : {\n  v: T\n}\ntype ErrResult<E <: Error> : {\n  err: E\n}\n\nrust-result : {\n  Ok: ((T) => OkResult<T>) |\n    ((OkResult<T>) => T) |\n    ((ErrResult<E>) => void),\n  isOk: ((OkResult<T>) => true) |\n    ((ErrResult<E>) => false)\n  Err: ((E <: Error) => ErrResult<E>) |\n    ((ErrResult<E>) => E) |\n    ((OkResult<T>) => void),\n  isErr: ((ErrResult<E>) => true) |\n    ((OkResult<T>) => false)\n}\n```\n\n### `Result.Ok`\n\nThe `Result.Ok` function is overloaded to do one of two things.\n  It can create a new `Ok` instance or it can check whether\n  the argument is an instance of `Ok`\n\nIf you call `Result.Ok` with a plain value it will return an\n  instance of `Ok` that boxes your plain value.\n\nIf you call `Result.Ok` with either an `Err` or an `Ok` instance\n  then it will return `undefined` for the `Err` and return the\n  value boxed in the `Ok`\n\n### `Result.isOk`\n\nThe `Result.isOk` function just checks whether the argument\n  is an instance of `Ok`.\n\nThis predicate function returns true if you pass it an `Ok` and\n  returns false if you pass it an `Err`\n\n### `Result.Err`\n\nThe `Result.Err` function is overloaded to do one of two things.\n  It can create a new `Err` instance or it can check whether\n  the argument is an instance of `Err`\n\nIf you call `Result.Err` with a plain error it will return an\n  instance of `Err` that boxes your plain error.\n\nIf you call `Result.Err` with either an `Err` or an `Ok` instance\n  then it will return `undefined` for the `Ok` and return the\n  value err in the `Err`\n\n### `Result.isErr`\n\nThe `Result.isErr` function just checks whether the argument\n  is an instance of `Err`.\n\nThis predicate function returns true if you pass it an `Err` and\n  returns false if you pass it an `Ok`\n\n## MIT Licenced.\n\n  [result]: http://doc.rust-lang.org/std/result/\n",
  "repository": {
    "type": "git",
    "url": "git://github.com/mmalecki/rust-result.js.git"
  },
  "users": {
    "ierceg": true
  },
  "license": "MIT",
  "bugs": {
    "url": "https://github.com/mmalecki/rust-result.js/issues"
  },
  "versions": {
    "0.1.0": {
      "name": "rust-result",
      "version": "0.1.0",
      "author": {
        "name": "Maciej Małecki",
        "email": "me@mmalecki.com"
      },
      "description": "Mimic Rust's `std::result`",
      "license": "MIT",
      "gitHead": "8ed4b27e95e5ab2bc7d5b2d57c4b175885a6f083",
      "_id": "rust-result@0.1.0",
      "scripts": {},
      "_shasum": "905d907daf1b0d22ed0c0e15e02db9dac282837f",
      "_from": ".",
      "_npmVersion": "2.1.1",
      "_nodeVersion": "0.10.32",
      "_npmUser": {
        "name": "mmalecki",
        "email": "me@mmalecki.com"
      },
      "maintainers": [
        {
          "name": "mmalecki",
          "email": "me@mmalecki.com"
        }
      ],
      "dist": {
        "shasum": "905d907daf1b0d22ed0c0e15e02db9dac282837f",
        "tarball": "https://archive.ito.gov.ir/npm/_packages/rust-result/-/rust-result-0.1.0.tgz",
        "integrity": "sha512-i9h1cSUUsW0XDAg0uwzOnm7Dw5JoG0p8Tc3Bro/Xz/K+ZZhP9EjmwGOlSEPzknO96co34ghtOAhVhHhJJj/Blw==",
        "signatures": [
          {
            "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
            "sig": "MEUCIQDKuVLHID+ohFGxJNGSr0z9DKJlf5dFRw24yZzeJSPJtgIgHy5CEKLU8xx2mMdJ7Q4dX6UpssGsrfI9OHKQls2+rBs="
          }
        ]
      }
    },
    "1.0.0": {
      "name": "rust-result",
      "version": "1.0.0",
      "author": {
        "name": "Maciej Małecki",
        "email": "me@mmalecki.com"
      },
      "description": "Mimic Rust's `std::result`",
      "main": "index",
      "homepage": "https://github.com/mmalecki/rust-result.js",
      "repository": {
        "type": "git",
        "url": "git://github.com/mmalecki/rust-result.js.git"
      },
      "bugs": {
        "url": "https://github.com/mmalecki/rust-result.js/issues"
      },
      "scripts": {
        "test": "node test.js",
        "cover": "istanbul cover --print detail --report html test.js",
        "view-cover": "istanbul report html && opn ./coverage/index.html"
      },
      "license": "MIT",
      "devDependencies": {
        "istanbul": "^0.3.5",
        "opn": "^1.0.0",
        "tape": "^3.0.1"
      },
      "dependencies": {
        "individual": "^2.0.0"
      },
      "gitHead": "98a203341cfd6847ba9373bb9d1fa665eae71a72",
      "_id": "rust-result@1.0.0",
      "_shasum": "34c75b2e6dc39fe5875e5bdec85b5e0f91536f72",
      "_from": ".",
      "_npmVersion": "2.1.12",
      "_nodeVersion": "0.10.33",
      "_npmUser": {
        "name": "mmalecki",
        "email": "me@mmalecki.com"
      },
      "maintainers": [
        {
          "name": "mmalecki",
          "email": "me@mmalecki.com"
        }
      ],
      "dist": {
        "shasum": "34c75b2e6dc39fe5875e5bdec85b5e0f91536f72",
        "tarball": "https://archive.ito.gov.ir/npm/_packages/rust-result/-/rust-result-1.0.0.tgz",
        "integrity": "sha512-6cJzSBU+J/RJCF063onnQf0cDUOHs9uZI1oroSGnHOph+CQTIJ5Pp2hK5kEQq1+7yE/EEWfulSNXAQ2jikPthA==",
        "signatures": [
          {
            "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
            "sig": "MEUCIADwMJ40B2x7W48jmYwrmYw2+sJ4ywm/4n6fsvKR48UnAiEA0LHdYBTDMZ0LSJiyhTbCMInEuvw5ScuT1qfEkhXz2tc="
          }
        ]
      }
    }
  },
  "name": "rust-result",
  "time": {
    "modified": "2026-05-21T22:06:21.137Z",
    "created": "2014-10-08T20:11:40.474Z",
    "0.1.0": "2014-10-08T20:11:40.474Z",
    "1.0.0": "2014-12-17T11:59:49.690Z"
  },
  "readmeFilename": "README.md",
  "homepage": "https://github.com/mmalecki/rust-result.js"
}