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

storage-manager-ts

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

storage-manager-ts - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

2

lib/index.d.ts

@@ -9,3 +9,3 @@ export { LocalStorage } from './local-storage';

/**
* Returning if the keys match with a regex, * will indicate that an a key starts with the regex after the *
* Returning if a key match with a regex, * will indicate that an a key starts with the regex after the *
* @param regex The regex to filter the key with

@@ -12,0 +12,0 @@ * @param key The key to filter with the regex

@@ -21,3 +21,3 @@ "use strict";

/**
* Returning if the keys match with a regex, * will indicate that an a key starts with the regex after the *
* Returning if a key match with a regex, * will indicate that an a key starts with the regex after the *
* @param regex The regex to filter the key with

@@ -24,0 +24,0 @@ * @param key The key to filter with the regex

@@ -0,0 +0,0 @@ export declare class LocalStorage {

@@ -0,0 +0,0 @@ "use strict";

{
"name": "storage-manager-ts",
"version": "1.0.3",
"version": "1.0.4",
"description": "A storage manager that supports storage managing with local and Redis storages",

@@ -10,3 +10,5 @@ "main": "lib/index.js",

"test": "mocha -r ts-node/register",
"local-storage-testing": "npm run test tests/local-storage.ts"
"unit-tests": "npm run test tests/local-storage.ts",
"pre-deploy": "npm run unit-tests && npm run build",
"deploy": "npm-deploy storage-manager-ts"
},

@@ -28,5 +30,2 @@ "repository": {

"homepage": "https://github.com/danitseitlin/storage-manager-ts#readme",
"dependencies": {
"tedis": "^0.1.12"
},
"devDependencies": {

@@ -38,2 +37,3 @@ "@types/chai": "^4.2.7",

"mocha": "^7.0.1",
"npm-package-deployer": ">0.0.1",
"ts-node": "^8.5.4",

@@ -40,0 +40,0 @@ "typescript": "^3.7.4"

@@ -1,73 +0,27 @@

# storage-manager-ts
A storage manager that supports storage managing in local-storage and redis
# Storage Manager · [![GitHub license](https://img.shields.io/badge/license-BSD%203%20Clause-blue.svg)](https://github.com/danitseitlin/storage-manager-ts/blob/master/LICENSE) [![npm version](http://img.shields.io/npm/v/storage-manager-ts.svg?style=flat)](https://npmjs.org/package/storage-manager-ts "View this project on npm") ![CI](https://github.com/danitseitlin/storage-manager-ts/workflows/CI/badge.svg)
## About
A project that contains utilities for local storage & general storage purposes
## Local Storage
### Initialize your storage manager:
## Quick start
### Initialize your local storage manager:
```
import { LocalStorage } from 'storage-manager-ts';
const storage = new LocalStorage();
const value = storage.get('key');
```
### Get a key:
```
const keyAsString = storage.get('myKey', false);
//by default the response is in json form
const keyAsJson = storage.get('myKey');
//or you could give it a true value
const keyAsJson2 = storage.get('myKey', true);
```
## Local storage functions list
| Function | Description |
|:---------- |:--------------------------------------------------------------------------------------------------------- |
| get | Returning the value of a key |
| set | Setting the value of a key |
| delete | Deleting a key |
| getKeys | Returning all the keys |
| convertKeyListToJSON | Building a JSON of the key + value |
### Set a key:
The value type is any and that means you have the flexibily to set any value you want!
```
//Set a key with string as value
storage.set('myKey', 'myValue');
//Set a key with number as value
storage.set('myKey', 5);
//Set a key with JSON as value
storage.set('myKey', { 'arg1': 'value1' });
```
## Helper functions list
| Function | Description |
|:---------- |:--------------------------------------------------------------------------------------------------------- |
| filterKeys | Returning if the keys match with a regex, * will indicate that an a key starts with the regex after the * |
| filterKey | Returning if a key match with a regex, * will indicate that an a key starts with the regex after the * |
### Remove a key:
```
//Removing the key from the storage
storage.delete('myKey');
```
### Filtering keys by regex:
```
storage.set('myKey1', '1');
storage.set('myKey2', '2');
storage.set('myKey3', '3');
//use * to mention a start of the key
//Getting all of the key names starting with 'myKey'
const keys: string[] = storage.filterKeys({start: 'myKey'});
```
### Getting key values by list:
```
storage.set('myKey1', '1');
storage.set('myKey2', '2');
storage.set('myKey3', '3');
//Getting all of the key names starting with 'myKey'
const keys: string[] = storage.filterKeys({start: 'myKey'});
//Getting all of their values
const values: any[] = storage.getKeysByList(keys);
```
### Comparing keys by regex:
```
storage.set('myKey1', '1');
storage.set('myBoy', 'yay');
//Getting all of the key names starting with 'my'
const keys: string[] = storage.filterKeys({ start: 'my'});
const regex: string = '*myKey';
//printing all of the comparisons of the keys to the second regex
for(let i = 0; i < keys.length; i++) {
//checking which keys starting with 'my' also start with 'myKey'
const comparison: boolean = storage.compareKeys({start: 'myKey'}, keys[i]);
console.log(`key ${keys[i]} comparison for regex {start: 'myKey'} is ${comparison}`);
}
```
![Unit testing](https://github.com/danitseitlin/storage-manager-ts/workflows/Unit%20testing/badge.svg)

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