Skip to content

Commit a4a5421

Browse files
committed
v2.1.0
- Migrate codebase to vanilla JS - No dependencies - Now it’s NPM package - See [old repository](https://github.com/VeliovGroup/Meteor-Client-Storage)
0 parents  commit a4a5421

14 files changed

+1192
-0
lines changed

.gitignore

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Logs
2+
logs
3+
*.log
4+
5+
# Runtime data
6+
pids
7+
*.pid
8+
*.seed
9+
10+
# Directory for instrumented libs generated by jscoverage/JSCover
11+
lib-cov
12+
13+
# Coverage directory used by tools like istanbul
14+
coverage
15+
16+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
17+
.grunt
18+
.idea
19+
**/.meteor
20+
*.lock
21+
22+
# Compiled binary addons (http://nodejs.org/api/addons.html)
23+
build/Release
24+
25+
# Dependency directory
26+
# Deployed apps should consider commenting this line out:
27+
# see https://npmjs.org/doc/faq.html#Should-I-check-my-node_modules-folder-into-git
28+
node_modules
29+
30+
# OSX.gitignore
31+
# https://github.com/github/gitignore/blob/master/Global/OSX.gitignore
32+
.DS_Store
33+
.AppleDouble
34+
.LSOverride
35+
36+
# Icon must end with two \r
37+
Icon
38+
39+
40+
# Thumbnails
41+
._*
42+
43+
# Files that might appear on external disk
44+
.Spotlight-V100
45+
.Trashes
46+
47+
# Directories potentially created on remote AFP share
48+
.AppleDB
49+
.AppleDesktop
50+
Network Trash Folder
51+
Temporary Items
52+
.apdisk
53+
54+
# cache files for sublime text
55+
*.tmlanguage.cache
56+
*.tmPreferences.cache
57+
*.stTheme.cache
58+
59+
# workspace files are user-specific
60+
*.sublime-workspace
61+
62+
# project files should be checked into the repository, unless a significant
63+
# proportion of contributors will probably not be using SublimeText
64+
*.sublime-project
65+
66+
# sftp configuration file
67+
sftp-config.json

.npm/package/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

.npm/package/README

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
This directory and the files immediately inside it are automatically generated
2+
when you change this package's NPM dependencies. Commit the files in this
3+
directory (npm-shrinkwrap.json, .gitignore, and this README) to source control
4+
so that others run the same versions of sub-dependencies.
5+
6+
You should NOT check in the node_modules directory that Meteor automatically
7+
creates; if you are using git, the .gitignore file tells git to ignore it.

.npm/package/npm-shrinkwrap.json

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.versions

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
allow-deny@1.0.5
2+
babel-compiler@6.9.0
3+
babel-runtime@0.1.10
4+
base64@1.0.9
5+
binary-heap@1.0.9
6+
blaze@2.1.8
7+
blaze-tools@1.0.9
8+
boilerplate-generator@1.0.9
9+
callback-hook@1.0.9
10+
check@1.2.3
11+
ddp@1.2.5
12+
ddp-client@1.2.8
13+
ddp-common@1.2.6
14+
ddp-server@1.2.8
15+
deps@1.0.12
16+
diff-sequence@1.0.6
17+
ecmascript@0.5.7
18+
ecmascript-runtime@0.3.12
19+
ejson@1.0.12
20+
geojson-utils@1.0.9
21+
html-tools@1.0.10
22+
htmljs@1.0.10
23+
id-map@1.0.8
24+
jquery@1.11.9
25+
local-test:ostrio:cstorage@2.1.0
26+
logging@1.1.14
27+
meteor@1.2.16
28+
minimongo@1.0.17
29+
modules@0.7.5
30+
modules-runtime@0.7.5
31+
mongo@1.1.9
32+
mongo-id@1.0.5
33+
npm-mongo@1.4.44
34+
observe-sequence@1.0.12
35+
ordered-dict@1.0.8
36+
ostrio:cstorage@2.1.0
37+
promise@0.8.3
38+
random@1.0.10
39+
reactive-var@1.0.10
40+
retry@1.0.8
41+
routepolicy@1.0.11
42+
spacebars@1.0.12
43+
spacebars-compiler@1.0.12
44+
tinytest@1.0.11
45+
tracker@1.0.14
46+
ui@1.0.11
47+
underscore@1.0.9
48+
webapp@1.3.10
49+
webapp-hashing@1.0.9

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Changelog
2+
======
3+
For full changelog see [releases on GitHub](https://github.com/VeliovGroup/Client-Storage/releases)

HISTORY.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
History
2+
======
3+
For full package history see [releases on GitHub](https://github.com/VeliovGroup/Client-Storage/releases)

LICENSE

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
Copyright (c) 2016, dr.dimitru (Dmitriy A.; Veliov Group, LLC)
2+
All rights reserved.
3+
4+
Redistribution and use in source and binary forms,
5+
with or without modification, are permitted provided
6+
that the following conditions are met:
7+
8+
1. Redistributions of source code must retain the
9+
above copyright notice, this list of conditions
10+
and the following disclaimer.
11+
12+
2. Redistributions in binary form must reproduce the
13+
above copyright notice, this list of conditions and
14+
the following disclaimer in the documentation and/or
15+
other materials provided with the distribution.
16+
17+
3. Neither the name of the copyright holder nor the
18+
names of its contributors may be used to endorse or
19+
promote products derived from this software without
20+
specific prior written permission.
21+
22+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25+
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
26+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
Client Storage
2+
========
3+
4+
- Bulletproof Client storage functions, `localStorage` with fall-back to `cookies`
5+
- Works in browser with disabled `localStorage` and `cookies`
6+
- __100%__ tests coverage
7+
8+
Install:
9+
========
10+
```shell
11+
npm install ClientStorage
12+
```
13+
14+
Install Meteor:
15+
========
16+
```shell
17+
meteor add ostrio:cstorage
18+
```
19+
20+
Require:
21+
========
22+
```jsx
23+
var ClientStorage = require('ClientStorage').ClientStorage;
24+
```
25+
26+
ES6 Import (Meteor):
27+
========
28+
```jsx
29+
import { ClientStorage } from 'meteor/ostrio:cstorage';
30+
```
31+
32+
33+
Usage:
34+
========
35+
#### Get
36+
- `ClientStorage.get(key)` - Read a record. If the key doesn't exist a null value will be returned.
37+
38+
#### Set
39+
- `ClientStorage.set('key', value)` - Create/overwrite a value in storage
40+
41+
#### Remove
42+
- `ClientStorage.remove(key)` - Remove a record
43+
44+
#### Has
45+
- `ClientStorage.has(key)` - Check whether a record exists, returns boolean value
46+
47+
#### Keys
48+
- `ClientStorage.keys()` - Returns an array of all storage keys
49+
50+
#### Empty
51+
- `ClientStorage.empty()` - Empty storage (remove all key/value pairs). __Use with caution! (*May remove cookies which was set not by you*)__
52+
53+
#### Use `cookies` only
54+
To use `cookies` as a driver for `ClientStorage` create new instance of `clientStorage` (*camel-case, first letter __lower-case__*)
55+
```js
56+
var csCookies = new clientStorage('cookies');
57+
```
58+
59+
#### Use `localStorage` only
60+
To use `localStorage` as a driver for `ClientStorage` create new instance of `clientStorage` (*camel-case, first letter __lower-case__*):
61+
```js
62+
var ClientStorage = require('ClientStorage').clientStorage;
63+
var csLocalStorage = new clientStorage('localStorage');
64+
```
65+
or in ES6:
66+
```jsx
67+
import { clientStorage } from 'meteor/ostrio:cstorage';
68+
let csLocalStorage = new clientStorage('localStorage');
69+
```
70+
71+
__Note:__ *All instances shares same cookies and localStorage records!*
72+
73+
74+
75+
Example:
76+
=========
77+
```javascript
78+
ClientStorage.set('locale', 'en'); // true
79+
ClientStorage.set('country', 'usa'); // true
80+
ClientStorage.set('gender', 'male'); // true
81+
82+
ClientStorage.get('gender'); // male
83+
84+
ClientStorage.has('locale'); // true
85+
ClientStorage.has('city'); // false
86+
87+
ClientStorage.keys(); // ['locale', 'country', 'gender']
88+
89+
ClientStorage.remove('locale'); // true
90+
ClientStorage.get('locale'); // null
91+
92+
ClientStorage.keys(); // ['country', 'gender']
93+
94+
ClientStorage.empty(); // true
95+
ClientStorage.keys(); // []
96+
97+
ClientStorage.empty(); // false
98+
```

0 commit comments

Comments
 (0)