@thzero/library_server 0.18.6 → 0.18.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +93 -93
- package/boot/index.js +466 -466
- package/boot/plugins/admin/index.js +6 -6
- package/boot/plugins/admin/news.js +33 -33
- package/boot/plugins/admin/users.js +33 -33
- package/boot/plugins/api.js +64 -64
- package/boot/plugins/apiFront.js +31 -31
- package/boot/plugins/index.js +70 -70
- package/boot/plugins/news.js +44 -44
- package/boot/plugins/users.js +46 -46
- package/boot/plugins/usersExtended.js +32 -32
- package/constants.js +45 -45
- package/data/baseNews.js +42 -42
- package/data/baseSettingsUser.js +9 -9
- package/data/baseUser.js +28 -28
- package/data/index.js +24 -24
- package/data/named.js +20 -20
- package/errors/tokenExpired.js +7 -7
- package/license.md +8 -8
- package/openSource.js +66 -66
- package/package.json +38 -38
- package/repository/index.js +182 -182
- package/repository/usageMetrics/devnull.js +16 -16
- package/routes/index.js +76 -76
- package/service/admin/baseNews.js +45 -45
- package/service/admin/index.js +130 -130
- package/service/admin/news.js +6 -6
- package/service/admin/users.js +107 -107
- package/service/baseSecurity.js +183 -183
- package/service/baseUser.js +122 -122
- package/service/communication.js +6 -6
- package/service/config.js +37 -37
- package/service/crypto.js +16 -16
- package/service/discovery/index.js +6 -6
- package/service/discovery/resources/index.js +101 -101
- package/service/external.js +19 -19
- package/service/externalRest.js +19 -19
- package/service/index.js +20 -20
- package/service/monitoring.js +12 -12
- package/service/news/base.js +59 -59
- package/service/news/index.js +6 -6
- package/service/news/validation/index.js +6 -6
- package/service/plans.js +31 -31
- package/service/restCommunication.js +21 -21
- package/service/usageMetrics.js +84 -84
- package/service/utility.js +188 -188
- package/service/version.js +37 -37
- package/utility/injector.js +59 -59
- package/utility/internalIp/index.js +48 -48
- package/utility/list/doubleLinked.js +88 -88
- package/utility/list/priorityQueue.js +109 -109
- package/utility/list/queue.js +72 -72
- package/utility/os.js +20 -20
package/utility/list/queue.js
CHANGED
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
/*
|
|
2
|
-
|
|
3
|
-
Queue.js
|
|
4
|
-
|
|
5
|
-
A function to represent a queue
|
|
6
|
-
|
|
7
|
-
Created by Kate Morley - http://code.iamkate.com/ - and released under the terms
|
|
8
|
-
of the CC0 1.0 Universal legal code:
|
|
9
|
-
|
|
10
|
-
http://creativecommons.org/publicdomain/zero/1.0/legalcode
|
|
11
|
-
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
/* Creates a new queue. A queue is a first-in-first-out (FIFO) data structure -
|
|
15
|
-
* items are added to the end of the queue and removed from the front.
|
|
16
|
-
*/
|
|
17
|
-
function Queue(){
|
|
18
|
-
|
|
19
|
-
// initialise the queue and offset
|
|
20
|
-
var queue = [];
|
|
21
|
-
var offset = 0;
|
|
22
|
-
|
|
23
|
-
// Returns the length of the queue.
|
|
24
|
-
this.length = function(){
|
|
25
|
-
return (queue.length - offset);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// Returns true if the queue is empty, and false otherwise.
|
|
29
|
-
this.isEmpty = function(){
|
|
30
|
-
return (queue.length == 0);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/* Enqueues the specified item. The parameter is:
|
|
34
|
-
*
|
|
35
|
-
* item - the item to enqueue
|
|
36
|
-
*/
|
|
37
|
-
this.enqueue = function(item){
|
|
38
|
-
queue.push(item);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/* Dequeues an item and returns it. If the queue is empty, the value
|
|
42
|
-
* 'undefined' is returned.
|
|
43
|
-
*/
|
|
44
|
-
this.dequeue = function(){
|
|
45
|
-
|
|
46
|
-
// if the queue is empty, return immediately
|
|
47
|
-
if (queue.length == 0) return undefined;
|
|
48
|
-
|
|
49
|
-
// store the item at the front of the queue
|
|
50
|
-
var item = queue[offset];
|
|
51
|
-
|
|
52
|
-
// increment the offset and remove the free space if necessary
|
|
53
|
-
if (++ offset * 2 >= queue.length){
|
|
54
|
-
queue = queue.slice(offset);
|
|
55
|
-
offset = 0;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// return the dequeued item
|
|
59
|
-
return item;
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/* Returns the item at the front of the queue (without dequeuing it). If the
|
|
64
|
-
* queue is empty then undefined is returned.
|
|
65
|
-
*/
|
|
66
|
-
this.peek = function(){
|
|
67
|
-
return (queue.length > 0 ? queue[offset] : undefined);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export default Queue;
|
|
1
|
+
/*
|
|
2
|
+
|
|
3
|
+
Queue.js
|
|
4
|
+
|
|
5
|
+
A function to represent a queue
|
|
6
|
+
|
|
7
|
+
Created by Kate Morley - http://code.iamkate.com/ - and released under the terms
|
|
8
|
+
of the CC0 1.0 Universal legal code:
|
|
9
|
+
|
|
10
|
+
http://creativecommons.org/publicdomain/zero/1.0/legalcode
|
|
11
|
+
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/* Creates a new queue. A queue is a first-in-first-out (FIFO) data structure -
|
|
15
|
+
* items are added to the end of the queue and removed from the front.
|
|
16
|
+
*/
|
|
17
|
+
function Queue(){
|
|
18
|
+
|
|
19
|
+
// initialise the queue and offset
|
|
20
|
+
var queue = [];
|
|
21
|
+
var offset = 0;
|
|
22
|
+
|
|
23
|
+
// Returns the length of the queue.
|
|
24
|
+
this.length = function(){
|
|
25
|
+
return (queue.length - offset);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Returns true if the queue is empty, and false otherwise.
|
|
29
|
+
this.isEmpty = function(){
|
|
30
|
+
return (queue.length == 0);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/* Enqueues the specified item. The parameter is:
|
|
34
|
+
*
|
|
35
|
+
* item - the item to enqueue
|
|
36
|
+
*/
|
|
37
|
+
this.enqueue = function(item){
|
|
38
|
+
queue.push(item);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/* Dequeues an item and returns it. If the queue is empty, the value
|
|
42
|
+
* 'undefined' is returned.
|
|
43
|
+
*/
|
|
44
|
+
this.dequeue = function(){
|
|
45
|
+
|
|
46
|
+
// if the queue is empty, return immediately
|
|
47
|
+
if (queue.length == 0) return undefined;
|
|
48
|
+
|
|
49
|
+
// store the item at the front of the queue
|
|
50
|
+
var item = queue[offset];
|
|
51
|
+
|
|
52
|
+
// increment the offset and remove the free space if necessary
|
|
53
|
+
if (++ offset * 2 >= queue.length){
|
|
54
|
+
queue = queue.slice(offset);
|
|
55
|
+
offset = 0;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// return the dequeued item
|
|
59
|
+
return item;
|
|
60
|
+
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/* Returns the item at the front of the queue (without dequeuing it). If the
|
|
64
|
+
* queue is empty then undefined is returned.
|
|
65
|
+
*/
|
|
66
|
+
this.peek = function(){
|
|
67
|
+
return (queue.length > 0 ? queue[offset] : undefined);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export default Queue;
|
package/utility/os.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import os from 'os';
|
|
2
|
-
|
|
3
|
-
class OsUtility {
|
|
4
|
-
static get isLinux() {
|
|
5
|
-
const type = os.type();
|
|
6
|
-
return (/^linux/i.test(type) || /^freebsd/i.test(type) || /^darwin/i.test(type));
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
static get isMac() {
|
|
10
|
-
const type = os.type();
|
|
11
|
-
return (/^darwin/i.test(type));
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
static get isWin() {
|
|
15
|
-
const type = os.type();
|
|
16
|
-
return (/^win/i.test(type));
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export default OsUtility;
|
|
1
|
+
import os from 'os';
|
|
2
|
+
|
|
3
|
+
class OsUtility {
|
|
4
|
+
static get isLinux() {
|
|
5
|
+
const type = os.type();
|
|
6
|
+
return (/^linux/i.test(type) || /^freebsd/i.test(type) || /^darwin/i.test(type));
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
static get isMac() {
|
|
10
|
+
const type = os.type();
|
|
11
|
+
return (/^darwin/i.test(type));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
static get isWin() {
|
|
15
|
+
const type = os.type();
|
|
16
|
+
return (/^win/i.test(type));
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export default OsUtility;
|