New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

wootils

Package Overview
Dependencies
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wootils - npm Package Compare versions

Comparing version 2.2.1 to 2.2.2

19

browser/simpleStorage.js

@@ -318,3 +318,3 @@ const extend = require('extend');

_getEntryValue(key) {
const entry = this.getEntry(key);
const entry = this._getEntry(key);
return entry ? entry.value : entry;

@@ -401,5 +401,5 @@ }

if (reset) {
this.setData(this._getInitialData(), false);
this._setData(this._getInitialData(), false);
} else {
this.setData({}, false);
this._setData({}, false);
}

@@ -567,8 +567,15 @@ }

* Makes a deep copy of an object.
* @param {Object} obj The object to copy.
* @return {Object}
* @param {Object|Array} obj The object to copy.
* @return {Object|Array}
* @access protected
*/
_copy(obj) {
return extend(true, {}, obj);
let result;
if (Array.isArray(obj)) {
({ obj: result } = extend(true, {}, { obj }));
} else {
result = extend(true, {}, obj);
}
return result;
}

@@ -575,0 +582,0 @@ /**

@@ -5,3 +5,3 @@ {

"homepage": "https://homer0.github.io/wootils/",
"version": "2.2.1",
"version": "2.2.2",
"repository": "homer0/wootils",

@@ -8,0 +8,0 @@ "author": "Leonardo Apiwan (@homer0) <me@homer0.com>",

@@ -758,2 +758,53 @@ jest.unmock('/browser/simpleStorage');

it('should add and save a new array entry', () => {
// Given
const currentTime = 0;
global.Date = {
now: jest.fn(() => currentTime),
};
const storageKey = 'myStorage';
const entryKey = 'user';
const entryValue = ['Rosario', 'Charo', 'Charito'];
const mStorage = getStorageProxy();
const mWindow = {
localStorage: mStorage,
};
const options = {
window: mWindow,
storage: {
key: storageKey,
},
entries: {
enabled: true,
deleteExpired: false,
},
};
let sut = null;
let resultBeforeAdding = null;
let resultFromAdding = null;
let resultAfterAdding = null;
// When
sut = getSutProxy(options);
resultBeforeAdding = sut.getEntryValue(entryKey);
resultFromAdding = sut.addEntry(entryKey, entryValue);
resultAfterAdding = sut.getEntryValue(entryKey);
// Then
expect(resultBeforeAdding).toBeNull();
expect(resultFromAdding).toEqual(entryValue);
expect(resultAfterAdding).toEqual(entryValue);
expect(mStorage.mocks.get).toHaveBeenCalledTimes(1);
expect(mStorage.mocks.get).toHaveBeenCalledWith(options.storage.key);
expect(mStorage.mocks.set).toHaveBeenCalledTimes(2);
expect(mStorage.mocks.set).toHaveBeenCalledWith(options.storage.key, '{}');
expect(mStorage.mocks.set).toHaveBeenCalledWith(
options.storage.key,
JSON.stringify({
[entryKey]: {
time: currentTime,
value: entryValue,
},
})
);
});
it('should add a new entry but not save it', () => {

@@ -760,0 +811,0 @@ // Given

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