Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
ai committed Apr 24, 2024
1 parent 08f4f8c commit 938875d
Show file tree
Hide file tree
Showing 10 changed files with 604 additions and 315 deletions.
2 changes: 1 addition & 1 deletion atom/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,4 @@ export declare let notifyId: number
*/
export function atom<Value, StoreExt = {}>(
...args: undefined extends Value ? [] | [Value] : [Value]
): WritableAtom<Value> & StoreExt
): StoreExt & WritableAtom<Value>
2 changes: 1 addition & 1 deletion atom/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ test('initializes store when it has listeners', () => {
}
})

deepStrictEqual(events, [])
equal(events.length, 0)

let unbind1 = $store.listen(value => {
events.push(`1: ${value}`)
Expand Down
10 changes: 5 additions & 5 deletions deep-map/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ import type { AllPaths, BaseDeepMap, FromPath } from './path.js'

export { AllPaths, BaseDeepMap, FromPath, getPath, setPath } from './path.js'

export type DeepMapStore<T extends BaseDeepMap> = Omit<
WritableAtom<T>,
'listen' | 'setKey' | 'subscribe'
> & {
export type DeepMapStore<T extends BaseDeepMap> = {
/**
* Subscribe to store changes.
*
Expand Down Expand Up @@ -61,7 +58,10 @@ export type DeepMapStore<T extends BaseDeepMap> = Omit<
changedKey: AllPaths<T> | undefined
) => void
): () => void
}
} & Omit<
WritableAtom<T>,
'listen' | 'setKey' | 'subscribe'
>

/**
* Create deep map store. Deep map store is a store with an object as store
Expand Down
8 changes: 3 additions & 5 deletions deep-map/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import FakeTimers from '@sinonjs/fake-timers'
import { deepStrictEqual } from 'node:assert'
import { deepStrictEqual, equal } from 'node:assert'
import { test } from 'node:test'

import { deepMap, onMount, onNotify } from '../index.js'
Expand All @@ -20,7 +20,7 @@ test('initializes store when it has listeners', () => {
}
})

deepStrictEqual(events, [])
equal(events.length, 0)

let unbind1 = $store.listen((value, oldValue, key) => {
events.push(`1: ${key} ${JSON.stringify(value)}`)
Expand Down Expand Up @@ -350,9 +350,7 @@ test('notifies correct previous value from deep store', t => {

events = []
$store.setKey('b.nested.deep', 3)
deepStrictEqual(events, [
{ a: 1, b: { nested: { deep: 3 } } }
])
deepStrictEqual(events, [{ a: 1, b: { nested: { deep: 3 } } }])

t.mock.reset()
unbind()
Expand Down
6 changes: 2 additions & 4 deletions lifecycle/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ test('shares data between onNotify listeners', () => {
deepStrictEqual(events, [{ test: 1 }])
})

test("doesn't share data between different listeners", () => {
test('does not share data between different listeners', () => {
let events: object[] = []
let store = atom(1)

Expand Down Expand Up @@ -239,9 +239,7 @@ test('supports map in onSet and onNotify', () => {
})

store.subscribe((value, oldValue, changed) => {
events.push(
`subscription ${changed} ${oldValue?.value}${value.value}`
)
events.push(`subscription ${changed} ${oldValue?.value}${value.value}`)
})
deepStrictEqual(events, ['subscription undefined undefined → 0'])

Expand Down
4 changes: 2 additions & 2 deletions map-creator/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export interface MapCreator<
(id: string, ...args: Args): MapStore<Value>
build(id: string, ...args: Args): MapStore<Value>
cache: {
[id: string]: MapStore<Value & { id: string }>
[id: string]: MapStore<{ id: string } & Value>
}
}

Expand All @@ -22,7 +22,7 @@ export function mapCreator<
StoreExt = {}
>(
init?: (
store: MapStore<Value & { id: string }> & StoreExt,
store: MapStore<{ id: string } & Value> & StoreExt,
id: string,
...args: Args
) => (() => void) | void
Expand Down
4 changes: 2 additions & 2 deletions map/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ export type StoreValue<SomeStore> = SomeStore extends {
? Value
: any

export type BaseMapStore<Value = any> = WritableAtom<Value> & {
export type BaseMapStore<Value = any> = {
setKey: (key: any, value: any) => any
}
} & WritableAtom<Value>

export type MapStoreKeys<SomeStore> = SomeStore extends {
setKey: (key: infer K, ...args: any[]) => any
Expand Down
4 changes: 2 additions & 2 deletions map/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import FakeTimers from '@sinonjs/fake-timers'
import { deepStrictEqual } from 'node:assert'
import { deepStrictEqual, equal } from 'node:assert'
import { test } from 'node:test'

import { map, onMount } from '../index.js'
Expand All @@ -20,7 +20,7 @@ test('initializes store when it has listeners', () => {
}
})

deepStrictEqual(events, [])
equal(events.length, 0)

let unbind1 = $store.listen((value, oldValue, key) => {
events.push(`1: ${key} ${JSON.stringify(value)}`)
Expand Down
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,17 @@
"devDependencies": {
"@logux/eslint-config": "^52.0.2",
"@sinonjs/fake-timers": "^11.2.2",
"@size-limit/preset-small-lib": "^11.0.2",
"@types/node": "^20.11.20",
"@size-limit/preset-small-lib": "^11.1.2",
"@types/node": "^20.12.7",
"@types/sinonjs__fake-timers": "^8.1.5",
"@types/ws": "^8.5.10",
"@typescript-eslint/eslint-plugin": "^7.1.0",
"@typescript-eslint/parser": "^7.1.0",
"@typescript-eslint/eslint-plugin": "^7.7.1",
"@typescript-eslint/parser": "^7.7.1",
"benchmark": "^2.1.4",
"better-node-test": "^0.5.0",
"better-node-test": "^0.5.1",
"c8": "^9.1.0",
"check-dts": "^0.7.2",
"clean-publish": "^4.2.0",
"clean-publish": "^4.4.0",
"eslint": "^8.57.0",
"eslint-config-standard": "^17.1.0",
"eslint-plugin-import": "^2.29.1",
Expand All @@ -60,9 +60,9 @@
"eslint-plugin-prefer-let": "^3.0.1",
"eslint-plugin-promise": "^6.1.1",
"nanodelay": "^2.0.2",
"size-limit": "^11.0.2",
"tsx": "^4.7.1",
"typescript": "^5.3.3"
"size-limit": "^11.1.2",
"tsx": "^4.7.2",
"typescript": "^5.4.5"
},
"prettier": {
"arrowParens": "avoid",
Expand Down
Loading

0 comments on commit 938875d

Please sign in to comment.