{
  "_id": "@xmldom/is-dom-node",
  "maintainers": [
    {
      "name": "cjbarth",
      "email": "chrisjbarth@hotmail.com"
    }
  ],
  "keywords": [
    "dom",
    "node",
    "typescript",
    "narrow",
    "guard"
  ],
  "dist-tags": {
    "latest": "1.0.1"
  },
  "author": {
    "name": "Chris Barth",
    "email": "chrisjbarth@hotmail.com"
  },
  "_rev": "1-b26e05a2ee0afb307431a52844960f96",
  "description": "TypeScript helper functions to narrow the type of object to a Node descendant",
  "readme": "# is-dom-node\n\n![Build Status](https://img.shields.io/github/actions/workflow/status/xmldom/is-dom-node/ci.yml)\n![Code Coverage](https://img.shields.io/codecov/c/github/xmldom/is-dom-node)\n![NPM Version](https://img.shields.io/npm/v/@xmldom/is-dom-node)\n![License](https://img.shields.io/npm/l/@xmldom/is-dom-node)\n\n## Description\n\n`@xmldom/is-dom-node` is a versatile TypeScript library designed to provide robust utility functions for working with DOM nodes. Whether you're developing for the browser or dealing with XML in NodeJS, this library offers a comprehensive set of functions for checking and asserting various types of DOM nodes. It's particularly useful when working with NodeJS libraries like [xpath](https://www.npmjs.com/package/xpath) and [@xmldom/xmldom](https://www.npmjs.com/package/@xmldom/xmldom), as it can validate the objects returned by these libraries.\n\n## Installation\n\n```shell\nnpm install @xmldom/is-dom-node\n```\n\n## Usage\n\nImport the library and use it as follows:\n\n```javascript\nimport * as isDomNode from \"@xmldom/is-dom-node\";\n\nconst element = document.createElement(\"div\");\nconst result = isDomNode.isElementNode(element); // Output: true\n```\n\n### TypeScript Example\n\n```typescript\nimport * as isDomNode from \"@xmldom/is-dom-node\";\n\nfunction handleNode(node: Node) {\n  if (isDomNode.isElementNode(node)) {\n    // TypeScript now knows `node` is an Element\n    console.log(node.tagName);\n  } else if (isDomNode.isTextNode(node)) {\n    // TypeScript now knows `node` is a Text node\n    console.log(node.wholeText);\n  } else {\n    try {\n      // Assert that the node is a Comment node\n      isDomNode.assertIsCommentNode(node);\n      // TypeScript now knows `node` is a Comment node\n      console.log(node.nodeValue);\n    } catch (error) {\n      console.error(\"Node is not a Comment node:\", error);\n    }\n  }\n}\n```\n\n## API Overview\n\nThe API consists of two main types of functions:\n\n### `is...` Functions\n\nThese functions return a boolean value indicating whether the given object meets certain criteria:\n\n- `isNodeLike`: Checks if a given value resembles a DOM node.\n- `isArrayOfNodes`: Checks if the given value is an array of DOM nodes.\n- `isElementNode`, `isAttributeNode`, `isTextNode`, etc.: Check for specific types of DOM nodes.\n\n### `assertIs...` Functions\n\nThese functions assert that a given object meets certain criteria and throw an error if it doesn't:\n\n- `assertIsNodeLike`: Asserts that a given value is a DOM node.\n- `assertIsArrayOfNodes`: Asserts that the given value is an array of DOM nodes.\n- `assertIsElementNode`, `assertIsAttributeNode`, `assertIsTextNode`, etc.: Assert for specific types of DOM nodes.\n\n### TypeScript Type Narrowing\n\nBoth the `is...` and `assertIs...` functions can be used for TypeScript type narrowing. After a successful check or assertion, TypeScript will recognize the specific type of the DOM node, allowing for more robust and error-free code.\n\n## Features\n\n- Lightweight\n- Written in TypeScript\n- Comprehensive tests\n- Compatible with NodeJS XML libraries like `xpath` and `@xmldom/xmldom`\n\n## Contributing\n\nPlease read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details.\n",
  "repository": {
    "type": "git",
    "url": "git+https://github.com/xmldom/is-dom-node.git"
  },
  "bugs": {
    "url": "https://github.com/xmldom/is-dom-node/issues"
  },
  "license": "MIT",
  "versions": {
    "1.0.0": {
      "name": "@xmldom/is-dom-node",
      "version": "1.0.0",
      "description": "TypeScript helper functions to narrow the type of object to a Node descendant",
      "main": "dist/index.js",
      "scripts": {
        "build": "tsc",
        "changelog": "gren changelog --override --generate --head main",
        "lint": "eslint \"{src,test}/*.ts\" --cache && npm run prettier-check",
        "lint:fix": "eslint --fix \"{src,test}/*.ts\" && npm run prettier-format",
        "prepare": "tsc",
        "prettier-check": "prettier --config .prettierrc.json --check .",
        "prettier-format": "prettier --config .prettierrc.json --write .",
        "prerelease": "git clean -xfd && npm ci && npm run lint && npm test && npm run build",
        "release": "release-it",
        "update:major": "npx npm-check-updates -i",
        "tsc": "tsc",
        "update:minor": "npx npm-check-updates -i -t minor",
        "test": "npm run tsc && nyc mocha"
      },
      "repository": {
        "type": "git",
        "url": "git+https://github.com/xmldom/is-dom-node.git"
      },
      "keywords": [
        "dom",
        "node",
        "typescript",
        "narrow",
        "guard"
      ],
      "author": {
        "name": "Chris Barth",
        "email": "chrisjbarth@hotmail.com"
      },
      "license": "MIT",
      "bugs": {
        "url": "https://github.com/xmldom/is-dom-node/issues"
      },
      "homepage": "https://github.com/xmldom/is-dom-node#readme",
      "devDependencies": {
        "@cjbarth/github-release-notes": "^4.2.0",
        "@istanbuljs/nyc-config-typescript": "^1.0.2",
        "@types/jsdom": "^21.1.2",
        "@types/mocha": "^10.0.1",
        "@types/node": "^16.18.50",
        "@typescript-eslint/eslint-plugin": "^6.6.0",
        "@typescript-eslint/parser": "^6.6.0",
        "@xmldom/xmldom": "^0.8.10",
        "choma": "^1.2.1",
        "eslint": "^8.49.0",
        "eslint-config-prettier": "^9.0.0",
        "eslint-plugin-deprecation": "^2.0.0",
        "jsdom": "^22.1.0",
        "mocha": "^10.2.0",
        "nyc": "^15.1.0",
        "prettier": "^3.0.3",
        "prettier-plugin-packagejson": "^2.4.5",
        "release-it": "^16.1.5",
        "ts-node": "^10.9.1",
        "typescript": "^5.2.2"
      },
      "engines": {
        "node": ">= 16"
      },
      "publishConfig": {
        "access": "public"
      },
      "types": "./dist/index.d.ts",
      "gitHead": "6312c0e83141c66f7ec0a2ca811e750387e18595",
      "_id": "@xmldom/is-dom-node@1.0.0",
      "_nodeVersion": "16.20.2",
      "_npmVersion": "8.19.4",
      "dist": {
        "integrity": "sha512-9Zoeh5RoFXc+Ooa0ZQtpxfqgcAxd+Z9XP22oJIRoDiQ8IL0qbCj3UoJHOUHot7LDhLMZ+iVAqPh46+hSVKYCZA==",
        "shasum": "9ac324360c412bab4582a22be3828f28c9b279b1",
        "tarball": "https://archive.ito.gov.ir/npm/_packages/@xmldom/is-dom-node/-/is-dom-node-1.0.0.tgz",
        "fileCount": 6,
        "unpackedSize": 22023,
        "signatures": [
          {
            "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
            "sig": "MEQCIFILEg7Yl1YZxjpZ58uua72jyVLMSOry87cfBd0befLFAiAaL9H0NVNWveaMymvWdDrVbUMsM/4F4rTX3bNtvSOmJA=="
          }
        ]
      },
      "_npmUser": {
        "name": "cjbarth",
        "email": "chrisjbarth@hotmail.com"
      },
      "directories": {},
      "maintainers": [
        {
          "name": "cjbarth",
          "email": "chrisjbarth@hotmail.com"
        }
      ],
      "_npmOperationalInternal": {
        "host": "s3://npm-registry-packages",
        "tmp": "tmp/is-dom-node_1.0.0_1696882496299_0.23564384707763386"
      },
      "_hasShrinkwrap": false
    },
    "1.0.1": {
      "name": "@xmldom/is-dom-node",
      "version": "1.0.1",
      "description": "TypeScript helper functions to narrow the type of object to a Node descendant",
      "main": "dist/index.js",
      "scripts": {
        "build": "tsc",
        "changelog": "gren changelog --override --generate --head main",
        "lint": "eslint \"{src,test}/*.ts\" --cache && npm run prettier-check",
        "lint:fix": "eslint --fix \"{src,test}/*.ts\" && npm run prettier-format",
        "prepare": "tsc",
        "prettier-check": "prettier --config .prettierrc.json --check .",
        "prettier-format": "prettier --config .prettierrc.json --write .",
        "prerelease": "git clean -xfd && npm ci && npm run lint && npm test && npm run build",
        "release": "release-it",
        "update:major": "npx npm-check-updates -i",
        "tsc": "tsc",
        "update:minor": "npx npm-check-updates -i -t minor",
        "test": "npm run tsc && nyc mocha"
      },
      "repository": {
        "type": "git",
        "url": "git+https://github.com/xmldom/is-dom-node.git"
      },
      "keywords": [
        "dom",
        "node",
        "typescript",
        "narrow",
        "guard"
      ],
      "author": {
        "name": "Chris Barth",
        "email": "chrisjbarth@hotmail.com"
      },
      "license": "MIT",
      "bugs": {
        "url": "https://github.com/xmldom/is-dom-node/issues"
      },
      "homepage": "https://github.com/xmldom/is-dom-node#readme",
      "devDependencies": {
        "@cjbarth/github-release-notes": "^4.2.0",
        "@istanbuljs/nyc-config-typescript": "^1.0.2",
        "@types/jsdom": "^21.1.2",
        "@types/mocha": "^10.0.2",
        "@types/node": "^16.18.58",
        "@typescript-eslint/eslint-plugin": "^6.7.5",
        "@typescript-eslint/parser": "^6.7.5",
        "@xmldom/xmldom": "^0.8.10",
        "choma": "^1.2.1",
        "eslint": "^8.51.0",
        "eslint-config-prettier": "^9.0.0",
        "eslint-plugin-deprecation": "^2.0.0",
        "jsdom": "^22.1.0",
        "mocha": "^10.2.0",
        "nyc": "^15.1.0",
        "prettier": "^3.0.3",
        "prettier-plugin-packagejson": "^2.4.6",
        "release-it": "^16.2.1",
        "ts-node": "^10.9.1",
        "typescript": "^5.2.2"
      },
      "engines": {
        "node": ">= 16"
      },
      "publishConfig": {
        "access": "public"
      },
      "types": "./dist/index.d.ts",
      "gitHead": "2f7a0dafe34999a257f4d6e8b19d94f982925849",
      "_id": "@xmldom/is-dom-node@1.0.1",
      "_nodeVersion": "16.20.2",
      "_npmVersion": "8.19.4",
      "dist": {
        "integrity": "sha512-CJDxIgE5I0FH+ttq/Fxy6nRpxP70+e2O048EPe85J2use3XKdatVM7dDVvFNjQudd9B49NPoZ+8PG49zj4Er8Q==",
        "shasum": "83b9f3e1260fb008061c6fa787b93a00f9be0629",
        "tarball": "https://archive.ito.gov.ir/npm/_packages/@xmldom/is-dom-node/-/is-dom-node-1.0.1.tgz",
        "fileCount": 6,
        "unpackedSize": 22054,
        "signatures": [
          {
            "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
            "sig": "MEUCIQCZ7hP7D3Qftki6JIQNbWStBD2KEzJSS5vz0V44p00UTgIgeCXzqUi1IPO5blMb3FIUbyw17rpdSjKIegY4c68dpHw="
          }
        ]
      },
      "_npmUser": {
        "name": "cjbarth",
        "email": "chrisjbarth@hotmail.com"
      },
      "directories": {},
      "maintainers": [
        {
          "name": "cjbarth",
          "email": "chrisjbarth@hotmail.com"
        }
      ],
      "_npmOperationalInternal": {
        "host": "s3://npm-registry-packages",
        "tmp": "tmp/is-dom-node_1.0.1_1696884840493_0.470843949965396"
      },
      "_hasShrinkwrap": false
    }
  },
  "name": "@xmldom/is-dom-node",
  "time": {
    "created": "2023-10-09T20:14:56.191Z",
    "1.0.0": "2023-10-09T20:14:56.533Z",
    "modified": "2026-05-30T09:12:03.775Z",
    "1.0.1": "2023-10-09T20:54:00.718Z"
  },
  "readmeFilename": "README.md",
  "homepage": "https://github.com/xmldom/is-dom-node#readme"
}