@finsemble/finsemble-electron-adapter 0.0.0

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.
Files changed (152) hide show
  1. package/LICENSE +1 -0
  2. package/README.md +9 -0
  3. package/dist/app.d.ts +1 -0
  4. package/dist/app.js +3 -0
  5. package/dist/app.js.LICENSE.txt +334 -0
  6. package/dist/app.js.map +1 -0
  7. package/dist/deploy/deploymentHelpers.d.ts +46 -0
  8. package/dist/deploy/installer.d.ts +5 -0
  9. package/dist/deploy/packageCreator.d.ts +4 -0
  10. package/dist/e2o.d.ts +2 -0
  11. package/dist/e2o.js +2 -0
  12. package/dist/e2o.js.map +1 -0
  13. package/dist/exports.d.ts +16 -0
  14. package/dist/exports.js +3 -0
  15. package/dist/exports.js.LICENSE.txt +334 -0
  16. package/dist/exports.js.map +1 -0
  17. package/dist/logger/classes/LoggerMain.d.ts +30 -0
  18. package/dist/logger/classes/LoggerRenderer.d.ts +11 -0
  19. package/dist/logger/colorizer.d.ts +2 -0
  20. package/dist/logger/config.d.ts +12 -0
  21. package/dist/logger/formatters/basic.d.ts +2 -0
  22. package/dist/logger/main.d.ts +2 -0
  23. package/dist/logger/renderer.d.ts +1 -0
  24. package/dist/logger/transports/winston-daily-rotate-file.d.ts +2 -0
  25. package/dist/logger/transports/winston-terminal-transport.d.ts +2 -0
  26. package/dist/logger/types.d.ts +9 -0
  27. package/dist/main/AffinityGroupManager.d.ts +15 -0
  28. package/dist/main/BrowserViews.d.ts +39 -0
  29. package/dist/main/Config.d.ts +16 -0
  30. package/dist/main/DownloadManager.d.ts +31 -0
  31. package/dist/main/ExternalApplicationManager.d.ts +42 -0
  32. package/dist/main/IAB.d.ts +17 -0
  33. package/dist/main/IAC.d.ts +33 -0
  34. package/dist/main/Main.d.ts +6 -0
  35. package/dist/main/MainBus.d.ts +22 -0
  36. package/dist/main/MainSystem.d.ts +82 -0
  37. package/dist/main/MainWindow.d.ts +154 -0
  38. package/dist/main/Manifest.d.ts +13 -0
  39. package/dist/main/MonitorInfo.d.ts +4 -0
  40. package/dist/main/PermissionsManager.d.ts +12 -0
  41. package/dist/main/ScreenCapture.d.ts +7 -0
  42. package/dist/main/SplashScreen.d.ts +13 -0
  43. package/dist/main/appDataFolder.d.ts +9 -0
  44. package/dist/main/autoUpdaterWrapper.d.ts +37 -0
  45. package/dist/main/contentSecurity.d.ts +17 -0
  46. package/dist/main/contextMenu.d.ts +2 -0
  47. package/dist/main/download.d.ts +28 -0
  48. package/dist/main/getWindowIdentity.d.ts +3 -0
  49. package/dist/main/listeners.d.ts +7 -0
  50. package/dist/main/mainStore.d.ts +3 -0
  51. package/dist/main/preloads.d.ts +8 -0
  52. package/dist/main/protocolHandler.d.ts +11 -0
  53. package/dist/main/updateManager.d.ts +20 -0
  54. package/dist/makeInstaller.d.ts +9 -0
  55. package/dist/makeInstaller.js +3 -0
  56. package/dist/makeInstaller.js.LICENSE.txt +12 -0
  57. package/dist/makeInstaller.js.map +1 -0
  58. package/dist/permissions/chromePermissions.d.ts +59 -0
  59. package/dist/permissions/defaultWindowOptions.d.ts +385 -0
  60. package/dist/render/InterApplicationBus.d.ts +16 -0
  61. package/dist/render/Notification.d.ts +3 -0
  62. package/dist/render/RequestHelper.d.ts +23 -0
  63. package/dist/render/System.d.ts +72 -0
  64. package/dist/render/Window.d.ts +75 -0
  65. package/dist/render/renderHelpers.d.ts +1 -0
  66. package/dist/server/AppD.d.ts +18 -0
  67. package/dist/server/AppDStaticConfigPlugin.d.ts +8 -0
  68. package/dist/server/CosaicCloud.d.ts +21 -0
  69. package/dist/server/Progress.d.ts +26 -0
  70. package/dist/server/Server.d.ts +18 -0
  71. package/dist/server/SmartDesktop.d.ts +41 -0
  72. package/dist/server/SmartDesktopEndpoints.d.ts +106 -0
  73. package/dist/server/SmartDesktopStaticConfigPlugin.d.ts +10 -0
  74. package/dist/server/cssUtilities.d.ts +6 -0
  75. package/dist/server/writeJSON.d.ts +1 -0
  76. package/dist/startup/e2oLauncher.d.ts +1 -0
  77. package/dist/startup/runScriptInElectron.d.ts +6 -0
  78. package/dist/types/types.d.ts +144 -0
  79. package/dist/util.d.ts +24 -0
  80. package/exports.js +10 -0
  81. package/node_modules/electron-ipc-mock/.npmignore +2 -0
  82. package/node_modules/electron-ipc-mock/.travis.yml +8 -0
  83. package/node_modules/electron-ipc-mock/LICENSE +19 -0
  84. package/node_modules/electron-ipc-mock/README.md +42 -0
  85. package/node_modules/electron-ipc-mock/dist/constants.js +8 -0
  86. package/node_modules/electron-ipc-mock/dist/electron-ipc-mock.js +56 -0
  87. package/node_modules/electron-ipc-mock/dist/event.js +25 -0
  88. package/node_modules/electron-ipc-mock/dist/index.js +22 -0
  89. package/node_modules/electron-ipc-mock/dist/ipc-main.js +103 -0
  90. package/node_modules/electron-ipc-mock/dist/ipc-renderer.js +113 -0
  91. package/node_modules/electron-ipc-mock/dist/pipe.js +40 -0
  92. package/node_modules/electron-ipc-mock/dist/utils.js +33 -0
  93. package/node_modules/electron-ipc-mock/package.json +34 -0
  94. package/node_modules/image-size/LICENSE +9 -0
  95. package/node_modules/image-size/Readme.md +185 -0
  96. package/node_modules/image-size/bin/image-size.js +48 -0
  97. package/node_modules/image-size/dist/detector.d.ts +3 -0
  98. package/node_modules/image-size/dist/detector.js +30 -0
  99. package/node_modules/image-size/dist/index.d.ts +11 -0
  100. package/node_modules/image-size/dist/index.js +123 -0
  101. package/node_modules/image-size/dist/readUInt.d.ts +4 -0
  102. package/node_modules/image-size/dist/readUInt.js +11 -0
  103. package/node_modules/image-size/dist/types/bmp.d.ts +2 -0
  104. package/node_modules/image-size/dist/types/bmp.js +14 -0
  105. package/node_modules/image-size/dist/types/cur.d.ts +2 -0
  106. package/node_modules/image-size/dist/types/cur.js +19 -0
  107. package/node_modules/image-size/dist/types/dds.d.ts +2 -0
  108. package/node_modules/image-size/dist/types/dds.js +14 -0
  109. package/node_modules/image-size/dist/types/gif.d.ts +2 -0
  110. package/node_modules/image-size/dist/types/gif.js +16 -0
  111. package/node_modules/image-size/dist/types/icns.d.ts +2 -0
  112. package/node_modules/image-size/dist/types/icns.js +103 -0
  113. package/node_modules/image-size/dist/types/ico.d.ts +2 -0
  114. package/node_modules/image-size/dist/types/ico.js +70 -0
  115. package/node_modules/image-size/dist/types/interface.d.ts +14 -0
  116. package/node_modules/image-size/dist/types/interface.js +2 -0
  117. package/node_modules/image-size/dist/types/j2c.d.ts +2 -0
  118. package/node_modules/image-size/dist/types/j2c.js +15 -0
  119. package/node_modules/image-size/dist/types/jp2.d.ts +2 -0
  120. package/node_modules/image-size/dist/types/jp2.js +58 -0
  121. package/node_modules/image-size/dist/types/jpg.d.ts +2 -0
  122. package/node_modules/image-size/dist/types/jpg.js +123 -0
  123. package/node_modules/image-size/dist/types/ktx.d.ts +2 -0
  124. package/node_modules/image-size/dist/types/ktx.js +15 -0
  125. package/node_modules/image-size/dist/types/png.d.ts +2 -0
  126. package/node_modules/image-size/dist/types/png.js +34 -0
  127. package/node_modules/image-size/dist/types/pnm.d.ts +2 -0
  128. package/node_modules/image-size/dist/types/pnm.js +75 -0
  129. package/node_modules/image-size/dist/types/psd.d.ts +2 -0
  130. package/node_modules/image-size/dist/types/psd.js +14 -0
  131. package/node_modules/image-size/dist/types/svg.d.ts +2 -0
  132. package/node_modules/image-size/dist/types/svg.js +91 -0
  133. package/node_modules/image-size/dist/types/tga.d.ts +2 -0
  134. package/node_modules/image-size/dist/types/tga.js +14 -0
  135. package/node_modules/image-size/dist/types/tiff.d.ts +2 -0
  136. package/node_modules/image-size/dist/types/tiff.js +97 -0
  137. package/node_modules/image-size/dist/types/webp.d.ts +2 -0
  138. package/node_modules/image-size/dist/types/webp.js +58 -0
  139. package/node_modules/image-size/dist/types.d.ts +20 -0
  140. package/node_modules/image-size/dist/types.js +40 -0
  141. package/node_modules/image-size/package.json +68 -0
  142. package/node_modules/inherits/LICENSE +16 -0
  143. package/node_modules/inherits/README.md +42 -0
  144. package/node_modules/inherits/inherits.js +9 -0
  145. package/node_modules/inherits/inherits_browser.js +27 -0
  146. package/node_modules/inherits/package.json +29 -0
  147. package/node_modules/queue/LICENSE +8 -0
  148. package/node_modules/queue/index.d.ts +173 -0
  149. package/node_modules/queue/index.js +195 -0
  150. package/node_modules/queue/package.json +43 -0
  151. package/node_modules/queue/readme.md +221 -0
  152. package/package.json +106 -0
@@ -0,0 +1,8 @@
1
+ The MIT License (MIT)
2
+ Copyright (c) 2014 Jesse Tane <jesse.tane@gmail.com>
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5
+
6
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7
+
8
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,173 @@
1
+ // Type definitions for Queue 4.5.1
2
+ // Project: https://github.com/jessetane/queue
3
+ // Definitions by: Alex Miller <https://github.com/codex->
4
+
5
+ import { EventEmitter } from "events";
6
+
7
+ export interface Options {
8
+ /**
9
+ * Max number of jobs the queue should process concurrently.
10
+ *
11
+ * @default Infinity
12
+ */
13
+ concurrency?: number;
14
+
15
+ /**
16
+ * Milliseconds to wait for a job to execute its callback.
17
+ *
18
+ * @default 0
19
+ */
20
+ timeout?: number;
21
+
22
+ /**
23
+ * Ensures the queue is always running if jobs are available. Useful in situations where you are using a queue only for concurrency control.
24
+ *
25
+ * @default false
26
+ */
27
+ autostart?: boolean;
28
+
29
+ /**
30
+ * An array to set job callback arguments on.
31
+ *
32
+ * @default null
33
+ */
34
+ results?: any[];
35
+ }
36
+
37
+ interface Queue extends EventEmitter {
38
+ /**
39
+ * Max number of jobs the queue should process concurrently.
40
+ */
41
+ concurrency: number;
42
+
43
+ /**
44
+ * Milliseconds to wait for a job to execute its callback.
45
+ */
46
+ timeout: number;
47
+
48
+ /**
49
+ * Ensures the queue is always running if jobs are available.
50
+ */
51
+ autostart: boolean;
52
+
53
+ /**
54
+ * An array to set job callback arguments on.
55
+ */
56
+ results: any[] | null;
57
+
58
+ /**
59
+ * Jobs pending + jobs to process.
60
+ */
61
+ readonly length: number;
62
+
63
+ /**
64
+ * Adds one or more elements to the end of the Queue and returns the new length of the Queue.
65
+ *
66
+ * @param workers New workers of the Queue.
67
+ */
68
+ push(...workers: QueueWorker[]): number;
69
+
70
+ /**
71
+ * Adds one or more elements to the front of the Queue and returns the new length of the Queue.
72
+ *
73
+ * @param workers Workers to insert at the start of the Queue.
74
+ */
75
+ unshift(...workers: QueueWorker[]): number;
76
+
77
+ /**
78
+ * Adds and/or removes elements from the queue.
79
+ *
80
+ * @param start The zero-based location in the Queue from which to start removing elements.
81
+ * @param deleteCount The number of elements to remove.
82
+ */
83
+ splice(start: number, deleteCount?: number): Queue;
84
+
85
+ /**
86
+ * Adds and/or removes elements from the queue.
87
+ *
88
+ * @param start The zero-based location in the Queue from which to start removing elements.
89
+ * @param deleteCount The number of elements to remove.
90
+ * @param workers Workers to insert into the Queue in place of the deleted elements.
91
+ */
92
+ splice(start: number, deleteCount: number, ...workers: QueueWorker[]): Queue;
93
+
94
+ /**
95
+ * Removes the last element from the Queue and returns that element.
96
+ */
97
+ pop(): QueueWorker | undefined;
98
+
99
+ /**
100
+ * Removes the first element from the Queue and returns that element.
101
+ */
102
+ shift(): QueueWorker | undefined;
103
+
104
+ /**
105
+ * Extracts a section of the Queue and returns Queue.
106
+ *
107
+ * @param start The beginning of the specified portion of the Queue.
108
+ * @param end The end of the specified portion of the Queue.
109
+ */
110
+ slice(start?: number, end?: number): Queue;
111
+
112
+ /**
113
+ * Reverses the order of the elements of the Queue in place.
114
+ */
115
+ reverse(): Queue;
116
+
117
+ /**
118
+ * Returns the first (least) index of an element within the Queue equal to the specified value, or -1 if none is found.
119
+ *
120
+ * @param searchElement The value to locate in the Queue.
121
+ * @param fromIndex The Queue index at which to begin the search. If omitted, the search starts at index 0.
122
+ */
123
+ indexOf(searchElement: QueueWorker, fromIndex?: number): number;
124
+
125
+ /**
126
+ * Returns the last (greatest) index of an element within the Queue equal to the specified value, or -1 if none is found.
127
+ *
128
+ * @param searchElement The value to locate in the Queue.
129
+ * @param fromIndex The Queue index at which to begin the search. If omitted, the search starts at the last index in the Queue.
130
+ */
131
+ lastIndexOf(searchElement: QueueWorker, fromIndex?: number): number;
132
+
133
+ /**
134
+ * Starts the queue.
135
+ *
136
+ * @param callback Callback to be called when the queue empties or when an error occurs.
137
+ */
138
+ start(callback?: (error?: Error) => void): void;
139
+
140
+ /**
141
+ * Stops the queue.
142
+ */
143
+ stop(): void;
144
+
145
+ /**
146
+ * Stop and empty the queue immediately.
147
+ *
148
+ * @param error error of why the stop has occurred, to be passed to start callback if supplied.
149
+ */
150
+ end(error?: Error): void;
151
+ }
152
+
153
+ interface QueueConstructor {
154
+ (options?: Options): Queue;
155
+ new (options?: Options): Queue;
156
+ }
157
+
158
+ declare const Queue: QueueConstructor;
159
+
160
+ export default Queue;
161
+
162
+ export interface QueueWorker {
163
+ (callback?: QueueWorkerCallback): void;
164
+
165
+ /**
166
+ * Override queue timeout.
167
+ */
168
+ timeout?: number;
169
+ }
170
+
171
+ export interface QueueWorkerCallback {
172
+ (error?: Error, data?: Object): void;
173
+ }
@@ -0,0 +1,195 @@
1
+ var inherits = require('inherits')
2
+ var EventEmitter = require('events').EventEmitter
3
+
4
+ module.exports = Queue
5
+ module.exports.default = Queue
6
+
7
+ function Queue (options) {
8
+ if (!(this instanceof Queue)) {
9
+ return new Queue(options)
10
+ }
11
+
12
+ EventEmitter.call(this)
13
+ options = options || {}
14
+ this.concurrency = options.concurrency || Infinity
15
+ this.timeout = options.timeout || 0
16
+ this.autostart = options.autostart || false
17
+ this.results = options.results || null
18
+ this.pending = 0
19
+ this.session = 0
20
+ this.running = false
21
+ this.jobs = []
22
+ this.timers = {}
23
+ }
24
+ inherits(Queue, EventEmitter)
25
+
26
+ var arrayMethods = [
27
+ 'pop',
28
+ 'shift',
29
+ 'indexOf',
30
+ 'lastIndexOf'
31
+ ]
32
+
33
+ arrayMethods.forEach(function (method) {
34
+ Queue.prototype[method] = function () {
35
+ return Array.prototype[method].apply(this.jobs, arguments)
36
+ }
37
+ })
38
+
39
+ Queue.prototype.slice = function (begin, end) {
40
+ this.jobs = this.jobs.slice(begin, end)
41
+ return this
42
+ }
43
+
44
+ Queue.prototype.reverse = function () {
45
+ this.jobs.reverse()
46
+ return this
47
+ }
48
+
49
+ var arrayAddMethods = [
50
+ 'push',
51
+ 'unshift',
52
+ 'splice'
53
+ ]
54
+
55
+ arrayAddMethods.forEach(function (method) {
56
+ Queue.prototype[method] = function () {
57
+ var methodResult = Array.prototype[method].apply(this.jobs, arguments)
58
+ if (this.autostart) {
59
+ this.start()
60
+ }
61
+ return methodResult
62
+ }
63
+ })
64
+
65
+ Object.defineProperty(Queue.prototype, 'length', {
66
+ get: function () {
67
+ return this.pending + this.jobs.length
68
+ }
69
+ })
70
+
71
+ Queue.prototype.start = function (cb) {
72
+ if (cb) {
73
+ callOnErrorOrEnd.call(this, cb)
74
+ }
75
+
76
+ this.running = true
77
+
78
+ if (this.pending >= this.concurrency) {
79
+ return
80
+ }
81
+
82
+ if (this.jobs.length === 0) {
83
+ if (this.pending === 0) {
84
+ done.call(this)
85
+ }
86
+ return
87
+ }
88
+
89
+ var self = this
90
+ var job = this.jobs.shift()
91
+ var once = true
92
+ var session = this.session
93
+ var timeoutId = null
94
+ var didTimeout = false
95
+ var resultIndex = null
96
+ var timeout = job.hasOwnProperty('timeout') ? job.timeout : this.timeout
97
+
98
+ function next (err, result) {
99
+ if (once && self.session === session) {
100
+ once = false
101
+ self.pending--
102
+ if (timeoutId !== null) {
103
+ delete self.timers[timeoutId]
104
+ clearTimeout(timeoutId)
105
+ }
106
+
107
+ if (err) {
108
+ self.emit('error', err, job)
109
+ } else if (didTimeout === false) {
110
+ if (resultIndex !== null) {
111
+ self.results[resultIndex] = Array.prototype.slice.call(arguments, 1)
112
+ }
113
+ self.emit('success', result, job)
114
+ }
115
+
116
+ if (self.session === session) {
117
+ if (self.pending === 0 && self.jobs.length === 0) {
118
+ done.call(self)
119
+ } else if (self.running) {
120
+ self.start()
121
+ }
122
+ }
123
+ }
124
+ }
125
+
126
+ if (timeout) {
127
+ timeoutId = setTimeout(function () {
128
+ didTimeout = true
129
+ if (self.listeners('timeout').length > 0) {
130
+ self.emit('timeout', next, job)
131
+ } else {
132
+ next()
133
+ }
134
+ }, timeout)
135
+ this.timers[timeoutId] = timeoutId
136
+ }
137
+
138
+ if (this.results) {
139
+ resultIndex = this.results.length
140
+ this.results[resultIndex] = null
141
+ }
142
+
143
+ this.pending++
144
+ self.emit('start', job)
145
+ var promise = job(next)
146
+ if (promise && promise.then && typeof promise.then === 'function') {
147
+ promise.then(function (result) {
148
+ return next(null, result)
149
+ }).catch(function (err) {
150
+ return next(err || true)
151
+ })
152
+ }
153
+
154
+ if (this.running && this.jobs.length > 0) {
155
+ this.start()
156
+ }
157
+ }
158
+
159
+ Queue.prototype.stop = function () {
160
+ this.running = false
161
+ }
162
+
163
+ Queue.prototype.end = function (err) {
164
+ clearTimers.call(this)
165
+ this.jobs.length = 0
166
+ this.pending = 0
167
+ done.call(this, err)
168
+ }
169
+
170
+ function clearTimers () {
171
+ for (var key in this.timers) {
172
+ var timeoutId = this.timers[key]
173
+ delete this.timers[key]
174
+ clearTimeout(timeoutId)
175
+ }
176
+ }
177
+
178
+ function callOnErrorOrEnd (cb) {
179
+ var self = this
180
+ this.on('error', onerror)
181
+ this.on('end', onend)
182
+
183
+ function onerror (err) { self.end(err) }
184
+ function onend (err) {
185
+ self.removeListener('error', onerror)
186
+ self.removeListener('end', onend)
187
+ cb(err, this.results)
188
+ }
189
+ }
190
+
191
+ function done (err) {
192
+ this.session++
193
+ this.running = false
194
+ this.emit('end', err)
195
+ }
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "queue",
3
+ "version": "6.0.2",
4
+ "description": "asynchronous function queue with adjustable concurrency",
5
+ "keywords": [
6
+ "queue",
7
+ "async",
8
+ "asynchronous",
9
+ "synchronous",
10
+ "job",
11
+ "task",
12
+ "concurrency",
13
+ "concurrent"
14
+ ],
15
+ "files": [
16
+ "index.js",
17
+ "index.d.ts"
18
+ ],
19
+ "dependencies": {
20
+ "inherits": "~2.0.3"
21
+ },
22
+ "devDependencies": {
23
+ "@types/node": "*",
24
+ "browserify": "^16.2.3",
25
+ "coveralls": "^3.0.3",
26
+ "istanbul": "^0.4.5",
27
+ "standard": "^12.0.1",
28
+ "tape": "^4.10.1",
29
+ "tsd-check": "*",
30
+ "typescript": "^3.3.3333"
31
+ },
32
+ "scripts": {
33
+ "test": "standard && node test && tsd-check",
34
+ "test-browser": "standard && browserify test/index.js > test/bundle.js && echo \"open test/index.html in your browser\"",
35
+ "travis": "standard && istanbul cover test --report lcovonly && cat coverage/lcov.info | coveralls",
36
+ "travis-ts": "tsc test/typescript.ts --m System --out /dev/null && echo 'TypeScript compilation passed.'",
37
+ "example": "node example",
38
+ "lint": "standard"
39
+ },
40
+ "repository": "https://github.com/jessetane/queue.git",
41
+ "author": "Jesse Tane <jesse.tane@gmail.com>",
42
+ "license": "MIT"
43
+ }
@@ -0,0 +1,221 @@
1
+ ```
2
+ ____ __ _____ __ _____
3
+ / __ `/ / / / _ \/ / / / _ \
4
+ / /_/ / /_/ / __/ /_/ / __/
5
+ \__, /\__,_/\___/\__,_/\___/
6
+ /_/
7
+ ```
8
+ Asynchronous function queue with adjustable concurrency.
9
+
10
+ [![npm](http://img.shields.io/npm/v/queue.svg?style=flat-square)](http://www.npmjs.org/queue)
11
+ [![tests](https://img.shields.io/travis/jessetane/queue.svg?style=flat-square&branch=master)](https://travis-ci.org/jessetane/queue)
12
+ [![coverage](https://img.shields.io/coveralls/jessetane/queue.svg?style=flat-square&branch=master)](https://coveralls.io/r/jessetane/queue)
13
+
14
+ This module exports a class `Queue` that implements most of the `Array` API. Pass async functions (ones that accept a callback or return a promise) to an instance's additive array methods. Processing begins when you call `q.start()`.
15
+
16
+ ## Example
17
+ `npm run example`
18
+ ``` javascript
19
+ var queue = require('../')
20
+
21
+ var q = queue({ results: [] })
22
+
23
+ // add jobs using the familiar Array API
24
+ q.push(function (cb) {
25
+ const result = 'two'
26
+ cb(null, result)
27
+ })
28
+
29
+ q.push(
30
+ function (cb) {
31
+ const result = 'four'
32
+ cb(null, result)
33
+ },
34
+ function (cb) {
35
+ const result = 'five'
36
+ cb(null, result)
37
+ }
38
+ )
39
+
40
+ // jobs can accept a callback or return a promise
41
+ q.push(function () {
42
+ return new Promise(function (resolve, reject) {
43
+ const result = 'one'
44
+ resolve(result)
45
+ })
46
+ })
47
+
48
+ q.unshift(function (cb) {
49
+ const result = 'one'
50
+ cb(null, result)
51
+ })
52
+
53
+ q.splice(2, 0, function (cb) {
54
+ const result = 'three'
55
+ cb(null, result)
56
+ })
57
+
58
+ // use the timeout feature to deal with jobs that
59
+ // take too long or forget to execute a callback
60
+ q.timeout = 100
61
+
62
+ q.on('timeout', function (next, job) {
63
+ console.log('job timed out:', job.toString().replace(/\n/g, ''))
64
+ next()
65
+ })
66
+
67
+ q.push(function (cb) {
68
+ setTimeout(function () {
69
+ console.log('slow job finished')
70
+ cb()
71
+ }, 200)
72
+ })
73
+
74
+ q.push(function (cb) {
75
+ console.log('forgot to execute callback')
76
+ })
77
+
78
+ // jobs can also override the queue's timeout
79
+ // on a per-job basis
80
+ function extraSlowJob (cb) {
81
+ setTimeout(function () {
82
+ console.log('extra slow job finished')
83
+ cb()
84
+ }, 400)
85
+ }
86
+
87
+ extraSlowJob.timeout = 500
88
+ q.push(extraSlowJob)
89
+
90
+ // jobs can also opt-out of the timeout altogether
91
+ function superSlowJob (cb) {
92
+ setTimeout(function () {
93
+ console.log('super slow job finished')
94
+ cb()
95
+ }, 1000)
96
+ }
97
+
98
+ superSlowJob.timeout = null
99
+ q.push(superSlowJob)
100
+
101
+ // get notified when jobs complete
102
+ q.on('success', function (result, job) {
103
+ console.log('job finished processing:', job.toString().replace(/\n/g, ''))
104
+ console.log('The result is:', result)
105
+ })
106
+
107
+ // begin processing, get notified on end / failure
108
+ q.start(function (err) {
109
+ if (err) throw err
110
+ console.log('all done:', q.results)
111
+ })
112
+
113
+ ```
114
+
115
+ ## Install
116
+ `npm install queue`
117
+
118
+ _Note_: You may need to install the [`events`](https://github.com/Gozala/events) dependency if
119
+ your environment does not have it by default (eg. browser, react-native).
120
+
121
+ ## Test
122
+ `npm test`
123
+ `npm run test-browser`
124
+
125
+ ## API
126
+
127
+ ### `var q = queue([opts])`
128
+ Constructor. `opts` may contain inital values for:
129
+ * `q.concurrency`
130
+ * `q.timeout`
131
+ * `q.autostart`
132
+ * `q.results`
133
+
134
+ ## Instance methods
135
+ ### `q.start([cb])`
136
+ cb, if passed, will be called when the queue empties or when an error occurs.
137
+
138
+ ### `q.stop()`
139
+ Stops the queue. can be resumed with `q.start()`.
140
+
141
+ ### `q.end([err])`
142
+ Stop and empty the queue immediately.
143
+
144
+ ## Instance methods mixed in from `Array`
145
+ Mozilla has docs on how these methods work [here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array). Note that `slice` does not copy the queue.
146
+ ### `q.push(element1, ..., elementN)`
147
+ ### `q.unshift(element1, ..., elementN)`
148
+ ### `q.splice(index , howMany[, element1[, ...[, elementN]]])`
149
+ ### `q.pop()`
150
+ ### `q.shift()`
151
+ ### `q.slice(begin[, end])`
152
+ ### `q.reverse()`
153
+ ### `q.indexOf(searchElement[, fromIndex])`
154
+ ### `q.lastIndexOf(searchElement[, fromIndex])`
155
+
156
+ ## Properties
157
+ ### `q.concurrency`
158
+ Max number of jobs the queue should process concurrently, defaults to `Infinity`.
159
+
160
+ ### `q.timeout`
161
+ Milliseconds to wait for a job to execute its callback. This can be overridden by specifying a `timeout` property on a per-job basis.
162
+
163
+ ### `q.autostart`
164
+ Ensures the queue is always running if jobs are available. Useful in situations where you are using a queue only for concurrency control.
165
+
166
+ ### `q.results`
167
+ An array to set job callback arguments on.
168
+
169
+ ### `q.length`
170
+ Jobs pending + jobs to process (readonly).
171
+
172
+ ## Events
173
+
174
+ ### `q.emit('start', job)`
175
+ Immediately before a job begins to execute.
176
+
177
+ ### `q.emit('success', result, job)`
178
+ After a job executes its callback.
179
+
180
+ ### `q.emit('error', err, job)`
181
+ After a job passes an error to its callback.
182
+
183
+ ### `q.emit('timeout', continue, job)`
184
+ After `q.timeout` milliseconds have elapsed and a job has not executed its callback.
185
+
186
+ ### `q.emit('end'[, err])`
187
+ After all jobs have been processed
188
+
189
+ ## Releases
190
+ The latest stable release is published to [npm](http://npmjs.org/queue). Abbreviated changelog below:
191
+ * [6.0](https://github.com/jessetane/queue/archive/6.0.1.tar.gz)
192
+ * Add `start` event before job begins (@joelgriffith)
193
+ * Add `timeout` property on a job to override the queue's timeout (@joelgriffith)
194
+ * [5.0](https://github.com/jessetane/queue/archive/5.0.0.tar.gz)
195
+ * Updated TypeScript bindings (@Codex-)
196
+ * [4.4](https://github.com/jessetane/queue/archive/4.4.0.tar.gz)
197
+ * Add results feature
198
+ * [4.3](https://github.com/jessetane/queue/archive/4.3.0.tar.gz)
199
+ * Add promise support (@kwolfy)
200
+ * [4.2](https://github.com/jessetane/queue/archive/4.2.0.tar.gz)
201
+ * Unref timers on end
202
+ * [4.1](https://github.com/jessetane/queue/archive/4.1.0.tar.gz)
203
+ * Add autostart feature
204
+ * [4.0](https://github.com/jessetane/queue/archive/4.0.0.tar.gz)
205
+ * Change license to MIT
206
+ * [3.1.x](https://github.com/jessetane/queue/archive/3.0.6.tar.gz)
207
+ * Add .npmignore
208
+ * [3.0.x](https://github.com/jessetane/queue/archive/3.0.6.tar.gz)
209
+ * Change the default concurrency to `Infinity`
210
+ * Allow `q.start()` to accept an optional callback executed on `q.emit('end')`
211
+ * [2.x](https://github.com/jessetane/queue/archive/2.2.0.tar.gz)
212
+ * Major api changes / not backwards compatible with 1.x
213
+ * [1.x](https://github.com/jessetane/queue/archive/1.0.2.tar.gz)
214
+ * Early prototype
215
+
216
+ ## License
217
+ Copyright © 2014 Jesse Tane <jesse.tane@gmail.com>
218
+
219
+ This work is free. You can redistribute it and/or modify it under the
220
+ terms of the [MIT License](https://opensource.org/licenses/MIT).
221
+ See LICENSE for full details.