-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.js
More file actions
68 lines (60 loc) · 1.63 KB
/
Copy pathapp.js
File metadata and controls
68 lines (60 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
This file just illustrates the usage of node module called 'pool'.
More about pool at https://github.com/samyakbhuta/pool.js
*/
/*
var pool = require("pool");
Will work if you have already install using 'npm install pool'
*/
var pool = require("./pool");
/*
function : addedKeyValue
A callback function which is passed to addKeyValue function.
Basically, this function is called at the end of execution
of the function where it is passed as callback. In this case
to function addKeyValue.
Just prints the "Added" to the console.
*/
var addedKeyValue = function (){
console.log("Added");
}
/*
function : showValue
A callback function which is passed to fetchValue function.
Basically, this function is called at the end of execution
of the function where it is passed as callback. In this case
to function fetchValue.
It once called prints the value supplied to it on console.
*/
var showValue = function (value){
console.log(value);
}
/*
Shows the total count of the pool at the time of call.
*/
var showSize = function (size){
console.log(size);
}
/*
Adding some key/values
*/
pool.addKeyValue("A","Apple",addedKeyValue);
pool.addKeyValue("B","Banana",addedKeyValue);
pool.addKeyValue("O","Orange",addedKeyValue);
pool.addKeyValue("K","Kiwi",addedKeyValue);
/*
Checking out the total count of key/value pair present in the pool.
*/
pool.size(showSize);
/*
Fetching the value based on key. The callback function actually carries the return value and prints it on console.
*/
pool.fetchValue("K",showValue)
/*
Listing down all the key/value pairs in pool.
*/
pool.enumerate();
/*
Get the pool for direct access to it.
*/
myData = pool.getPool();