Skip to content

Commit

Permalink
fix: expose equals functions
Browse files Browse the repository at this point in the history
  • Loading branch information
schummar committed Mar 7, 2024
1 parent 9445310 commit 4a48695
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
16 changes: 8 additions & 8 deletions src/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@ export {
type CacheOptions,
} from './cache';
export type {
AsyncConnectionActions,
AsyncUpdateFunction,
BaseConnectionActions,
CalculationActions,
Cancel,
Connection,
ConnectionActions,
DisposableCancel,
Duration,
Effect,
Listener,
SubscribeOptions,
AsyncUpdateFunction,
Selector,
SubscribeOptions,
Update,
UpdateFrom,
UpdateFunction,
CalculationActions,
Use,
AsyncConnectionActions,
BaseConnectionActions,
Connection,
ConnectionActions,
DisposableCancel,
} from './commonTypes';
export { ResourceGroup, allResources, createResourceGroup, type Resource } from './resourceGroup';
export { Scope, createScope } from './scope';
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export * from './core';
export { applyPatches } from './lib/applyPatches';
export { calcDuration } from './lib/calcDuration';
export { diff, type Patch } from './lib/diff';
export { deepEqual, shallowEqual, strictEqual } from './lib/equals';
export { InstanceCache } from './lib/instanceCache';
export { type Path, type PathAsArray, type PathAsString, type Value } from './lib/path';
export { get, set } from './lib/propAccess';
Expand Down
4 changes: 2 additions & 2 deletions src/lib/equals.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
export function defaultEqual(a: any, b: any) {
export function strictEqual(a: any, b: any) {
return a === b;
}

export function shallowEqual(a: any, b: any): boolean {
return internalEqual(defaultEqual)(a, b);
return internalEqual(strictEqual)(a, b);
}

export function deepEqual(a: any, b: any): boolean {
Expand Down
6 changes: 3 additions & 3 deletions test/core/store.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
import { createStore, set } from '../../src';
import { defaultEqual, shallowEqual } from '../../src/lib/equals';
import { strictEqual, shallowEqual } from '../../src/lib/equals';
import { flushPromises } from '../testHelpers';

beforeEach(() => {
Expand Down Expand Up @@ -156,7 +156,7 @@ describe('static store', () => {
test('store.subscribe default equals', async () => {
const state = createStore({ a: 1 });
const listener = vi.fn();
state.subscribe(listener, { equals: defaultEqual });
state.subscribe(listener, { equals: strictEqual });
state.set({ a: 1 });
expect(listener.mock.calls).toMatchObject([
[{ a: 1 }, undefined],
Expand Down Expand Up @@ -296,7 +296,7 @@ describe('static store', () => {
const state = createStore(true);
const mapped = state.map((x) => [x]);
const listener = vi.fn();
mapped.subscribe(listener, { equals: defaultEqual });
mapped.subscribe(listener, { equals: strictEqual });
state.set(false);
state.set(true);
state.set(false);
Expand Down

0 comments on commit 4a48695

Please sign in to comment.