Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
storage-engine
Advanced tools
Storage Engine is an abstraction on the AsyncStorage
API of React-Native, as
stated in their documentation:
It is recommended that you use an abstraction on top of AsyncStorage instead of AsyncStorage directly for anything more than light usage since it operates globally.
So there you go, an abstraction that aims to make working with the AsyncStorage
API a bit more developer friendly. The major selling point of this module is
the fact that it infuses the EventEmitter
pattern with the AsyncStorage
API
which will allow you to listen to any modification that you make to the storage
(while using this module).
This project is released in the public npm registry and can be installed using:
npm install --save storage-engine
Please note that this module is designed for react-native
and therefor has
a peerDependency upon it.
The StorageEngine
will emit an event with the name of the key as event name.
This allows you to subscribe to any operation that might affect the key.
import StorageEngine from 'storage-engine';
const storage = new StorageEmitter();
//
// Subscribe to changes to the `foobar` key.
//
storage.on('foobar', (action, ...args) => {
if (action === 'setItem') {
console.log('foobar has been updated to', ...args);
}
});
await storage.setItem('foobar', 'what is going on');
The following API methods are available:
<key>
as event name.Retrieve the item from async Storage. It accepts the following arguments:
name
(string), Name of the key that needs to be retrieved.If no value is found, null
will be returned instead.
const name = await storage.getItem('name');
console.log(name); // what ever value was stored.
<key>
as event name.Store the item from async Storage. It accepts the following arguments:
name
(string), Name of the key that needs to be retrieved.value
(string), Value that needs to be stored.await storage.setItem('name', 'value');
const name = await storage.getItem('name');
console.log(name); // value
<key>
as event name.Removes the item from async Storage. It accepts the following arguments:
name
(string), Name of the key that needs to be removed.await storage.removeItem('name');
const name = await storage.getItem('name');
console.log(name); // null
<key>
as event name.It merges the given value with the previous stored value. It accepts the following arguments:
name
(string), Name of the key that needs to be removed.value
, (string), Value that needs to be merged.await storage.setItem('name', '{"bar":"baz"}');
await storage.mergeItem('name', '{"foo":"bar"}');
const name = await storage.getItem('name'); // { bar: baz, foo: bar }
<methodName>
as event name.Removes all items from async Storage.
await storage.clear();
<methodName>
as event name.Flushes any pending requests using a single batch call to get the data.
await storage.flushGetRequests();
<key>
as event name for each key.1.0.1
FAQs
EventEmitter abstraction on top the React-Native AsyncStorage API
The npm package storage-engine receives a total of 10,289 weekly downloads. As such, storage-engine popularity was classified as popular.
We found that storage-engine demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.