{"library":"oc-hash-builder","title":"OC Hash Builder","description":"oc-hash-builder is a utility library within the OpenComponents (OC) ecosystem, designed to provide deterministic hashing capabilities. Its primary role is to generate consistent hashes for component-related data, configurations, and content, which is crucial for OpenComponents' internal mechanisms such as caching, component identification, and versioning. As of version 1.0.5, it represents a stable initial release. The library's release cadence is likely tied to the broader OpenComponents project, focusing on stability and integration rather than frequent, independent updates. A key differentiator is its purpose-built nature for the OpenComponents framework, ensuring compatibility and adherence to OC's specific requirements for managing and deploying micro-frontends. It ships with TypeScript types, facilitating its use in modern JavaScript and TypeScript projects.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install oc-hash-builder"],"cli":null},"imports":["import { buildHash } from 'oc-hash-builder';","import { HashBuilder } from 'oc-hash-builder';","import hashBuilder from 'oc-hash-builder';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { buildHash } from 'oc-hash-builder';\n\n// Example 1: Hashing a simple object\nconst componentConfig = {\n  name: 'my-component',\n  version: '1.0.0',\n  dependencies: ['lodash@4.17.21'],\n  settings: {\n    env: 'production'\n  }\n};\nconst configHash = buildHash(componentConfig);\nconsole.log(`Hash for component config: ${configHash}`);\n\n// Example 2: Hashing a string (e.g., component template content)\nconst templateContent = `<div>Hello, {{name}}!</div>`;\nconst contentHash = buildHash(templateContent);\nconsole.log(`Hash for template content: ${contentHash}`);\n\n// Example 3: Ensuring deterministic hashing\nconst sameConfigDifferentOrder = {\n  settings: {\n    env: 'production'\n  },\n  dependencies: ['lodash@4.17.21'],\n  name: 'my-component',\n  version: '1.0.0'\n};\nconst orderIndependentHash = buildHash(sameConfigDifferentOrder);\nconsole.log(`Hash for reordered config (should be same): ${orderIndependentHash}`);\n\n// In a real OpenComponents context, this might be used internally or exposed\n// via a plugin system for ensuring component integrity and cache keys.\n// For instance, during component publishing or rendering lifecycle.","lang":"typescript","description":"Demonstrates how to use `oc-hash-builder` to create deterministic hashes for objects and strings, which is critical for identifying and caching OpenComponents artifacts.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}