Skip to content

Commit af91094

Browse files
committed
2 parents 751df3c + 5b445cb commit af91094

File tree

10 files changed

+1147
-311
lines changed

10 files changed

+1147
-311
lines changed

README.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ Cache data using JavaScript in the browser.
55
### Status
66

77
[![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/yusufshakeel/dyCacheJS)
8-
[![npm version](https://img.shields.io/badge/npm-1.4.0-blue.svg)](https://www.npmjs.com/package/dycachejs)
8+
[![npm version](https://img.shields.io/badge/npm-1.5.0-blue.svg)](https://www.npmjs.com/package/dycachejs)
99
[![Build Status](https://travis-ci.org/yusufshakeel/dyCacheJS.svg?branch=master)](https://travis-ci.org/yusufshakeel/dyCacheJS)
1010
[![](https://data.jsdelivr.com/v1/package/npm/dycachejs/badge)](https://www.jsdelivr.com/package/npm/dycachejs)
1111

12+
1213
### Getting Started
1314
* Download the [latest release](https://github.com/yusufshakeel/dyCacheJS/releases) of the project.
1415
* Clone the repo: `git clone https://github.com/yusufshakeel/dyCacheJS.git`
@@ -19,10 +20,21 @@ Cache data using JavaScript in the browser.
1920
### Documentation
2021
Check the `index.html` file of this project.
2122

23+
2224
### License
2325
It's free and released under [MIT License](https://github.com/yusufshakeel/dyCacheJS/blob/master/LICENSE) Copyright (c) 2018 Yusuf Shakeel
2426

27+
2528
### Donate
2629
Feeling generous :-) Buy me a cup of tea.
2730

28-
[Donate via PayPal](https://www.paypal.me/yusufshakeel)
31+
[Donate via PayPal](https://www.paypal.me/yusufshakeel)
32+
33+
34+
### How to setup?
35+
36+
Run `npm install` to install all the packages.
37+
38+
Then run `npm run all` to build and run the tests.
39+
40+
You will get the minified file inside `dist/js` directory.

dist/js/dyCache.min.js

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

index.html

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,31 @@ <h4><code>purge()</code></h4>
301301
<a name="array-methods"></a>
302302
<h4 class="text-center"><a href="#array-methods">Array Methods</a></h4>
303303

304+
<!-- arrInit() -->
305+
<a name="arrInit"></a>
306+
<h4><code>arrInit(key)</code></h4>
307+
308+
<p>This will create a new array referred by <code>key</code> in the cache.</p>
309+
310+
<p>If array referred by <code>key</code> exists in the cache then it is overwritten.</p>
311+
312+
<pre><code>obj.arrInit('users'); // create a new array by the name users</code></pre>
313+
314+
<div>
315+
<a class="btn btn-primary"
316+
role="button"
317+
data-toggle="collapse"
318+
href="#collapse-arrInit"
319+
aria-expanded="false"
320+
aria-controls="collapse-arrInit">Output</a>
321+
</div>
322+
<div class="collapse" id="collapse-arrInit">
323+
</div>
324+
325+
<!-- arrInit() ends here -->
326+
327+
<hr>
328+
304329
<!-- arrPush() -->
305330
<a name="arrPush"></a>
306331
<h4><code>arrPush(key, value)</code></h4>
@@ -683,6 +708,31 @@ <h4><code>arrDeleteElems(key, start, [deleteCount])</code></h4>
683708
<a name="object-methods"></a>
684709
<h4 class="text-center"><a href="#object-methods">Object Methods</a></h4>
685710

711+
<!-- oInit() -->
712+
<a name="oInit"></a>
713+
<h4><code>oInit(key)</code></h4>
714+
715+
<p>This will create a new object in the cache by the name <code>key</code>.</p>
716+
717+
<p>If object referred by <code>key</code> exists in the cache then it will be overwritten.</p>
718+
719+
<pre><code>obj.oInit('players'); // creates a new object players</code></pre>
720+
721+
<div>
722+
<a class="btn btn-primary"
723+
role="button"
724+
data-toggle="collapse"
725+
href="#collapse-oInit"
726+
aria-expanded="false"
727+
aria-controls="collapse-oInit">Output</a>
728+
</div>
729+
<div class="collapse" id="collapse-oInit">
730+
</div>
731+
732+
<!-- oInit() ends here -->
733+
734+
<hr>
735+
686736
<!-- oSet() -->
687737
<a name="oSet"></a>
688738
<h4><code>oSet(key, oKey, oValue)</code></h4>

src/js/dyCache.forTest.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ var dyCache = /** @class */ (function () {
7878
dyCache.prototype.get = function (key) {
7979
return this._cache[key];
8080
};
81+
/**
82+
* This will initialise a new array in the cache and will refer it by key.
83+
* @param {string} key
84+
*/
85+
dyCache.prototype.arrInit = function (key) {
86+
this._cache[key] = [];
87+
};
8188
/**
8289
* This will push new value in an array at the right side.
8390
*
@@ -339,6 +346,13 @@ var dyCache = /** @class */ (function () {
339346
return this._cache[key].splice(start, deleteCount);
340347
}
341348
};
349+
/**
350+
* This will initialise a new object in the cache and will refer it by key.
351+
* @param {string} key
352+
*/
353+
dyCache.prototype.oInit = function (key) {
354+
this._cache[key] = {};
355+
};
342356
/**
343357
* This will create an object by the reference key in the cache.
344358
* Then it will add a property oKey and assign the value oValue.

0 commit comments

Comments
 (0)