Rocky_Mountain_Vending/.pnpm-store/v10/files/a4/b8cd71425942b178e98d523f72d323db5d3de7a76a3ba56af940d79a5d1feb7e190f4433bf543b910d0accc9a86e0760fdbe1d0802625951da7e5319147b81
DMleadgen 46d973904b
Initial commit: Rocky Mountain Vending website
Next.js website for Rocky Mountain Vending company featuring:
- Product catalog with Stripe integration
- Service areas and parts pages
- Admin dashboard with Clerk authentication
- SEO optimized pages with JSON-LD structured data

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12 16:22:15 -07:00

80 lines
1.7 KiB
Text

/**
* @license
* Copyright 2018 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import {isEqual} from 'lodash-es';
/**
* @fileoverview This class is designed to allow maps with arbitrary equality functions.
* It is not meant to be performant and is well-suited to use cases where the number of entries is
* likely to be small (like computed artifacts).
*/
class ArbitraryEqualityMap {
constructor() {
this._equalsFn = ArbitraryEqualityMap.deepEquals;
/** @type {Array<{key: *, value: *}>} */
this._entries = [];
}
/**
* @param {function(*,*):boolean} equalsFn
*/
setEqualityFn(equalsFn) {
this._equalsFn = equalsFn;
}
/**
* @param {*} key
* @return {boolean}
*/
has(key) {
return this._findIndexOf(key) !== -1;
}
/**
* @param {*} key
* @return {*}
*/
get(key) {
const entry = this._entries[this._findIndexOf(key)];
return entry?.value;
}
/**
* @param {*} key
* @param {*} value
*/
set(key, value) {
let index = this._findIndexOf(key);
if (index === -1) index = this._entries.length;
this._entries[index] = {key, value};
}
/**
* @param {*} key
* @return {number}
*/
_findIndexOf(key) {
for (let i = 0; i < this._entries.length; i++) {
if (this._equalsFn(key, this._entries[i].key)) return i;
}
return -1;
}
/**
* Determines whether two objects are deeply equal. Defers to lodash isEqual, but is kept here for
* easy usage by consumers.
* See https://lodash.com/docs/4.17.5#isEqual.
* @param {*} objA
* @param {*} objB
* @return {boolean}
*/
static deepEquals(objA, objB) {
return isEqual(objA, objB);
}
}
export {ArbitraryEqualityMap};