Skip to content

Commit 2055f6e

Browse files
committed
stack methods example
1 parent a34804e commit 2055f6e

8 files changed

Lines changed: 324 additions & 6 deletions

File tree

dist/js/dyCache.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.html

Lines changed: 244 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ <h3 class="text-center">Content</h3>
9595
<li><a href="#cache-methods">Cache Methods</a></li>
9696
<li><a href="#array-methods">Array Methods</a></li>
9797
<li><a href="#object-methods">Object Methods</a></li>
98+
<li><a href="#stack-methods">Stack Methods</a></li>
9899
</ul>
99100

100101
<hr>
@@ -866,6 +867,249 @@ <h4><code>oDel(key, oKey)</code></h4>
866867

867868
<!-- oDel() ends here -->
868869

870+
<hr>
871+
872+
<a name="stack-methods"></a>
873+
<h4 class="text-center"><a href="#stack-methods">Stack Methods</a></h4>
874+
875+
<!-- stackInit() -->
876+
<a name="stackInit"></a>
877+
<h4><code>stackInit(key)</code></h4>
878+
879+
<p>This will initialise a stack referred by <code>key</code>
880+
in the cache.</p>
881+
882+
<pre><code>obj.stackInit('myStack');</code></pre>
883+
884+
<div>
885+
<a class="btn btn-primary"
886+
role="button"
887+
data-toggle="collapse"
888+
href="#collapse-stackInit"
889+
aria-expanded="false"
890+
aria-controls="collapse-stackInit">Output</a>
891+
</div>
892+
<div class="collapse" id="collapse-stackInit">
893+
</div>
894+
895+
<!-- stackInit() ends here -->
896+
897+
<hr>
898+
899+
<!-- stackExists() -->
900+
<a name="stackExists"></a>
901+
<h4><code>stackExists(key)</code></h4>
902+
903+
<p>This will check if the stack referred by <code>key</code>
904+
exists in the cache.</p>
905+
906+
<p>Return <code>true</code> if stack exists. Otherwise, <code>false</code>.</p>
907+
908+
<pre><code>obj.stackExists('myStack');</code></pre>
909+
910+
<div>
911+
<a class="btn btn-primary"
912+
role="button"
913+
data-toggle="collapse"
914+
href="#collapse-stackExists"
915+
aria-expanded="false"
916+
aria-controls="collapse-stackExists">Output</a>
917+
</div>
918+
<div class="collapse" id="collapse-stackExists">
919+
</div>
920+
921+
<!-- stackExists() ends here -->
922+
923+
<hr>
924+
925+
<!-- stackPush() -->
926+
<a name="stackPush"></a>
927+
<h4><code>stackPush(key, value)</code></h4>
928+
929+
<p>This will push a <code>value</code> in the stack referred by
930+
<code>key</code> in the cache.</p>
931+
932+
<p><code>value</code> can be a number, string, array or object.</p>
933+
934+
<pre><code>obj.stackPush('myStack', 10); // push number</code></pre>
935+
<pre><code>obj.stackPush('myStack', 'Yusuf Shakeel'); // push string</code></pre>
936+
<pre><code>obj.stackPush('myStack', [1, 2]); // push array</code></pre>
937+
<pre><code>obj.stackPush('myStack', { a: 10 }); // push object</code></pre>
938+
939+
<div>
940+
<a class="btn btn-primary"
941+
role="button"
942+
data-toggle="collapse"
943+
href="#collapse-stackPush"
944+
aria-expanded="false"
945+
aria-controls="collapse-stackPush">Output</a>
946+
</div>
947+
<div class="collapse" id="collapse-stackPush">
948+
</div>
949+
950+
<!-- stackPush() ends here -->
951+
952+
<hr>
953+
954+
<!-- stackPeek() -->
955+
<a name="stackPeek"></a>
956+
<h4><code>stackPeek(key)</code></h4>
957+
958+
<p>This will return the top element of the stack referred by
959+
<code>key</code> in the cache.</p>
960+
961+
<p>Will return <code>null</code> if stack does not exists.</p>
962+
963+
<pre><code>obj.stackPeek('myStack');</code></pre>
964+
965+
<div>
966+
<a class="btn btn-primary"
967+
role="button"
968+
data-toggle="collapse"
969+
href="#collapse-stackPeek"
970+
aria-expanded="false"
971+
aria-controls="collapse-stackPeek">Output</a>
972+
</div>
973+
<div class="collapse" id="collapse-stackPeek">
974+
</div>
975+
976+
<!-- stackPeek() ends here -->
977+
978+
<hr>
979+
980+
<!-- stackPop() -->
981+
<a name="stackPop"></a>
982+
<h4><code>stackPop(key)</code></h4>
983+
984+
<p>This will pop the top element from the stack referred by
985+
<code>key</code> in the cache.</p>
986+
987+
<p>Will return <code>undefined</code> if stack does not exists.</p>
988+
989+
<pre><code>obj.stackPop('myStack');</code></pre>
990+
991+
<div>
992+
<a class="btn btn-primary"
993+
role="button"
994+
data-toggle="collapse"
995+
href="#collapse-stackPop"
996+
aria-expanded="false"
997+
aria-controls="collapse-stackPop">Output</a>
998+
</div>
999+
<div class="collapse" id="collapse-stackPop">
1000+
</div>
1001+
1002+
<!-- stackPop() ends here -->
1003+
1004+
<hr>
1005+
1006+
<!-- stackLength() -->
1007+
<a name="stackLength"></a>
1008+
<h4><code>stackLength(key)</code></h4>
1009+
1010+
<p>This will return total number of elements in the stack referred by
1011+
<code>key</code> in the cache.</p>
1012+
1013+
<p>On success return number of elements in the stack. Otherwise -1.</p>
1014+
1015+
<pre><code>obj.stackLength('myStack');</code></pre>
1016+
1017+
<div>
1018+
<a class="btn btn-primary"
1019+
role="button"
1020+
data-toggle="collapse"
1021+
href="#collapse-stackLength"
1022+
aria-expanded="false"
1023+
aria-controls="collapse-stackLength">Output</a>
1024+
</div>
1025+
<div class="collapse" id="collapse-stackLength">
1026+
</div>
1027+
1028+
<!-- stackLength() ends here -->
1029+
1030+
<hr>
1031+
1032+
<!-- stackIsEmpty() -->
1033+
<a name="stackIsEmpty"></a>
1034+
<h4><code>stackIsEmpty(key)</code></h4>
1035+
1036+
<p>This will check is the stack referred by
1037+
<code>key</code> in the cache is empty.</p>
1038+
1039+
<p>If empty will return <code>true</code>. Otherwise, <code>false</code>.</p>
1040+
1041+
<p>If <code>key</code> does not exists then return <code>undefined</code>.</p>
1042+
1043+
<pre><code>obj.stackIsEmpty('myStack');</code></pre>
1044+
1045+
<div>
1046+
<a class="btn btn-primary"
1047+
role="button"
1048+
data-toggle="collapse"
1049+
href="#collapse-stackIsEmpty"
1050+
aria-expanded="false"
1051+
aria-controls="collapse-stackIsEmpty">Output</a>
1052+
</div>
1053+
<div class="collapse" id="collapse-stackIsEmpty">
1054+
</div>
1055+
1056+
<!-- stackIsEmpty() ends here -->
1057+
1058+
<hr>
1059+
1060+
<!-- stackPurge() -->
1061+
<a name="stackPurge"></a>
1062+
<h4><code>stackPurge(key)</code></h4>
1063+
1064+
<p>This will empty the stack referred by
1065+
<code>key</code> in the cache.</p>
1066+
1067+
<p>Will return <code>true</code> on success. Otherwise, <code>false</code>.</p>
1068+
1069+
<pre><code>obj.stackPurge('myStack');</code></pre>
1070+
1071+
<div>
1072+
<a class="btn btn-primary"
1073+
role="button"
1074+
data-toggle="collapse"
1075+
href="#collapse-stackPurge"
1076+
aria-expanded="false"
1077+
aria-controls="collapse-stackPurge">Output</a>
1078+
</div>
1079+
<div class="collapse" id="collapse-stackPurge">
1080+
</div>
1081+
1082+
<!-- stackPurge() ends here -->
1083+
1084+
<hr>
1085+
1086+
<!-- stackDelete() -->
1087+
<a name="stackDelete"></a>
1088+
<h4><code>stackDelete(key)</code></h4>
1089+
1090+
<p>This will delete the stack referred by
1091+
<code>key</code> from the cache.</p>
1092+
1093+
<p>Will return <code>true</code> on success. Otherwise, <code>false</code>.</p>
1094+
1095+
<pre><code>obj.stackDelete('myStack');</code></pre>
1096+
1097+
<div>
1098+
<a class="btn btn-primary"
1099+
role="button"
1100+
data-toggle="collapse"
1101+
href="#collapse-stackDelete"
1102+
aria-expanded="false"
1103+
aria-controls="collapse-stackDelete">Output</a>
1104+
</div>
1105+
<div class="collapse" id="collapse-stackDelete">
1106+
</div>
1107+
1108+
<!-- stackDelete() ends here -->
1109+
1110+
<hr>
1111+
1112+
8691113
</div>
8701114

8711115
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">

src/js/dyCache.forTest.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ var dyCache = /** @class */ (function () {
484484
return typeof this._cache[key] !== "undefined";
485485
};
486486
/**
487-
* This will return the last element in the stack referred by key
487+
* This will return the top element in the stack referred by key
488488
* in the cache.
489489
*
490490
* On success return the value. Otherwise, null.

src/js/dyCache.forTest.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/js/dyCache.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ var dyCache = /** @class */ (function () {
484484
return typeof this._cache[key] !== "undefined";
485485
};
486486
/**
487-
* This will return the last element in the stack referred by key
487+
* This will return the top element in the stack referred by key
488488
* in the cache.
489489
*
490490
* On success return the value. Otherwise, null.

0 commit comments

Comments
 (0)