{"id":14505,"library":"component-xor","title":"XOR Utility Function","description":"component-xor is a minuscule JavaScript utility package providing a single function, `xor(bool, bool)`, to compute the exclusive OR of two boolean values. Released under the MIT license, its latest version is 0.0.4, published in 2015. This package is part of the 'component' ecosystem, an early web package manager that predates modern module bundlers and is no longer actively maintained. Due to its age and the deprecation of its original ecosystem, it lacks modern features like ES Modules support and active development. Its key differentiator was its extreme simplicity and adherence to the 'component' philosophy, but it is now effectively abandoned. For new projects, developers should implement the simple XOR logic directly or use modern alternatives, as `component-xor` does not receive updates or support.","status":"abandoned","version":"0.0.4","language":"javascript","source_language":"en","source_url":"https://github.com/component/xor","tags":["javascript","xor"],"install":[{"cmd":"npm install component-xor","lang":"bash","label":"npm"},{"cmd":"yarn add component-xor","lang":"bash","label":"yarn"},{"cmd":"pnpm add component-xor","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package predates widespread ES Module (ESM) adoption and is CommonJS-only. Attempting to use ESM `import` syntax will result in errors.","wrong":"import { xor } from 'component-xor';","symbol":"xor","correct":"const xor = require('component-xor');"}],"quickstart":{"code":"const xor = require('component-xor');\n\nconsole.log('XOR Truth Table:');\nconsole.log(`true, true   => ${xor(true, true)}`);    // Expected: false\nconsole.log(`true, false  => ${xor(true, false)}`);   // Expected: true\nconsole.log(`false, true  => ${xor(false, true)}`);   // Expected: true\nconsole.log(`false, false => ${xor(false, false)}`); // Expected: false\n\nconst a = true;\nconst b = false;\nconst c = true;\n\nconsole.log(`\\nCustom examples:`);\nconsole.log(`xor(${a}, ${b}) is ${xor(a, b)}`);\nconsole.log(`xor(${a}, ${c}) is ${xor(a, c)}`);\nconsole.log(`xor(${b}, ${c}) is ${xor(b, c)}`);\n\n// Demonstrating non-boolean input behavior (JavaScript coercion)\nconsole.log(`\\nCoercion examples:`);\nconsole.log(`xor(1, 0) => ${xor(1, 0)}`); // Coerces to xor(true, false) => true\nconsole.log(`xor(1, 1) => ${xor(1, 1)}`); // Coerces to xor(true, true)  => false","lang":"javascript","description":"Demonstrates basic usage of the `xor` function with various boolean and truthy/falsy inputs, illustrating its simple boolean logic."},"warnings":[{"fix":"Do not use `component-xor` in new projects. For existing projects, consider replacing it with a direct implementation of the XOR logic (`(a && !b) || (!a && b)`) or a modern, actively maintained utility library.","message":"This package and its original 'component' ecosystem are abandoned. It has not been updated since 2015 and will not receive bug fixes, security patches, or new features.","severity":"breaking","affected_versions":"<=0.0.4"},{"fix":"Ensure you use CommonJS `require()` syntax (`const xor = require('component-xor');`) to import this package. For ES Module projects, consider writing the XOR logic inline or finding an ESM-compatible alternative.","message":"The package is CommonJS-only and does not support ES Modules (`import`/`export`) syntax directly. Using `import` statements will cause runtime errors in modern environments unless transpiled or handled by a compatible module loader.","severity":"gotcha","affected_versions":"all"},{"fix":"For bitwise XOR, use the `^` operator (e.g., `a ^ b`). For logical XOR in modern JavaScript, consider `Boolean(a) !== Boolean(b)` or `(a && !b) || (!a && b)`.","message":"Minimal functionality: `component-xor` only provides a basic boolean XOR. For bitwise XOR (`^`) or more advanced logical operations, this package is insufficient.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Replace the import statement with the CommonJS `require()` syntax: `const xor = require('component-xor');`.","cause":"Attempting to use ES Module `import { xor } from 'component-xor';` syntax in a project that expects CommonJS modules or when the bundler doesn't correctly handle CJS interoperability.","error":"TypeError: (0 , component_xor__WEBPACK_IMPORTED_MODULE_0__.xor) is not a function"},{"fix":"Verify that `component-xor` is listed in your `package.json` and `node_modules`. Ensure you have a correct `const xor = require('component-xor');` statement at the top of your file.","cause":"The package was either not installed, or the import/require statement was incorrect, leading to the `xor` function not being available in the current scope.","error":"ReferenceError: xor is not defined"}],"ecosystem":"npm"}