dragonfly_chrome_headless 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (228) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +10 -0
  3. data/.travis.yml +12 -0
  4. data/Gemfile +4 -0
  5. data/README.md +53 -0
  6. data/Rakefile +10 -0
  7. data/bin/console +14 -0
  8. data/bin/setup +8 -0
  9. data/dragonfly_chrome_headless.gemspec +27 -0
  10. data/lib/dragonfly_chrome_headless.rb +9 -0
  11. data/lib/dragonfly_chrome_headless/plugin.rb +17 -0
  12. data/lib/dragonfly_chrome_headless/processors/rasterize.rb +33 -0
  13. data/lib/dragonfly_chrome_headless/version.rb +3 -0
  14. data/node_modules/.bin/chrome-remote-interface +1 -0
  15. data/node_modules/.bin/mkdirp +1 -0
  16. data/node_modules/.bin/rimraf +1 -0
  17. data/node_modules/@types/core-js/LICENSE +21 -0
  18. data/node_modules/@types/core-js/README.md +16 -0
  19. data/node_modules/@types/core-js/index.d.ts +2452 -0
  20. data/node_modules/@types/core-js/package.json +85 -0
  21. data/node_modules/@types/mkdirp/README.md +18 -0
  22. data/node_modules/@types/mkdirp/index.d.ts +14 -0
  23. data/node_modules/@types/mkdirp/package.json +77 -0
  24. data/node_modules/@types/mkdirp/types-metadata.json +25 -0
  25. data/node_modules/@types/node/README.md +16 -0
  26. data/node_modules/@types/node/index.d.ts +4132 -0
  27. data/node_modules/@types/node/package.json +84 -0
  28. data/node_modules/balanced-match/.npmignore +5 -0
  29. data/node_modules/balanced-match/LICENSE.md +21 -0
  30. data/node_modules/balanced-match/README.md +91 -0
  31. data/node_modules/balanced-match/index.js +59 -0
  32. data/node_modules/balanced-match/package.json +112 -0
  33. data/node_modules/brace-expansion/README.md +123 -0
  34. data/node_modules/brace-expansion/index.js +201 -0
  35. data/node_modules/brace-expansion/package.json +114 -0
  36. data/node_modules/chrome-launcher/.clang-format +6 -0
  37. data/node_modules/chrome-launcher/.npmignore +11 -0
  38. data/node_modules/chrome-launcher/README.md +123 -0
  39. data/node_modules/chrome-launcher/ask.js +32 -0
  40. data/node_modules/chrome-launcher/ask.ts +35 -0
  41. data/node_modules/chrome-launcher/chrome-finder.js +157 -0
  42. data/node_modules/chrome-launcher/chrome-finder.ts +186 -0
  43. data/node_modules/chrome-launcher/chrome-launcher.js +245 -0
  44. data/node_modules/chrome-launcher/chrome-launcher.ts +312 -0
  45. data/node_modules/chrome-launcher/compiled-check.js +14 -0
  46. data/node_modules/chrome-launcher/flags.js +27 -0
  47. data/node_modules/chrome-launcher/flags.ts +26 -0
  48. data/node_modules/chrome-launcher/index.js +7 -0
  49. data/node_modules/chrome-launcher/index.ts +1 -0
  50. data/node_modules/chrome-launcher/manual-chrome-launcher.js +30 -0
  51. data/node_modules/chrome-launcher/package.json +116 -0
  52. data/node_modules/chrome-launcher/random-port.js +24 -0
  53. data/node_modules/chrome-launcher/random-port.ts +23 -0
  54. data/node_modules/chrome-launcher/tsconfig.json +19 -0
  55. data/node_modules/chrome-launcher/utils.js +52 -0
  56. data/node_modules/chrome-launcher/utils.ts +44 -0
  57. data/node_modules/chrome-launcher/yarn.lock +1486 -0
  58. data/node_modules/chrome-remote-interface/LICENSE +18 -0
  59. data/node_modules/chrome-remote-interface/README.md +849 -0
  60. data/node_modules/chrome-remote-interface/bin/client.js +337 -0
  61. data/node_modules/chrome-remote-interface/chrome-remote-interface.js +11 -0
  62. data/node_modules/chrome-remote-interface/index.js +39 -0
  63. data/node_modules/chrome-remote-interface/lib/api.js +84 -0
  64. data/node_modules/chrome-remote-interface/lib/chrome.js +307 -0
  65. data/node_modules/chrome-remote-interface/lib/defaults.js +4 -0
  66. data/node_modules/chrome-remote-interface/lib/devtools.js +245 -0
  67. data/node_modules/chrome-remote-interface/lib/external-request.js +28 -0
  68. data/node_modules/chrome-remote-interface/lib/protocol.json +13780 -0
  69. data/node_modules/chrome-remote-interface/lib/websocket-wrapper.js +32 -0
  70. data/node_modules/chrome-remote-interface/package.json +128 -0
  71. data/node_modules/chrome-remote-interface/webpack.config.js +55 -0
  72. data/node_modules/commander/Readme.md +195 -0
  73. data/node_modules/commander/index.js +851 -0
  74. data/node_modules/commander/package.json +92 -0
  75. data/node_modules/concat-map/.travis.yml +4 -0
  76. data/node_modules/concat-map/LICENSE +18 -0
  77. data/node_modules/concat-map/README.markdown +62 -0
  78. data/node_modules/concat-map/example/map.js +6 -0
  79. data/node_modules/concat-map/index.js +13 -0
  80. data/node_modules/concat-map/package.json +117 -0
  81. data/node_modules/concat-map/test/map.js +39 -0
  82. data/node_modules/debug/.coveralls.yml +1 -0
  83. data/node_modules/debug/.eslintrc +11 -0
  84. data/node_modules/debug/.npmignore +9 -0
  85. data/node_modules/debug/.travis.yml +14 -0
  86. data/node_modules/debug/CHANGELOG.md +357 -0
  87. data/node_modules/debug/LICENSE +19 -0
  88. data/node_modules/debug/Makefile +50 -0
  89. data/node_modules/debug/Readme.md +312 -0
  90. data/node_modules/debug/component.json +19 -0
  91. data/node_modules/debug/karma.conf.js +70 -0
  92. data/node_modules/debug/node.js +1 -0
  93. data/node_modules/debug/package.json +124 -0
  94. data/node_modules/debug/src/browser.js +185 -0
  95. data/node_modules/debug/src/debug.js +202 -0
  96. data/node_modules/debug/src/index.js +10 -0
  97. data/node_modules/debug/src/node.js +246 -0
  98. data/node_modules/fs.realpath/LICENSE +43 -0
  99. data/node_modules/fs.realpath/README.md +33 -0
  100. data/node_modules/fs.realpath/index.js +66 -0
  101. data/node_modules/fs.realpath/old.js +303 -0
  102. data/node_modules/fs.realpath/package.json +94 -0
  103. data/node_modules/glob/LICENSE +15 -0
  104. data/node_modules/glob/README.md +368 -0
  105. data/node_modules/glob/changelog.md +67 -0
  106. data/node_modules/glob/common.js +240 -0
  107. data/node_modules/glob/glob.js +790 -0
  108. data/node_modules/glob/package.json +112 -0
  109. data/node_modules/glob/sync.js +486 -0
  110. data/node_modules/html-pdf-chrome/.npmignore +9 -0
  111. data/node_modules/html-pdf-chrome/LICENSE +21 -0
  112. data/node_modules/html-pdf-chrome/README.md +165 -0
  113. data/node_modules/html-pdf-chrome/lib/src/ChromePrintOptions.d.ts +87 -0
  114. data/node_modules/html-pdf-chrome/lib/src/ChromePrintOptions.js +4 -0
  115. data/node_modules/html-pdf-chrome/lib/src/ChromePrintOptions.js.map +1 -0
  116. data/node_modules/html-pdf-chrome/lib/src/CompletionTrigger.d.ts +120 -0
  117. data/node_modules/html-pdf-chrome/lib/src/CompletionTrigger.js +206 -0
  118. data/node_modules/html-pdf-chrome/lib/src/CompletionTrigger.js.map +1 -0
  119. data/node_modules/html-pdf-chrome/lib/src/CreateResult.d.ts +70 -0
  120. data/node_modules/html-pdf-chrome/lib/src/CreateResult.js +98 -0
  121. data/node_modules/html-pdf-chrome/lib/src/CreateResult.js.map +1 -0
  122. data/node_modules/html-pdf-chrome/lib/src/index.d.ts +72 -0
  123. data/node_modules/html-pdf-chrome/lib/src/index.js +123 -0
  124. data/node_modules/html-pdf-chrome/lib/src/index.js.map +1 -0
  125. data/node_modules/html-pdf-chrome/package.json +133 -0
  126. data/node_modules/html-pdf-chrome/src/ChromePrintOptions.ts +99 -0
  127. data/node_modules/html-pdf-chrome/src/CompletionTrigger.ts +201 -0
  128. data/node_modules/html-pdf-chrome/src/CreateResult.ts +100 -0
  129. data/node_modules/html-pdf-chrome/src/index.ts +179 -0
  130. data/node_modules/inflight/LICENSE +15 -0
  131. data/node_modules/inflight/README.md +37 -0
  132. data/node_modules/inflight/inflight.js +54 -0
  133. data/node_modules/inflight/package.json +105 -0
  134. data/node_modules/inherits/LICENSE +16 -0
  135. data/node_modules/inherits/README.md +42 -0
  136. data/node_modules/inherits/inherits.js +7 -0
  137. data/node_modules/inherits/inherits_browser.js +23 -0
  138. data/node_modules/inherits/package.json +97 -0
  139. data/node_modules/lighthouse-logger/README.md +4 -0
  140. data/node_modules/lighthouse-logger/index.js +212 -0
  141. data/node_modules/lighthouse-logger/package.json +69 -0
  142. data/node_modules/lighthouse-logger/yarn.lock +13 -0
  143. data/node_modules/minimatch/LICENSE +15 -0
  144. data/node_modules/minimatch/README.md +209 -0
  145. data/node_modules/minimatch/minimatch.js +923 -0
  146. data/node_modules/minimatch/package.json +99 -0
  147. data/node_modules/minimist/.travis.yml +4 -0
  148. data/node_modules/minimist/LICENSE +18 -0
  149. data/node_modules/minimist/example/parse.js +2 -0
  150. data/node_modules/minimist/index.js +187 -0
  151. data/node_modules/minimist/package.json +101 -0
  152. data/node_modules/minimist/readme.markdown +73 -0
  153. data/node_modules/minimist/test/dash.js +24 -0
  154. data/node_modules/minimist/test/default_bool.js +20 -0
  155. data/node_modules/minimist/test/dotted.js +16 -0
  156. data/node_modules/minimist/test/long.js +31 -0
  157. data/node_modules/minimist/test/parse.js +318 -0
  158. data/node_modules/minimist/test/parse_modified.js +9 -0
  159. data/node_modules/minimist/test/short.js +67 -0
  160. data/node_modules/minimist/test/whitespace.js +8 -0
  161. data/node_modules/mkdirp/.travis.yml +8 -0
  162. data/node_modules/mkdirp/LICENSE +21 -0
  163. data/node_modules/mkdirp/bin/cmd.js +33 -0
  164. data/node_modules/mkdirp/bin/usage.txt +12 -0
  165. data/node_modules/mkdirp/examples/pow.js +6 -0
  166. data/node_modules/mkdirp/index.js +98 -0
  167. data/node_modules/mkdirp/package.json +93 -0
  168. data/node_modules/mkdirp/readme.markdown +100 -0
  169. data/node_modules/mkdirp/test/chmod.js +41 -0
  170. data/node_modules/mkdirp/test/clobber.js +38 -0
  171. data/node_modules/mkdirp/test/mkdirp.js +28 -0
  172. data/node_modules/mkdirp/test/opts_fs.js +29 -0
  173. data/node_modules/mkdirp/test/opts_fs_sync.js +27 -0
  174. data/node_modules/mkdirp/test/perm.js +32 -0
  175. data/node_modules/mkdirp/test/perm_sync.js +36 -0
  176. data/node_modules/mkdirp/test/race.js +37 -0
  177. data/node_modules/mkdirp/test/rel.js +32 -0
  178. data/node_modules/mkdirp/test/return.js +25 -0
  179. data/node_modules/mkdirp/test/return_sync.js +24 -0
  180. data/node_modules/mkdirp/test/root.js +19 -0
  181. data/node_modules/mkdirp/test/sync.js +32 -0
  182. data/node_modules/mkdirp/test/umask.js +28 -0
  183. data/node_modules/mkdirp/test/umask_sync.js +32 -0
  184. data/node_modules/ms/README.md +51 -0
  185. data/node_modules/ms/index.js +152 -0
  186. data/node_modules/ms/license.md +21 -0
  187. data/node_modules/ms/package.json +109 -0
  188. data/node_modules/once/LICENSE +15 -0
  189. data/node_modules/once/README.md +79 -0
  190. data/node_modules/once/once.js +42 -0
  191. data/node_modules/once/package.json +101 -0
  192. data/node_modules/path-is-absolute/index.js +20 -0
  193. data/node_modules/path-is-absolute/license +21 -0
  194. data/node_modules/path-is-absolute/package.json +111 -0
  195. data/node_modules/path-is-absolute/readme.md +59 -0
  196. data/node_modules/rimraf/LICENSE +15 -0
  197. data/node_modules/rimraf/README.md +101 -0
  198. data/node_modules/rimraf/bin.js +50 -0
  199. data/node_modules/rimraf/package.json +99 -0
  200. data/node_modules/rimraf/rimraf.js +363 -0
  201. data/node_modules/ultron/LICENSE +22 -0
  202. data/node_modules/ultron/index.js +138 -0
  203. data/node_modules/ultron/package.json +112 -0
  204. data/node_modules/wrappy/LICENSE +15 -0
  205. data/node_modules/wrappy/README.md +36 -0
  206. data/node_modules/wrappy/package.json +97 -0
  207. data/node_modules/wrappy/wrappy.js +33 -0
  208. data/node_modules/ws/LICENSE +21 -0
  209. data/node_modules/ws/README.md +259 -0
  210. data/node_modules/ws/SECURITY.md +33 -0
  211. data/node_modules/ws/index.js +15 -0
  212. data/node_modules/ws/lib/BufferUtil.fallback.js +56 -0
  213. data/node_modules/ws/lib/BufferUtil.js +15 -0
  214. data/node_modules/ws/lib/ErrorCodes.js +28 -0
  215. data/node_modules/ws/lib/EventTarget.js +158 -0
  216. data/node_modules/ws/lib/Extensions.js +69 -0
  217. data/node_modules/ws/lib/PerMessageDeflate.js +339 -0
  218. data/node_modules/ws/lib/Receiver.js +520 -0
  219. data/node_modules/ws/lib/Sender.js +438 -0
  220. data/node_modules/ws/lib/Validation.fallback.js +9 -0
  221. data/node_modules/ws/lib/Validation.js +17 -0
  222. data/node_modules/ws/lib/WebSocket.js +705 -0
  223. data/node_modules/ws/lib/WebSocketServer.js +336 -0
  224. data/node_modules/ws/package.json +122 -0
  225. data/package.json +26 -0
  226. data/samples/sample.html +13 -0
  227. data/script/rasterize.js +18 -0
  228. metadata +325 -0
@@ -0,0 +1,152 @@
1
+ /**
2
+ * Helpers.
3
+ */
4
+
5
+ var s = 1000;
6
+ var m = s * 60;
7
+ var h = m * 60;
8
+ var d = h * 24;
9
+ var y = d * 365.25;
10
+
11
+ /**
12
+ * Parse or format the given `val`.
13
+ *
14
+ * Options:
15
+ *
16
+ * - `long` verbose formatting [false]
17
+ *
18
+ * @param {String|Number} val
19
+ * @param {Object} [options]
20
+ * @throws {Error} throw an error if val is not a non-empty string or a number
21
+ * @return {String|Number}
22
+ * @api public
23
+ */
24
+
25
+ module.exports = function(val, options) {
26
+ options = options || {};
27
+ var type = typeof val;
28
+ if (type === 'string' && val.length > 0) {
29
+ return parse(val);
30
+ } else if (type === 'number' && isNaN(val) === false) {
31
+ return options.long ? fmtLong(val) : fmtShort(val);
32
+ }
33
+ throw new Error(
34
+ 'val is not a non-empty string or a valid number. val=' +
35
+ JSON.stringify(val)
36
+ );
37
+ };
38
+
39
+ /**
40
+ * Parse the given `str` and return milliseconds.
41
+ *
42
+ * @param {String} str
43
+ * @return {Number}
44
+ * @api private
45
+ */
46
+
47
+ function parse(str) {
48
+ str = String(str);
49
+ if (str.length > 100) {
50
+ return;
51
+ }
52
+ var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(
53
+ str
54
+ );
55
+ if (!match) {
56
+ return;
57
+ }
58
+ var n = parseFloat(match[1]);
59
+ var type = (match[2] || 'ms').toLowerCase();
60
+ switch (type) {
61
+ case 'years':
62
+ case 'year':
63
+ case 'yrs':
64
+ case 'yr':
65
+ case 'y':
66
+ return n * y;
67
+ case 'days':
68
+ case 'day':
69
+ case 'd':
70
+ return n * d;
71
+ case 'hours':
72
+ case 'hour':
73
+ case 'hrs':
74
+ case 'hr':
75
+ case 'h':
76
+ return n * h;
77
+ case 'minutes':
78
+ case 'minute':
79
+ case 'mins':
80
+ case 'min':
81
+ case 'm':
82
+ return n * m;
83
+ case 'seconds':
84
+ case 'second':
85
+ case 'secs':
86
+ case 'sec':
87
+ case 's':
88
+ return n * s;
89
+ case 'milliseconds':
90
+ case 'millisecond':
91
+ case 'msecs':
92
+ case 'msec':
93
+ case 'ms':
94
+ return n;
95
+ default:
96
+ return undefined;
97
+ }
98
+ }
99
+
100
+ /**
101
+ * Short format for `ms`.
102
+ *
103
+ * @param {Number} ms
104
+ * @return {String}
105
+ * @api private
106
+ */
107
+
108
+ function fmtShort(ms) {
109
+ if (ms >= d) {
110
+ return Math.round(ms / d) + 'd';
111
+ }
112
+ if (ms >= h) {
113
+ return Math.round(ms / h) + 'h';
114
+ }
115
+ if (ms >= m) {
116
+ return Math.round(ms / m) + 'm';
117
+ }
118
+ if (ms >= s) {
119
+ return Math.round(ms / s) + 's';
120
+ }
121
+ return ms + 'ms';
122
+ }
123
+
124
+ /**
125
+ * Long format for `ms`.
126
+ *
127
+ * @param {Number} ms
128
+ * @return {String}
129
+ * @api private
130
+ */
131
+
132
+ function fmtLong(ms) {
133
+ return plural(ms, d, 'day') ||
134
+ plural(ms, h, 'hour') ||
135
+ plural(ms, m, 'minute') ||
136
+ plural(ms, s, 'second') ||
137
+ ms + ' ms';
138
+ }
139
+
140
+ /**
141
+ * Pluralization helper.
142
+ */
143
+
144
+ function plural(ms, n, name) {
145
+ if (ms < n) {
146
+ return;
147
+ }
148
+ if (ms < n * 1.5) {
149
+ return Math.floor(ms / n) + ' ' + name;
150
+ }
151
+ return Math.ceil(ms / n) + ' ' + name + 's';
152
+ }
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Zeit, Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,109 @@
1
+ {
2
+ "_args": [
3
+ [
4
+ {
5
+ "raw": "ms@2.0.0",
6
+ "scope": null,
7
+ "escapedName": "ms",
8
+ "name": "ms",
9
+ "rawSpec": "2.0.0",
10
+ "spec": "2.0.0",
11
+ "type": "version"
12
+ },
13
+ "/Users/tomascelizna/Devel/dragonfly_chrome_headless/node_modules/debug"
14
+ ]
15
+ ],
16
+ "_from": "ms@2.0.0",
17
+ "_id": "ms@2.0.0",
18
+ "_inCache": true,
19
+ "_location": "/ms",
20
+ "_nodeVersion": "7.8.0",
21
+ "_npmOperationalInternal": {
22
+ "host": "packages-18-east.internal.npmjs.com",
23
+ "tmp": "tmp/ms-2.0.0.tgz_1494937565215_0.34005374647676945"
24
+ },
25
+ "_npmUser": {
26
+ "name": "leo",
27
+ "email": "leo@zeit.co"
28
+ },
29
+ "_npmVersion": "4.2.0",
30
+ "_phantomChildren": {},
31
+ "_requested": {
32
+ "raw": "ms@2.0.0",
33
+ "scope": null,
34
+ "escapedName": "ms",
35
+ "name": "ms",
36
+ "rawSpec": "2.0.0",
37
+ "spec": "2.0.0",
38
+ "type": "version"
39
+ },
40
+ "_requiredBy": [
41
+ "/debug"
42
+ ],
43
+ "_resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
44
+ "_shasum": "5608aeadfc00be6c2901df5f9861788de0d597c8",
45
+ "_shrinkwrap": null,
46
+ "_spec": "ms@2.0.0",
47
+ "_where": "/Users/tomascelizna/Devel/dragonfly_chrome_headless/node_modules/debug",
48
+ "bugs": {
49
+ "url": "https://github.com/zeit/ms/issues"
50
+ },
51
+ "dependencies": {},
52
+ "description": "Tiny milisecond conversion utility",
53
+ "devDependencies": {
54
+ "eslint": "3.19.0",
55
+ "expect.js": "0.3.1",
56
+ "husky": "0.13.3",
57
+ "lint-staged": "3.4.1",
58
+ "mocha": "3.4.1"
59
+ },
60
+ "directories": {},
61
+ "dist": {
62
+ "shasum": "5608aeadfc00be6c2901df5f9861788de0d597c8",
63
+ "tarball": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz"
64
+ },
65
+ "eslintConfig": {
66
+ "extends": "eslint:recommended",
67
+ "env": {
68
+ "node": true,
69
+ "es6": true
70
+ }
71
+ },
72
+ "files": [
73
+ "index.js"
74
+ ],
75
+ "gitHead": "9b88d1568a52ec9bb67ecc8d2aa224fa38fd41f4",
76
+ "homepage": "https://github.com/zeit/ms#readme",
77
+ "license": "MIT",
78
+ "lint-staged": {
79
+ "*.js": [
80
+ "npm run lint",
81
+ "prettier --single-quote --write",
82
+ "git add"
83
+ ]
84
+ },
85
+ "main": "./index",
86
+ "maintainers": [
87
+ {
88
+ "name": "leo",
89
+ "email": "leo@zeit.co"
90
+ },
91
+ {
92
+ "name": "rauchg",
93
+ "email": "rauchg@gmail.com"
94
+ }
95
+ ],
96
+ "name": "ms",
97
+ "optionalDependencies": {},
98
+ "readme": "ERROR: No README data found!",
99
+ "repository": {
100
+ "type": "git",
101
+ "url": "git+https://github.com/zeit/ms.git"
102
+ },
103
+ "scripts": {
104
+ "lint": "eslint lib/* bin/*",
105
+ "precommit": "lint-staged",
106
+ "test": "mocha tests.js"
107
+ },
108
+ "version": "2.0.0"
109
+ }
@@ -0,0 +1,15 @@
1
+ The ISC License
2
+
3
+ Copyright (c) Isaac Z. Schlueter and Contributors
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
15
+ IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
@@ -0,0 +1,79 @@
1
+ # once
2
+
3
+ Only call a function once.
4
+
5
+ ## usage
6
+
7
+ ```javascript
8
+ var once = require('once')
9
+
10
+ function load (file, cb) {
11
+ cb = once(cb)
12
+ loader.load('file')
13
+ loader.once('load', cb)
14
+ loader.once('error', cb)
15
+ }
16
+ ```
17
+
18
+ Or add to the Function.prototype in a responsible way:
19
+
20
+ ```javascript
21
+ // only has to be done once
22
+ require('once').proto()
23
+
24
+ function load (file, cb) {
25
+ cb = cb.once()
26
+ loader.load('file')
27
+ loader.once('load', cb)
28
+ loader.once('error', cb)
29
+ }
30
+ ```
31
+
32
+ Ironically, the prototype feature makes this module twice as
33
+ complicated as necessary.
34
+
35
+ To check whether you function has been called, use `fn.called`. Once the
36
+ function is called for the first time the return value of the original
37
+ function is saved in `fn.value` and subsequent calls will continue to
38
+ return this value.
39
+
40
+ ```javascript
41
+ var once = require('once')
42
+
43
+ function load (cb) {
44
+ cb = once(cb)
45
+ var stream = createStream()
46
+ stream.once('data', cb)
47
+ stream.once('end', function () {
48
+ if (!cb.called) cb(new Error('not found'))
49
+ })
50
+ }
51
+ ```
52
+
53
+ ## `once.strict(func)`
54
+
55
+ Throw an error if the function is called twice.
56
+
57
+ Some functions are expected to be called only once. Using `once` for them would
58
+ potentially hide logical errors.
59
+
60
+ In the example below, the `greet` function has to call the callback only once:
61
+
62
+ ```javascript
63
+ function greet (name, cb) {
64
+ // return is missing from the if statement
65
+ // when no name is passed, the callback is called twice
66
+ if (!name) cb('Hello anonymous')
67
+ cb('Hello ' + name)
68
+ }
69
+
70
+ function log (msg) {
71
+ console.log(msg)
72
+ }
73
+
74
+ // this will print 'Hello anonymous' but the logical error will be missed
75
+ greet(null, once(msg))
76
+
77
+ // once.strict will print 'Hello anonymous' and throw an error when the callback will be called the second time
78
+ greet(null, once.strict(msg))
79
+ ```
@@ -0,0 +1,42 @@
1
+ var wrappy = require('wrappy')
2
+ module.exports = wrappy(once)
3
+ module.exports.strict = wrappy(onceStrict)
4
+
5
+ once.proto = once(function () {
6
+ Object.defineProperty(Function.prototype, 'once', {
7
+ value: function () {
8
+ return once(this)
9
+ },
10
+ configurable: true
11
+ })
12
+
13
+ Object.defineProperty(Function.prototype, 'onceStrict', {
14
+ value: function () {
15
+ return onceStrict(this)
16
+ },
17
+ configurable: true
18
+ })
19
+ })
20
+
21
+ function once (fn) {
22
+ var f = function () {
23
+ if (f.called) return f.value
24
+ f.called = true
25
+ return f.value = fn.apply(this, arguments)
26
+ }
27
+ f.called = false
28
+ return f
29
+ }
30
+
31
+ function onceStrict (fn) {
32
+ var f = function () {
33
+ if (f.called)
34
+ throw new Error(f.onceError)
35
+ f.called = true
36
+ return f.value = fn.apply(this, arguments)
37
+ }
38
+ var name = fn.name || 'Function wrapped with `once`'
39
+ f.onceError = name + " shouldn't be called more than once"
40
+ f.called = false
41
+ return f
42
+ }
@@ -0,0 +1,101 @@
1
+ {
2
+ "_args": [
3
+ [
4
+ {
5
+ "raw": "once@^1.3.0",
6
+ "scope": null,
7
+ "escapedName": "once",
8
+ "name": "once",
9
+ "rawSpec": "^1.3.0",
10
+ "spec": ">=1.3.0 <2.0.0",
11
+ "type": "range"
12
+ },
13
+ "/Users/tomascelizna/Devel/dragonfly_chrome_headless/node_modules/glob"
14
+ ]
15
+ ],
16
+ "_from": "once@>=1.3.0 <2.0.0",
17
+ "_id": "once@1.4.0",
18
+ "_inCache": true,
19
+ "_location": "/once",
20
+ "_nodeVersion": "6.5.0",
21
+ "_npmOperationalInternal": {
22
+ "host": "packages-12-west.internal.npmjs.com",
23
+ "tmp": "tmp/once-1.4.0.tgz_1473196269128_0.537820661207661"
24
+ },
25
+ "_npmUser": {
26
+ "name": "isaacs",
27
+ "email": "i@izs.me"
28
+ },
29
+ "_npmVersion": "3.10.7",
30
+ "_phantomChildren": {},
31
+ "_requested": {
32
+ "raw": "once@^1.3.0",
33
+ "scope": null,
34
+ "escapedName": "once",
35
+ "name": "once",
36
+ "rawSpec": "^1.3.0",
37
+ "spec": ">=1.3.0 <2.0.0",
38
+ "type": "range"
39
+ },
40
+ "_requiredBy": [
41
+ "/glob",
42
+ "/inflight"
43
+ ],
44
+ "_resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
45
+ "_shasum": "583b1aa775961d4b113ac17d9c50baef9dd76bd1",
46
+ "_shrinkwrap": null,
47
+ "_spec": "once@^1.3.0",
48
+ "_where": "/Users/tomascelizna/Devel/dragonfly_chrome_headless/node_modules/glob",
49
+ "author": {
50
+ "name": "Isaac Z. Schlueter",
51
+ "email": "i@izs.me",
52
+ "url": "http://blog.izs.me/"
53
+ },
54
+ "bugs": {
55
+ "url": "https://github.com/isaacs/once/issues"
56
+ },
57
+ "dependencies": {
58
+ "wrappy": "1"
59
+ },
60
+ "description": "Run a function exactly one time",
61
+ "devDependencies": {
62
+ "tap": "^7.0.1"
63
+ },
64
+ "directories": {
65
+ "test": "test"
66
+ },
67
+ "dist": {
68
+ "shasum": "583b1aa775961d4b113ac17d9c50baef9dd76bd1",
69
+ "tarball": "https://registry.npmjs.org/once/-/once-1.4.0.tgz"
70
+ },
71
+ "files": [
72
+ "once.js"
73
+ ],
74
+ "gitHead": "0e614d9f5a7e6f0305c625f6b581f6d80b33b8a6",
75
+ "homepage": "https://github.com/isaacs/once#readme",
76
+ "keywords": [
77
+ "once",
78
+ "function",
79
+ "one",
80
+ "single"
81
+ ],
82
+ "license": "ISC",
83
+ "main": "once.js",
84
+ "maintainers": [
85
+ {
86
+ "name": "isaacs",
87
+ "email": "i@izs.me"
88
+ }
89
+ ],
90
+ "name": "once",
91
+ "optionalDependencies": {},
92
+ "readme": "ERROR: No README data found!",
93
+ "repository": {
94
+ "type": "git",
95
+ "url": "git://github.com/isaacs/once.git"
96
+ },
97
+ "scripts": {
98
+ "test": "tap test/*.js"
99
+ },
100
+ "version": "1.4.0"
101
+ }