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

@scalar/object-utils

Package Overview
Dependencies
Maintainers
0
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@scalar/object-utils - npm Package Compare versions

Comparing version 1.1.6 to 1.1.7

6

CHANGELOG.md
# @scalar/object-utils
## 1.1.7
### Patch Changes
- 03e9bbb: Move to flatted for localstorage
## 1.1.6

@@ -4,0 +10,0 @@

1

dist/mutator-record/handlers.d.ts

@@ -22,3 +22,4 @@ import { Mutation } from '../mutator-record/mutations.js';

redo: (uid: string) => void;
loadLocalStorage: () => void;
};
//# sourceMappingURL=handlers.d.ts.map

30

dist/mutator-record/handlers.js
import { Mutation } from './mutations.js';
import { useDebounceFn } from '@vueuse/core';
import { stringify, parse } from 'flatted';
import { LS_CONFIG } from './local-storage.js';

@@ -16,11 +17,27 @@

const onChange = localStorageKey
? useDebounceFn(() => localStorage.setItem(localStorageKey, JSON.stringify(entityMap)), LS_CONFIG.DEBOUNCE_MS, { maxWait: LS_CONFIG.MAX_WAIT_MS })
? useDebounceFn(() => localStorage.setItem(localStorageKey, stringify(entityMap)), LS_CONFIG.DEBOUNCE_MS, { maxWait: LS_CONFIG.MAX_WAIT_MS })
: () => null;
/** Adds a new item to the record of tracked items and creates a new mutation tracking instance */
const add = (item) => {
entityMap[item.uid] = item;
mutationMap[item.uid] = new Mutation(item, maxNumberRecords);
onChange();
};
/** Load the previous entity map state from localStorage into the active state */
const loadLocalStorage = () => {
if (!localStorageKey)
return;
const lsItem = localStorage.getItem(localStorageKey);
const data =
// Check for the new data structure to support the old ones
lsItem?.[0] === '['
? parse(localStorage.getItem(localStorageKey) || '[{}]')
: JSON.parse(localStorage.getItem(localStorageKey) || '{}');
const instances = Object.values(data);
// TODO: Validation should be provided for each entity
instances.forEach(add);
};
return {
/** Adds a new item to the record of tracked items and creates a new mutation tracking instance */
add: (item) => {
entityMap[item.uid] = item;
mutationMap[item.uid] = new Mutation(item, maxNumberRecords);
onChange();
},
add,
delete: (uid) => {

@@ -61,2 +78,3 @@ delete entityMap[uid];

},
loadLocalStorage,
};

@@ -63,0 +81,0 @@ }

@@ -16,3 +16,3 @@ {

],
"version": "1.1.6",
"version": "1.1.7",
"engines": {

@@ -60,2 +60,3 @@ "node": ">=18"

"@vueuse/core": "^10.10.0",
"flatted": "^3.3.1",
"just-clone": "^6.2.0",

@@ -62,0 +63,0 @@ "ts-deepmerge": "^7.0.1"

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