Socket
Socket
Sign inDemoInstall

@tanstack/store

Package Overview
Dependencies
Maintainers
2
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tanstack/store - npm Package Compare versions

Comparing version 0.1.3 to 0.3.0

dist/cjs/index.cjs

30

package.json
{
"name": "@tanstack/store",
"author": "Tanner Linsley",
"version": "0.1.3",
"version": "0.3.0",
"license": "MIT",

@@ -21,14 +21,14 @@ "repository": "tanstack/store",

"type": "module",
"types": "build/legacy/index.d.ts",
"main": "build/legacy/index.cjs",
"module": "build/legacy/index.js",
"types": "dist/esm/index.d.ts",
"main": "dist/cjs/index.cjs",
"module": "dist/esm/index.js",
"exports": {
".": {
"import": {
"types": "./build/modern/index.d.ts",
"default": "./build/modern/index.js"
"types": "./dist/esm/index.d.ts",
"default": "./dist/esm/index.js"
},
"require": {
"types": "./build/modern/index.d.cts",
"default": "./build/modern/index.cjs"
"types": "./dist/cjs/index.d.cts",
"default": "./dist/cjs/index.cjs"
}

@@ -40,14 +40,18 @@ },

"files": [
"build",
"dist",
"src"
],
"scripts": {
"clean": "rimraf ./build && rimraf ./coverage",
"clean": "rimraf ./dist && rimraf ./coverage",
"test:eslint": "eslint --ext .ts,.tsx ./src",
"test:types": "tsc",
"test:lib": "vitest run --coverage",
"test:types:versions49": "node ../../node_modules/typescript49/lib/tsc.js --project tsconfig.legacy.json",
"test:types:versions50": "node ../../node_modules/typescript50/lib/tsc.js",
"test:types:versions51": "node ../../node_modules/typescript51/lib/tsc.js",
"test:types:versions52": "tsc",
"test:types": "pnpm run \"/^test:types:versions.*/\"",
"test:lib": "vitest",
"test:lib:dev": "pnpm run test:lib --watch",
"test:build": "publint --strict",
"build": "tsup"
"build": "vite build"
}
}
export type AnyUpdater = (...args: any[]) => any
export type Listener = (opts: { priority: Priority }) => void
export type Listener = () => void
export type Priority = 'high' | 'low'
interface StoreOptions<

@@ -16,4 +14,3 @@ TState,

) => () => void
onUpdate?: (opts: { priority: Priority }) => void
defaultPriority?: Priority
onUpdate?: () => void
}

@@ -30,3 +27,2 @@

_flushing = 0
_nextPriority: null | Priority = null

@@ -47,8 +43,3 @@ constructor(initialState: TState, options?: StoreOptions<TState, TUpdater>) {

setState = (
updater: TUpdater,
opts?: {
priority: Priority
},
) => {
setState = (updater: TUpdater) => {
const previous = this.state

@@ -59,15 +50,4 @@ this.state = this.options?.updateFn

const priority = opts?.priority ?? this.options?.defaultPriority ?? 'high'
if (this._nextPriority === null) {
this._nextPriority = priority
} else if (this._nextPriority === 'high') {
this._nextPriority = priority
} else {
this._nextPriority = this.options?.defaultPriority ?? 'high'
}
// Always run onUpdate, regardless of batching
this.options?.onUpdate?.({
priority: this._nextPriority,
})
this.options?.onUpdate?.()

@@ -83,5 +63,3 @@ // Attempt to flush

if (this._flushing !== flushId) return
listener({
priority: this._nextPriority ?? 'high',
})
listener()
})

@@ -88,0 +66,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc