Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/brandoncorbin/string-store
Storage in a string
https://github.com/brandoncorbin/string-store
javascript storage string
Last synced: 17 days ago
JSON representation
Storage in a string
- Host: GitHub
- URL: https://github.com/brandoncorbin/string-store
- Owner: brandoncorbin
- Created: 2017-10-06T20:57:23.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-10-08T20:14:05.000Z (over 7 years ago)
- Last Synced: 2024-12-12T05:00:17.293Z (27 days ago)
- Topics: javascript, storage, string
- Language: JavaScript
- Size: 29.3 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# String Store!
Storage in a string - or something like that. I needed a way to pass around a light way set of key values without using JSON. The values will never be a complex object, so serializing them like a URL seemed like a half decent way to go
## What?
It turns ``active=true&tacos=good`` in to ``{ active: true, tacos: 'good' }`` and vice versa.
## Installation
```
npm install string-store --save
```## Example
```
let StringStore = require('string-store');
let config = new StringStore('name=brandon&active=true');
console.log(config.get('active'));
```### Add/Set Item
```
config.set('age',40);
config.set('family',4);
```### Remove Item
```
config.remove('age');
```### Get Item
```
config.get('family'); // output 4
```### Get as String
```
config.toString(); // name=brandon&active=true&family=4
```### Get as Object
```
config.toObject(); // outpus{
name : 'brandon',
active : true,
family: 4
}```