Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@nanostores/query

Package Overview
Dependencies
Maintainers
4
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nanostores/query - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

28

dist/nanoquery.js

@@ -16,3 +16,3 @@ import { map, onStart, onStop, atom } from "nanostores";

subscribe("online", () => events.emit(RECONNECT));
const _refetchOnInterval = /* @__PURE__ */ new Map(), _lastFetch = /* @__PURE__ */ new Map(), _runningFetches = /* @__PURE__ */ new Set();
const _refetchOnInterval = /* @__PURE__ */ new Map(), _lastFetch = /* @__PURE__ */ new Map(), _runningFetches = /* @__PURE__ */ new Map();
let rewrittenSettings = {};

@@ -29,2 +29,9 @@ const runFetcher = async ([key, keyParts], store, settings, force) => {

};
const setAsLoading = () => {
set({
...store.value,
...loading,
promise: _runningFetches.get(key)
});
};
const { dedupeTime = 4e3, fetcher } = {

@@ -35,6 +42,11 @@ ...settings,

const now = getNow();
if (_runningFetches.has(key)) {
if (!store.value.loading)
setAsLoading();
return;
}
if (!force) {
const cached = cache.get(key);
if (store.value.data !== cached)
set(cached ? { data: cached, ...notLoading } : { ...loading });
if (cached && store.value.data !== cached)
set({ data: cached, ...notLoading });
const last = _lastFetch.get(key);

@@ -45,10 +57,7 @@ if (last && last + dedupeTime > now) {

}
if (_runningFetches.has(key)) {
return;
}
_lastFetch.set(key, now);
_runningFetches.add(key);
try {
const promise = fetcher(...keyParts);
set({ data: store.value.data, ...loading, promise });
_lastFetch.set(key, now);
_runningFetches.set(key, promise);
setAsLoading();
const res = await promise;

@@ -89,3 +98,2 @@ cache.set(key, res);

};
fetcherStore.get = () => fetcherStore.value;
let keysInternalUnsub, prevKey, prevKeyParts, keyUnsub, keyStore;

@@ -92,0 +100,0 @@ let evtUnsubs = [];

{
"name": "@nanostores/query",
"version": "0.1.2",
"version": "0.1.3",
"description": "Tiny remote data fetching library for Nano Stores",

@@ -5,0 +5,0 @@ "scripts": {

Sorry, the diff of this file is not supported yet

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