{"library":"shallow-equal","title":"Shallow Equality Check","description":"The `shallow-equal` library provides minimalistic, TypeScript-compatible utilities for performing shallow equality checks on arrays and objects. It currently stands at version 3.1.0, offering highly optimized functions like `shallowEqualArrays` and `shallowEqualObjects` for specific data types, alongside a generic `shallowEqual` function that includes runtime type checking. The project emphasizes being super light with no external dependencies, ensuring a small footprint. Its release cadence is stable, focusing on minor enhancements and maintenance rather than frequent, large-scale breaking changes, typical for foundational utility packages. A key differentiator is its explicit separation of array and object equality functions, allowing developers to choose the most performant option when the type is known, avoiding the overhead of runtime type inference inherent in more generic solutions.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install shallow-equal"],"cli":null},"imports":["import { shallowEqualArrays } from 'shallow-equal';","import { shallowEqualObjects } from 'shallow-equal';","import { shallowEqual } from 'shallow-equal';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { shallowEqualArrays, shallowEqualObjects } from \"shallow-equal\";\n\n// Demonstrates shallow equality for arrays. Nested objects are compared by reference.\nconst arr1 = [1, 2, { id: 1 }];\nconst arr2 = [1, 2, { id: 1 }];\nconsole.log(\"shallowEqualArrays(arr1, arr2):\", shallowEqualArrays(arr1, arr2)); // Expected: false (because {id:1} !== {id:1})\n\nconst arr3 = [1, 2, 3];\nconst arr4 = [1, 2, 3];\nconsole.log(\"shallowEqualArrays(arr3, arr4):\", shallowEqualArrays(arr3, arr4)); // Expected: true\n\n// Demonstrates shallow equality for objects. Nested objects are compared by reference.\nconst obj1 = { a: 5, b: \"abc\", c: { id: 1 } };\nconst obj2 = { a: 5, b: \"abc\", c: { id: 1 } };\nconsole.log(\"shallowEqualObjects(obj1, obj2):\", shallowEqualObjects(obj1, obj2)); // Expected: false (because {id:1} !== {id:1})\n\nconst obj3 = { a: 5, b: \"abc\" };\nconst obj4 = { a: 5, b: \"abc\" };\nconsole.log(\"shallowEqualObjects(obj3, obj4):\", shallowEqualObjects(obj3, obj4)); // Expected: true","lang":"typescript","description":"Demonstrates how to use `shallowEqualArrays` and `shallowEqualObjects` for efficient shallow comparisons, clarifying that nested non-primitives are compared by reference, not recursively.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}