fsevents 1.0.8 → 1.0.9

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of fsevents might be problematic. Click here for more details.

Files changed (194) hide show
  1. package/node_modules/ansi-styles/index.js +72 -6
  2. package/node_modules/ansi-styles/package.json +19 -12
  3. package/node_modules/ansi-styles/readme.md +36 -8
  4. package/node_modules/are-we-there-yet/CHANGES.md +19 -0
  5. package/node_modules/are-we-there-yet/README.md +12 -2
  6. package/node_modules/are-we-there-yet/index.js +4 -132
  7. package/node_modules/are-we-there-yet/package.json +18 -13
  8. package/node_modules/are-we-there-yet/test/lib/test-event.js +29 -0
  9. package/node_modules/are-we-there-yet/test/tracker.js +44 -43
  10. package/node_modules/are-we-there-yet/test/trackergroup.js +73 -64
  11. package/node_modules/are-we-there-yet/test/trackerstream.js +26 -40
  12. package/node_modules/are-we-there-yet/tracker-base.js +11 -0
  13. package/node_modules/are-we-there-yet/tracker-group.js +107 -0
  14. package/node_modules/are-we-there-yet/tracker-stream.js +35 -0
  15. package/node_modules/are-we-there-yet/tracker.js +30 -0
  16. package/node_modules/asn1/package.json +1 -2
  17. package/node_modules/assert-plus/package.json +1 -3
  18. package/node_modules/async/package.json +1 -1
  19. package/node_modules/aws4/.npmignore +2 -1
  20. package/node_modules/aws4/README.md +4 -0
  21. package/node_modules/aws4/aws4.js +8 -3
  22. package/node_modules/aws4/node_modules/lru-cache/.npmignore +3 -0
  23. package/node_modules/aws4/node_modules/lru-cache/.travis.yml +3 -4
  24. package/node_modules/aws4/node_modules/lru-cache/README.md +29 -24
  25. package/node_modules/aws4/node_modules/lru-cache/benchmarks/insertion-time.js +32 -0
  26. package/node_modules/aws4/node_modules/lru-cache/lib/lru-cache.js +333 -199
  27. package/node_modules/aws4/node_modules/lru-cache/node_modules/pseudomap/LICENSE +15 -0
  28. package/node_modules/aws4/node_modules/lru-cache/node_modules/pseudomap/README.md +60 -0
  29. package/node_modules/aws4/node_modules/lru-cache/node_modules/pseudomap/map.js +9 -0
  30. package/node_modules/aws4/node_modules/lru-cache/node_modules/pseudomap/package.json +59 -0
  31. package/node_modules/aws4/node_modules/lru-cache/node_modules/pseudomap/pseudomap.js +113 -0
  32. package/node_modules/aws4/node_modules/lru-cache/node_modules/pseudomap/test/basic.js +86 -0
  33. package/node_modules/aws4/node_modules/lru-cache/node_modules/yallist/.npmignore +4 -0
  34. package/node_modules/aws4/node_modules/lru-cache/node_modules/yallist/.travis.yml +7 -0
  35. package/node_modules/aws4/node_modules/lru-cache/node_modules/yallist/CONTRIBUTING.md +4 -0
  36. package/node_modules/aws4/node_modules/lru-cache/node_modules/yallist/LICENSE +15 -0
  37. package/node_modules/aws4/node_modules/lru-cache/node_modules/yallist/README.md +204 -0
  38. package/node_modules/aws4/node_modules/lru-cache/node_modules/yallist/package.json +59 -0
  39. package/node_modules/aws4/node_modules/lru-cache/node_modules/yallist/test/basic.js +188 -0
  40. package/node_modules/aws4/node_modules/lru-cache/node_modules/yallist/yallist.js +360 -0
  41. package/node_modules/aws4/node_modules/lru-cache/package.json +16 -12
  42. package/node_modules/aws4/node_modules/lru-cache/test/basic.js +270 -146
  43. package/node_modules/aws4/node_modules/lru-cache/test/foreach.js +39 -25
  44. package/node_modules/aws4/node_modules/lru-cache/test/inspect.js +54 -0
  45. package/node_modules/aws4/node_modules/lru-cache/test/no-symbol.js +3 -0
  46. package/node_modules/aws4/node_modules/lru-cache/test/serialize.js +115 -104
  47. package/node_modules/aws4/package.json +17 -14
  48. package/node_modules/bl/bl.js +9 -3
  49. package/node_modules/bl/package.json +12 -12
  50. package/node_modules/bl/test/test.js +14 -0
  51. package/node_modules/color-convert/README.md +62 -0
  52. package/node_modules/color-convert/conversions.js +594 -0
  53. package/node_modules/color-convert/css-keywords.js +151 -0
  54. package/node_modules/color-convert/index.js +75 -0
  55. package/node_modules/color-convert/package.json +92 -0
  56. package/node_modules/color-convert/route.js +98 -0
  57. package/node_modules/dashdash/lib/dashdash.js +1 -1
  58. package/node_modules/dashdash/node_modules/assert-plus/AUTHORS +6 -0
  59. package/node_modules/dashdash/node_modules/assert-plus/CHANGES.md +14 -0
  60. package/node_modules/dashdash/node_modules/assert-plus/README.md +162 -0
  61. package/node_modules/dashdash/node_modules/assert-plus/assert.js +211 -0
  62. package/node_modules/dashdash/node_modules/assert-plus/package.json +89 -0
  63. package/node_modules/dashdash/package.json +19 -12
  64. package/node_modules/ecc-jsbn/package.json +1 -2
  65. package/node_modules/escape-string-regexp/package.json +15 -11
  66. package/node_modules/extsprintf/package.json +2 -3
  67. package/node_modules/form-data/.dockerignore +7 -0
  68. package/node_modules/form-data/.editorconfig +10 -0
  69. package/node_modules/form-data/.eslintignore +1 -0
  70. package/node_modules/form-data/.eslintrc +64 -0
  71. package/node_modules/form-data/{Readme.md → README.md} +9 -1
  72. package/node_modules/form-data/lib/browser.js +2 -1
  73. package/node_modules/form-data/lib/form_data.js +172 -135
  74. package/node_modules/form-data/lib/populate.js +9 -0
  75. package/node_modules/form-data/package.json +35 -16
  76. package/node_modules/form-data/wercker.yml +36 -0
  77. package/node_modules/fstream-ignore/node_modules/minimatch/node_modules/brace-expansion/index.js +1 -1
  78. package/node_modules/fstream-ignore/node_modules/minimatch/node_modules/brace-expansion/package.json +14 -10
  79. package/node_modules/gauge/README.md +1 -1
  80. package/node_modules/gauge/package.json +18 -14
  81. package/node_modules/gauge/progress-bar.js +2 -2
  82. package/node_modules/http-signature/package.json +1 -2
  83. package/node_modules/is-my-json-valid/README.md +2 -2
  84. package/node_modules/is-my-json-valid/index.js +15 -6
  85. package/node_modules/is-my-json-valid/package.json +11 -7
  86. package/node_modules/is-my-json-valid/test/json-schema-draft4/multipleOf.json +36 -0
  87. package/node_modules/is-my-json-valid/test/misc.js +18 -0
  88. package/node_modules/is-typedarray/package.json +1 -2
  89. package/node_modules/isarray/.npmignore +1 -0
  90. package/node_modules/isarray/.travis.yml +4 -0
  91. package/node_modules/isarray/Makefile +6 -0
  92. package/node_modules/isarray/README.md +6 -0
  93. package/node_modules/isarray/index.js +3 -1
  94. package/node_modules/isarray/package.json +28 -10
  95. package/node_modules/isarray/test.js +20 -0
  96. package/node_modules/jodid25519/package.json +1 -2
  97. package/node_modules/jsbn/package.json +1 -2
  98. package/node_modules/json-schema/package.json +1 -1
  99. package/node_modules/jsprim/package.json +1 -2
  100. package/node_modules/lodash.pad/LICENSE +17 -16
  101. package/node_modules/lodash.pad/README.md +2 -2
  102. package/node_modules/lodash.pad/index.js +3 -94
  103. package/node_modules/lodash.pad/package.json +12 -12
  104. package/node_modules/lodash.padend/LICENSE +23 -0
  105. package/node_modules/lodash.padend/README.md +18 -0
  106. package/node_modules/lodash.padend/index.js +285 -0
  107. package/node_modules/lodash.padend/package.json +91 -0
  108. package/node_modules/lodash.padstart/LICENSE +23 -0
  109. package/node_modules/lodash.padstart/README.md +18 -0
  110. package/node_modules/lodash.padstart/index.js +285 -0
  111. package/node_modules/lodash.padstart/package.json +91 -0
  112. package/node_modules/lodash.repeat/LICENSE +17 -16
  113. package/node_modules/lodash.repeat/README.md +2 -2
  114. package/node_modules/lodash.repeat/index.js +3 -94
  115. package/node_modules/lodash.repeat/package.json +14 -13
  116. package/node_modules/lodash.tostring/LICENSE +23 -0
  117. package/node_modules/lodash.tostring/README.md +18 -0
  118. package/node_modules/lodash.tostring/index.js +164 -0
  119. package/node_modules/lodash.tostring/package.json +91 -0
  120. package/node_modules/mime-db/HISTORY.md +14 -0
  121. package/node_modules/mime-db/db.json +26 -3
  122. package/node_modules/mime-db/package.json +23 -18
  123. package/node_modules/mime-types/HISTORY.md +8 -0
  124. package/node_modules/mime-types/README.md +1 -1
  125. package/node_modules/mime-types/package.json +21 -16
  126. package/node_modules/node-pre-gyp/CHANGELOG.md +11 -0
  127. package/node_modules/node-pre-gyp/lib/util/abi_crosswalk.json +44 -4
  128. package/node_modules/node-pre-gyp/package.json +16 -16
  129. package/node_modules/npmlog/.nyc_output/64996.json +1 -0
  130. package/node_modules/npmlog/.nyc_output/64998.json +1 -0
  131. package/node_modules/npmlog/.nyc_output/65000.json +1 -0
  132. package/node_modules/npmlog/log.js +3 -2
  133. package/node_modules/npmlog/package.json +15 -11
  134. package/node_modules/npmlog/test/progress.js +25 -8
  135. package/node_modules/once/package.json +1 -1
  136. package/node_modules/qs/package.json +1 -2
  137. package/node_modules/readable-stream/.travis.yml +18 -16
  138. package/node_modules/readable-stream/README.md +1 -1
  139. package/node_modules/readable-stream/doc/stream.markdown +435 -405
  140. package/node_modules/readable-stream/lib/_stream_duplex.js +13 -20
  141. package/node_modules/readable-stream/lib/_stream_passthrough.js +3 -4
  142. package/node_modules/readable-stream/lib/_stream_readable.js +110 -205
  143. package/node_modules/readable-stream/lib/_stream_transform.js +21 -38
  144. package/node_modules/readable-stream/lib/_stream_writable.js +108 -121
  145. package/node_modules/readable-stream/package.json +19 -15
  146. package/node_modules/request/package.json +1 -2
  147. package/node_modules/rimraf/node_modules/glob/README.md +6 -0
  148. package/node_modules/rimraf/node_modules/glob/common.js +12 -3
  149. package/node_modules/rimraf/node_modules/glob/glob.js +20 -3
  150. package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/index.js +1 -1
  151. package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/package.json +14 -10
  152. package/node_modules/rimraf/node_modules/glob/package.json +15 -11
  153. package/node_modules/rimraf/node_modules/glob/sync.js +8 -1
  154. package/node_modules/rimraf/package.json +14 -10
  155. package/node_modules/semver/package.json +1 -2
  156. package/node_modules/sshpk/lib/formats/rfc4253.js +2 -1
  157. package/node_modules/sshpk/package.json +13 -10
  158. package/node_modules/strip-ansi/package.json +21 -16
  159. package/node_modules/strip-ansi/readme.md +5 -5
  160. package/node_modules/tough-cookie/lib/cookie.js +2 -2
  161. package/node_modules/tough-cookie/package.json +13 -9
  162. package/node_modules/tweetnacl/CHANGELOG.md +53 -0
  163. package/node_modules/tweetnacl/COPYING.txt +9 -0
  164. package/node_modules/tweetnacl/README.md +14 -40
  165. package/node_modules/tweetnacl/nacl-fast.js +21 -51
  166. package/node_modules/tweetnacl/nacl-fast.min.js +2 -2
  167. package/node_modules/tweetnacl/nacl.js +21 -51
  168. package/node_modules/tweetnacl/nacl.min.js +1 -1
  169. package/node_modules/tweetnacl/package.json +28 -38
  170. package/node_modules/verror/package.json +2 -3
  171. package/package.json +2 -2
  172. package/node_modules/aws4/example.js +0 -372
  173. package/node_modules/aws4/node_modules/lru-cache/test/memory-leak.js +0 -51
  174. package/node_modules/isarray/build/build.js +0 -209
  175. package/node_modules/lodash._basetostring/LICENSE +0 -22
  176. package/node_modules/lodash._basetostring/README.md +0 -20
  177. package/node_modules/lodash._basetostring/index.js +0 -22
  178. package/node_modules/lodash._basetostring/package.json +0 -99
  179. package/node_modules/lodash._createpadding/LICENSE +0 -22
  180. package/node_modules/lodash._createpadding/README.md +0 -20
  181. package/node_modules/lodash._createpadding/index.js +0 -37
  182. package/node_modules/lodash._createpadding/package.json +0 -101
  183. package/node_modules/lodash._root/LICENSE +0 -22
  184. package/node_modules/lodash._root/README.md +0 -18
  185. package/node_modules/lodash._root/index.js +0 -53
  186. package/node_modules/lodash._root/package.json +0 -77
  187. package/node_modules/lodash.padleft/LICENSE.txt +0 -22
  188. package/node_modules/lodash.padleft/README.md +0 -20
  189. package/node_modules/lodash.padleft/index.js +0 -50
  190. package/node_modules/lodash.padleft/package.json +0 -107
  191. package/node_modules/lodash.padright/LICENSE.txt +0 -22
  192. package/node_modules/lodash.padright/README.md +0 -20
  193. package/node_modules/lodash.padright/index.js +0 -50
  194. package/node_modules/lodash.padright/package.json +0 -107
@@ -1,10 +1,34 @@
1
1
  'use strict';
2
+ var colorConvert = require('color-convert');
2
3
 
3
- function assembleStyles () {
4
+ function wrapAnsi16(fn, offset) {
5
+ return function () {
6
+ var code = fn.apply(colorConvert, arguments);
7
+ return '\u001b[' + (code + offset) + 'm';
8
+ };
9
+ }
10
+
11
+ function wrapAnsi256(fn, offset) {
12
+ return function () {
13
+ var code = fn.apply(colorConvert, arguments);
14
+ return '\u001b[' + (38 + offset) + ';5;' + code + 'm';
15
+ };
16
+ }
17
+
18
+ function wrapAnsi16m(fn, offset) {
19
+ return function () {
20
+ var rgb = fn.apply(colorConvert, arguments);
21
+ return '\u001b[' + (38 + offset) + ';2;' +
22
+ rgb[0] + ';' + rgb[1] + ';' + rgb[2] + 'm';
23
+ };
24
+ }
25
+
26
+ function assembleStyles() {
4
27
  var styles = {
5
- modifiers: {
28
+ modifier: {
6
29
  reset: [0, 0],
7
- bold: [1, 22], // 21 isn't widely supported and 22 does the same thing
30
+ // 21 isn't widely supported and 22 does the same thing
31
+ bold: [1, 22],
8
32
  dim: [2, 22],
9
33
  italic: [3, 23],
10
34
  underline: [4, 24],
@@ -12,7 +36,7 @@ function assembleStyles () {
12
36
  hidden: [8, 28],
13
37
  strikethrough: [9, 29]
14
38
  },
15
- colors: {
39
+ color: {
16
40
  black: [30, 39],
17
41
  red: [31, 39],
18
42
  green: [32, 39],
@@ -23,7 +47,7 @@ function assembleStyles () {
23
47
  white: [37, 39],
24
48
  gray: [90, 39]
25
49
  },
26
- bgColors: {
50
+ bgColor: {
27
51
  bgBlack: [40, 49],
28
52
  bgRed: [41, 49],
29
53
  bgGreen: [42, 49],
@@ -36,7 +60,7 @@ function assembleStyles () {
36
60
  };
37
61
 
38
62
  // fix humans
39
- styles.colors.grey = styles.colors.gray;
63
+ styles.color.grey = styles.color.gray;
40
64
 
41
65
  Object.keys(styles).forEach(function (groupName) {
42
66
  var group = styles[groupName];
@@ -56,6 +80,48 @@ function assembleStyles () {
56
80
  });
57
81
  });
58
82
 
83
+ function rgb2rgb(r, g, b) {
84
+ return [r, g, b];
85
+ }
86
+
87
+ styles.color.close = '\u001b[39m';
88
+ styles.bgColor.close = '\u001b[49m';
89
+
90
+ styles.color.ansi = {};
91
+ styles.color.ansi256 = {};
92
+ styles.color.ansi16m = {
93
+ rgb: wrapAnsi16m(rgb2rgb, 0)
94
+ };
95
+
96
+ styles.bgColor.ansi = {};
97
+ styles.bgColor.ansi256 = {};
98
+ styles.bgColor.ansi16m = {
99
+ rgb: wrapAnsi16m(rgb2rgb, 10)
100
+ };
101
+
102
+ for (var key in colorConvert) {
103
+ if (!colorConvert.hasOwnProperty(key) || typeof colorConvert[key] !== 'object') {
104
+ continue;
105
+ }
106
+
107
+ var suite = colorConvert[key];
108
+
109
+ if ('ansi16' in suite) {
110
+ styles.color.ansi[key] = wrapAnsi16(suite.ansi16, 0);
111
+ styles.bgColor.ansi[key] = wrapAnsi16(suite.ansi16, 10);
112
+ }
113
+
114
+ if ('ansi256' in suite) {
115
+ styles.color.ansi256[key] = wrapAnsi256(suite.ansi256, 0);
116
+ styles.bgColor.ansi256[key] = wrapAnsi256(suite.ansi256, 10);
117
+ }
118
+
119
+ if ('rgb' in suite) {
120
+ styles.color.ansi16m[key] = wrapAnsi16m(suite.rgb, 0);
121
+ styles.bgColor.ansi16m[key] = wrapAnsi16m(suite.rgb, 10);
122
+ }
123
+ }
124
+
59
125
  return styles;
60
126
  }
61
127
 
@@ -1,19 +1,23 @@
1
1
  {
2
2
  "_from": "ansi-styles@^2.1.0",
3
- "_id": "ansi-styles@2.1.0",
3
+ "_id": "ansi-styles@2.2.0",
4
4
  "_location": "/ansi-styles",
5
- "_nodeVersion": "0.12.4",
5
+ "_nodeVersion": "4.2.6",
6
+ "_npmOperationalInternal": {
7
+ "host": "packages-5-east.internal.npmjs.com",
8
+ "tmp": "tmp/ansi-styles-2.2.0.tgz_1456057673117_0.8365559694357216"
9
+ },
6
10
  "_npmUser": {
7
11
  "email": "jappelman@xebia.com",
8
12
  "name": "jbnicolai"
9
13
  },
10
- "_npmVersion": "2.10.1",
14
+ "_npmVersion": "2.14.12",
11
15
  "_phantomChildren": {},
12
16
  "_requiredBy": [
13
17
  "/chalk"
14
18
  ],
15
- "_resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.1.0.tgz",
16
- "_shasum": "990f747146927b559a932bf92959163d60c0d0e2",
19
+ "_resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.0.tgz",
20
+ "_shasum": "c59191936e6ed1c1315a4b6b6b97f3acfbfa68b0",
17
21
  "_shrinkwrap": null,
18
22
  "author": {
19
23
  "email": "sindresorhus@gmail.com",
@@ -23,15 +27,18 @@
23
27
  "bugs": {
24
28
  "url": "https://github.com/chalk/ansi-styles/issues"
25
29
  },
26
- "dependencies": {},
30
+ "dependencies": {
31
+ "color-convert": "^1.0.0"
32
+ },
27
33
  "description": "ANSI escape codes for styling strings in the terminal",
28
34
  "devDependencies": {
29
- "mocha": "*"
35
+ "ava": "*",
36
+ "xo": "*"
30
37
  },
31
38
  "directories": {},
32
39
  "dist": {
33
- "shasum": "990f747146927b559a932bf92959163d60c0d0e2",
34
- "tarball": "http://registry.npmjs.org/ansi-styles/-/ansi-styles-2.1.0.tgz"
40
+ "shasum": "c59191936e6ed1c1315a4b6b6b97f3acfbfa68b0",
41
+ "tarball": "http://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.0.tgz"
35
42
  },
36
43
  "engines": {
37
44
  "node": ">=0.10.0"
@@ -39,7 +46,7 @@
39
46
  "files": [
40
47
  "index.js"
41
48
  ],
42
- "gitHead": "18421cbe4a2d93359ec2599a894f704be126d066",
49
+ "gitHead": "74502955deaf0eb977507757e33c52cad5a9aefa",
43
50
  "homepage": "https://github.com/chalk/ansi-styles",
44
51
  "keywords": [
45
52
  "256",
@@ -82,7 +89,7 @@
82
89
  "url": "git+https://github.com/chalk/ansi-styles.git"
83
90
  },
84
91
  "scripts": {
85
- "test": "mocha"
92
+ "test": "xo && ava"
86
93
  },
87
- "version": "2.1.0"
94
+ "version": "2.2.0"
88
95
  }
@@ -17,12 +17,20 @@ $ npm install --save ansi-styles
17
17
  ## Usage
18
18
 
19
19
  ```js
20
- var ansi = require('ansi-styles');
21
-
22
- console.log(ansi.green.open + 'Hello world!' + ansi.green.close);
20
+ const style = require('ansi-styles');
21
+
22
+ console.log(style.green.open + 'Hello world!' + style.green.close);
23
+
24
+ // color conversion between 16/256/truecolor
25
+ // NOTE: if conversion goes to 16 colors or 256 colors, the original color
26
+ // may be degraded to fit that color palette. This means terminals
27
+ // that do not support 16 million colors will best-match the
28
+ // original color.
29
+ console.log(style.bgColor.ansi.hsl(120, 80, 72) + 'Hello world!' + style.bgColor.close);
30
+ console.log(style.color.ansi256.rgb(199, 20, 250) + 'Hello world!' + style.color.close);
31
+ console.log(style.color.ansi16m.hex('#ABCDEF') + 'Hello world!' + style.color.close);
23
32
  ```
24
33
 
25
-
26
34
  ## API
27
35
 
28
36
  Each style has an `open` and `close` property.
@@ -69,17 +77,37 @@ Each style has an `open` and `close` property.
69
77
 
70
78
  By default you get a map of styles, but the styles are also available as groups. They are non-enumerable so they don't show up unless you access them explicitly. This makes it easier to expose only a subset in a higher-level module.
71
79
 
72
- - `ansi.modifiers`
73
- - `ansi.colors`
74
- - `ansi.bgColors`
80
+ - `style.modifier`
81
+ - `style.color`
82
+ - `style.bgColor`
75
83
 
76
84
 
77
85
  ###### Example
78
86
 
79
87
  ```js
80
- console.log(ansi.colors.green.open);
88
+ console.log(style.color.green.open);
81
89
  ```
82
90
 
91
+ ## [256 / 16 million (TrueColor) support](https://gist.github.com/XVilka/8346728)
92
+ `ansi-styles` uses the [`color-convert`](https://github.com/MoOx/color-convert) package to allow for converting between various colors and ANSI escapes, with support for 256 and 16 million colors.
93
+
94
+ To use these, call the associated conversion function with the intended output, e.g.:
95
+
96
+ ```js
97
+ style.color.ansi.rgb(100, 200, 15); // RGB to 16 color ansi foreground code
98
+ style.bgColor.ansi.rgb(100, 200, 15); // RGB to 16 color ansi background code
99
+
100
+ style.color.ansi256.hsl(120, 100, 60); // HSL to 256 color ansi foreground code
101
+ style.bgColor.ansi256.hsl(120, 100, 60); // HSL to 256 color ansi foreground code
102
+
103
+ style.color.ansi16m.hex('#C0FFEE'); // Hex (RGB) to 16 million color foreground code
104
+ style.bgColor.ansi16m.hex('#C0FFEE'); // Hex (RGB) to 16 million color background code
105
+ ```
106
+
107
+ ## Related
108
+
109
+ - [ansi-escapes](https://github.com/sindresorhus/ansi-escapes) - ANSI escape codes for manipulating the terminal
110
+
83
111
 
84
112
  ## License
85
113
 
@@ -0,0 +1,19 @@
1
+ Hi, figured we could actually use a changelog now:
2
+
3
+ ## 1.1.1 2016-01-29
4
+
5
+ * Fix a typo in stream completion tracker
6
+
7
+ ## 1.1.0 2016-01-29
8
+
9
+ * Rewrote completion percent computation to be low impact– no more walking a
10
+ tree of completion groups every time we need this info. Previously, with
11
+ medium sized tree of completion groups, even a relatively modest number of
12
+ calls to the top level `completed()` method would result in absurd numbers
13
+ of calls overall as it walked down the tree. We now, instead, keep track as
14
+ we bubble up changes, so the computation is limited to when data changes and
15
+ to the depth of that one branch, instead of _every_ node. (Plus, we were already
16
+ incurring _this_ cost, since we already bubbled out changes.)
17
+ * Moved different tracker types out to their own files.
18
+ * Made tests test for TOO MANY events too.
19
+ * Standarized the source code formatting
@@ -62,8 +62,18 @@ This will result in one or more `change` events being emitted.
62
62
  Events
63
63
  ======
64
64
 
65
- All tracker objects emit `change` events with an argument of the name of the
66
- thing changing.
65
+ All tracker objects emit `change` events with the following arguments:
66
+
67
+ ```
68
+ function (name, completed, tracker)
69
+ ```
70
+
71
+ `name` is the name of the tracker that originally emitted the event,
72
+ or if it didn't have one, the first containing tracker group that had one.
73
+
74
+ `completed` is the percent complete (as returned by `tracker.completed()` method).
75
+
76
+ `tracker` is the tracker object that you are listening for events on.
67
77
 
68
78
  TrackerGroup
69
79
  ============
@@ -1,132 +1,4 @@
1
- "use strict"
2
- var stream = require("readable-stream")
3
- var EventEmitter = require("events").EventEmitter
4
- var util = require("util")
5
- var delegate = require("delegates")
6
-
7
- function noteChange (trackerGroup) {
8
- return function (name) {
9
- trackerGroup.emit('change', name || trackerGroup.name);
10
- }
11
- }
12
-
13
- var TrackerGroup = exports.TrackerGroup = function (name) {
14
- EventEmitter.call(this)
15
- this.name = name
16
- this.trackGroup = []
17
- this.totalWeight = 0
18
- this.noteChange = noteChange(this)
19
- }
20
- util.inherits(TrackerGroup, EventEmitter)
21
-
22
- TrackerGroup.prototype.completed = function () {
23
- if (this.trackGroup.length==0) return 0
24
- var valPerWeight = 1 / this.totalWeight
25
- var completed = 0
26
- for (var i = 0, len = this.trackGroup.length; i < len; i++){
27
- var group = this.trackGroup[i];
28
- completed += valPerWeight * group.weight * group.completed()
29
- }
30
- return completed
31
- }
32
-
33
- TrackerGroup.prototype.addUnit = function (unit, weight, noChange) {
34
- unit.weight = weight || 1
35
- this.totalWeight += unit.weight
36
- this.trackGroup.push(unit)
37
- // Bubble events back up
38
- unit.on("change", this.noteChange)
39
- if (! noChange) this.emit("change", this.name)
40
- return unit
41
- }
42
-
43
- TrackerGroup.prototype.newGroup = function (name, weight) {
44
- return this.addUnit(new TrackerGroup(name), weight)
45
- }
46
-
47
- TrackerGroup.prototype.newItem = function (name, todo, weight) {
48
- return this.addUnit(new Tracker(name, todo), weight)
49
- }
50
-
51
- TrackerGroup.prototype.newStream = function (name, todo, weight) {
52
- return this.addUnit(new TrackerStream(name, todo), weight)
53
- }
54
-
55
- TrackerGroup.prototype.finish = function () {
56
- if (! this.trackGroup.length) this.addUnit(new Tracker(), 1, true)
57
- for (var i = 0, len = this.trackGroup.length; i < len; i++) {
58
- var group = this.trackGroup[i]
59
- group.removeListener("change", this.noteChange)
60
- group.finish()
61
- }
62
- this.emit("change", this.name)
63
- }
64
-
65
- var buffer = " "
66
- TrackerGroup.prototype.debug = function (depth) {
67
- depth = depth || 0
68
- var indent = depth ? buffer.substr(0,depth) : ""
69
- var output = indent + (this.name||"top") + ": " + this.completed() + "\n"
70
- this.trackGroup.forEach(function(T) {
71
- if (T instanceof TrackerGroup) {
72
- output += T.debug(depth + 1)
73
- }
74
- else {
75
- output += indent + " " + T.name + ": " + T.completed() + "\n"
76
- }
77
- })
78
- return output
79
- }
80
-
81
- var Tracker = exports.Tracker = function (name,todo) {
82
- EventEmitter.call(this)
83
- this.name = name
84
- this.workDone = 0
85
- this.workTodo = todo || 0
86
- }
87
- util.inherits(Tracker, EventEmitter)
88
-
89
- Tracker.prototype.completed = function () {
90
- return this.workTodo === 0 ? 0 : this.workDone / this.workTodo
91
- }
92
-
93
- Tracker.prototype.addWork = function (work) {
94
- this.workTodo += work
95
- this.emit("change", this.name)
96
- }
97
-
98
- Tracker.prototype.completeWork = function (work) {
99
- this.workDone += work
100
- if (this.workDone > this.workTodo) this.workDone = this.workTodo
101
- this.emit("change", this.name)
102
- }
103
-
104
- Tracker.prototype.finish = function () {
105
- this.workTodo = this.workDone = 1
106
- this.emit("change", this.name)
107
- }
108
-
109
-
110
- var TrackerStream = exports.TrackerStream = function (name, size, options) {
111
- stream.Transform.call(this, options)
112
- this.tracker = new Tracker(name, size)
113
- this.name = name
114
- var self = this
115
- this.tracker.on("change", function (name) { self.emit("change", name) })
116
- }
117
- util.inherits(TrackerStream, stream.Transform)
118
-
119
- TrackerStream.prototype._transform = function (data, encoding, cb) {
120
- this.tracker.completeWork(data.length ? data.length : 1)
121
- this.push(data)
122
- cb()
123
- }
124
-
125
- TrackerStream.prototype._flush = function (cb) {
126
- this.tracker.finish()
127
- cb()
128
- }
129
-
130
- delegate(TrackerStream.prototype, "tracker")
131
- .method("completed")
132
- .method("addWork")
1
+ 'use strict'
2
+ exports.TrackerGroup = require('./tracker-group.js')
3
+ exports.Tracker = require('./tracker.js')
4
+ exports.TrackerStream = require('./tracker-stream.js')
@@ -1,19 +1,23 @@
1
1
  {
2
- "_from": "are-we-there-yet@~1.0.6",
3
- "_id": "are-we-there-yet@1.0.6",
2
+ "_from": "are-we-there-yet@~1.1.2",
3
+ "_id": "are-we-there-yet@1.1.2",
4
4
  "_location": "/are-we-there-yet",
5
- "_nodeVersion": "5.4.0",
5
+ "_nodeVersion": "4.2.2",
6
+ "_npmOperationalInternal": {
7
+ "host": "packages-13-west.internal.npmjs.com",
8
+ "tmp": "tmp/are-we-there-yet-1.1.2.tgz_1458084397358_0.15847722673788667"
9
+ },
6
10
  "_npmUser": {
7
11
  "email": "me@re-becca.org",
8
12
  "name": "iarna"
9
13
  },
10
- "_npmVersion": "3.6.0",
14
+ "_npmVersion": "3.8.1",
11
15
  "_phantomChildren": {},
12
16
  "_requiredBy": [
13
17
  "/npmlog"
14
18
  ],
15
- "_resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.0.6.tgz",
16
- "_shasum": "a2d28c93102aa6cc96245a26cb954de06ec53f0c",
19
+ "_resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.2.tgz",
20
+ "_shasum": "80e470e95a084794fe1899262c5667c6e88de1b3",
17
21
  "_shrinkwrap": null,
18
22
  "author": {
19
23
  "name": "Rebecca Turner",
@@ -28,14 +32,15 @@
28
32
  },
29
33
  "description": "Keep track of the overall completion of many dispirate processes",
30
34
  "devDependencies": {
31
- "tap": "^5.2.0"
35
+ "standard": "^6.0.8",
36
+ "tap": "^5.7.0"
32
37
  },
33
38
  "directories": {},
34
39
  "dist": {
35
- "shasum": "a2d28c93102aa6cc96245a26cb954de06ec53f0c",
36
- "tarball": "http://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.0.6.tgz"
40
+ "shasum": "80e470e95a084794fe1899262c5667c6e88de1b3",
41
+ "tarball": "http://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.2.tgz"
37
42
  },
38
- "gitHead": "5f19c8b6f9c5afb8b0b17308cb9d66f7027ae526",
43
+ "gitHead": "dd5706e2204cb681e78031d0ffe156ed4cc75823",
39
44
  "homepage": "https://github.com/iarna/are-we-there-yet",
40
45
  "license": "ISC",
41
46
  "main": "index.js",
@@ -47,14 +52,14 @@
47
52
  ],
48
53
  "name": "are-we-there-yet",
49
54
  "optionalDependencies": {},
50
- "readme": "are-we-there-yet\n----------------\n\nTrack complex hiearchies of asynchronous task completion statuses. This is\nintended to give you a way of recording and reporting the progress of the big\nrecursive fan-out and gather type workflows that are so common in async.\n\nWhat you do with this completion data is up to you, but the most common use case is to\nfeed it to one of the many progress bar modules.\n\nMost progress bar modules include a rudamentary version of this, but my\nneeds were more complex.\n\nUsage\n=====\n\n```javascript\nvar TrackerGroup = require(\"are-we-there-yet\").TrackerGroup\n\nvar top = new TrackerGroup(\"program\")\n\nvar single = top.newItem(\"one thing\", 100)\nsingle.completeWork(20)\n\nconsole.log(top.completed()) // 0.2\n\nfs.stat(\"file\", function(er, stat) {\n if (er) throw er \n var stream = top.newStream(\"file\", stat.size)\n console.log(top.completed()) // now 0.1 as single is 50% of the job and is 20% complete\n // and 50% * 20% == 10%\n fs.createReadStream(\"file\").pipe(stream).on(\"data\", function (chunk) {\n // do stuff with chunk\n })\n top.on(\"change\", function (name) {\n // called each time a chunk is read from \"file\"\n // top.completed() will start at 0.1 and fill up to 0.6 as the file is read\n })\n})\n```\n\nShared Methods\n==============\n\nAll tracker objects described below have the following methods, they, along\nwith the event comprise the interface for consumers of tracker objects.\n\n* var completed = tracker.completed()\n\nReturns the ratio of completed work to work to be done. Range of 0 to 1.\n\n* tracker.finish()\n\nMarks the tracker as completed. With a TrackerGroup this marks all of its\ncomponents as completed.\n\nMarks all of the components of this tracker as finished, which in turn means\nthat `tracker.completed()` for this will now be 1.\n\nThis will result in one or more `change` events being emitted.\n\nEvents\n======\n\nAll tracker objects emit `change` events with an argument of the name of the\nthing changing.\n\nTrackerGroup\n============\n\n* var tracker = new TrackerGroup(**name**)\n\n * **name** *(optional)* - The name of this tracker group, used in change\n notifications if the component updating didn't have a name. Defaults to undefined.\n\nCreates a new empty tracker aggregation group. These are trackers whose\ncompletion status is determined by the completion status of other trackers.\n\n* tracker.addUnit(**otherTracker**, **weight**)\n\n * **otherTracker** - Any of the other are-we-there-yet tracker objects\n * **weight** *(optional)* - The weight to give the tracker, defaults to 1.\n\nAdds the **otherTracker** to this aggregation group. The weight determines\nhow long you expect this tracker to take to complete in proportion to other\nunits. So for instance, if you add one tracker with a weight of 1 and\nanother with a weight of 2, you're saying the second will take twice as long\nto complete as the first. As such, the first will account for 33% of the\ncompletion of this tracker and the second will account for the other 67%.\n\nReturns **otherTracker**.\n\n* var subGroup = tracker.newGroup(**name**, **weight**)\n\nThe above is exactly equivalent to:\n\n```javascript\n var subGroup = tracker.addUnit(new TrackerGroup(name), weight)\n```\n\n* var subItem = tracker.newItem(**name**, **todo**, **weight**)\n\nThe above is exactly equivalent to:\n\n```javascript\n var subItem = tracker.addUnit(new Tracker(name, todo), weight)\n```\n\n* var subStream = tracker.newStream(**name**, **todo**, **weight**)\n\nThe above is exactly equivalent to:\n\n```javascript\n var subStream = tracker.addUnit(new TrackerStream(name, todo), weight)\n```\n\n* console.log( tracker.debug() )\n\nReturns a tree showing the completion of this tracker group and all of its\nchildren, including recursively entering all of the children.\n\nTracker\n=======\n\n* var tracker = new Tracker(**name**, **todo**)\n\n * **name** *(optional)* The name of this counter to report in change\n events. Defaults to undefined.\n * **todo** *(optional)* The amount of work todo (a number). Defaults to 0.\n\nOrdinarily these are constructed as a part of a tracker group (via\n`newItem`).\n\n* var completed = tracker.completed()\n\nReturns the ratio of completed work to work to be done. Range of 0 to 1. If\ntotal work to be done is 0 then it will return 0.\n\n* tracker.addWork(**todo**)\n\n * **todo** A number to add to the amount of work to be done.\n\nIncreases the amount of work to be done, thus decreasing the completion\npercentage. Triggers a `change` event.\n\n* tracker.completeWork(**completed**)\n\n * **completed** A number to add to the work complete\n\nIncrease the amount of work complete, thus increasing the completion percentage.\nWill never increase the work completed past the amount of work todo. That is,\npercentages > 100% are not allowed. Triggers a `change` event.\n\n* tracker.finish()\n\nMarks this tracker as finished, tracker.completed() will now be 1. Triggers\na `change` event.\n\nTrackerStream\n=============\n\n* var tracker = new TrackerStream(**name**, **size**, **options**)\n\n * **name** *(optional)* The name of this counter to report in change\n events. Defaults to undefined.\n * **size** *(optional)* The number of bytes being sent through this stream.\n * **options** *(optional)* A hash of stream options\n\nThe tracker stream object is a pass through stream that updates an internal\ntracker object each time a block passes through. It's intended to track\ndownloads, file extraction and other related activities. You use it by piping\nyour data source into it and then using it as your data source.\n\nIf your data has a length attribute then that's used as the amount of work\ncompleted when the chunk is passed through. If it does not (eg, object\nstreams) then each chunk counts as completing 1 unit of work, so your size\nshould be the total number of objects being streamed.\n\n* tracker.addWork(**todo**)\n\n * **todo** Increase the expected overall size by **todo** bytes.\n\nIncreases the amount of work to be done, thus decreasing the completion\npercentage. Triggers a `change` event.\n",
55
+ "readme": "are-we-there-yet\n----------------\n\nTrack complex hiearchies of asynchronous task completion statuses. This is\nintended to give you a way of recording and reporting the progress of the big\nrecursive fan-out and gather type workflows that are so common in async.\n\nWhat you do with this completion data is up to you, but the most common use case is to\nfeed it to one of the many progress bar modules.\n\nMost progress bar modules include a rudamentary version of this, but my\nneeds were more complex.\n\nUsage\n=====\n\n```javascript\nvar TrackerGroup = require(\"are-we-there-yet\").TrackerGroup\n\nvar top = new TrackerGroup(\"program\")\n\nvar single = top.newItem(\"one thing\", 100)\nsingle.completeWork(20)\n\nconsole.log(top.completed()) // 0.2\n\nfs.stat(\"file\", function(er, stat) {\n if (er) throw er \n var stream = top.newStream(\"file\", stat.size)\n console.log(top.completed()) // now 0.1 as single is 50% of the job and is 20% complete\n // and 50% * 20% == 10%\n fs.createReadStream(\"file\").pipe(stream).on(\"data\", function (chunk) {\n // do stuff with chunk\n })\n top.on(\"change\", function (name) {\n // called each time a chunk is read from \"file\"\n // top.completed() will start at 0.1 and fill up to 0.6 as the file is read\n })\n})\n```\n\nShared Methods\n==============\n\nAll tracker objects described below have the following methods, they, along\nwith the event comprise the interface for consumers of tracker objects.\n\n* var completed = tracker.completed()\n\nReturns the ratio of completed work to work to be done. Range of 0 to 1.\n\n* tracker.finish()\n\nMarks the tracker as completed. With a TrackerGroup this marks all of its\ncomponents as completed.\n\nMarks all of the components of this tracker as finished, which in turn means\nthat `tracker.completed()` for this will now be 1.\n\nThis will result in one or more `change` events being emitted.\n\nEvents\n======\n\nAll tracker objects emit `change` events with the following arguments:\n\n```\nfunction (name, completed, tracker)\n```\n\n`name` is the name of the tracker that originally emitted the event,\nor if it didn't have one, the first containing tracker group that had one.\n\n`completed` is the percent complete (as returned by `tracker.completed()` method).\n\n`tracker` is the tracker object that you are listening for events on.\n\nTrackerGroup\n============\n\n* var tracker = new TrackerGroup(**name**)\n\n * **name** *(optional)* - The name of this tracker group, used in change\n notifications if the component updating didn't have a name. Defaults to undefined.\n\nCreates a new empty tracker aggregation group. These are trackers whose\ncompletion status is determined by the completion status of other trackers.\n\n* tracker.addUnit(**otherTracker**, **weight**)\n\n * **otherTracker** - Any of the other are-we-there-yet tracker objects\n * **weight** *(optional)* - The weight to give the tracker, defaults to 1.\n\nAdds the **otherTracker** to this aggregation group. The weight determines\nhow long you expect this tracker to take to complete in proportion to other\nunits. So for instance, if you add one tracker with a weight of 1 and\nanother with a weight of 2, you're saying the second will take twice as long\nto complete as the first. As such, the first will account for 33% of the\ncompletion of this tracker and the second will account for the other 67%.\n\nReturns **otherTracker**.\n\n* var subGroup = tracker.newGroup(**name**, **weight**)\n\nThe above is exactly equivalent to:\n\n```javascript\n var subGroup = tracker.addUnit(new TrackerGroup(name), weight)\n```\n\n* var subItem = tracker.newItem(**name**, **todo**, **weight**)\n\nThe above is exactly equivalent to:\n\n```javascript\n var subItem = tracker.addUnit(new Tracker(name, todo), weight)\n```\n\n* var subStream = tracker.newStream(**name**, **todo**, **weight**)\n\nThe above is exactly equivalent to:\n\n```javascript\n var subStream = tracker.addUnit(new TrackerStream(name, todo), weight)\n```\n\n* console.log( tracker.debug() )\n\nReturns a tree showing the completion of this tracker group and all of its\nchildren, including recursively entering all of the children.\n\nTracker\n=======\n\n* var tracker = new Tracker(**name**, **todo**)\n\n * **name** *(optional)* The name of this counter to report in change\n events. Defaults to undefined.\n * **todo** *(optional)* The amount of work todo (a number). Defaults to 0.\n\nOrdinarily these are constructed as a part of a tracker group (via\n`newItem`).\n\n* var completed = tracker.completed()\n\nReturns the ratio of completed work to work to be done. Range of 0 to 1. If\ntotal work to be done is 0 then it will return 0.\n\n* tracker.addWork(**todo**)\n\n * **todo** A number to add to the amount of work to be done.\n\nIncreases the amount of work to be done, thus decreasing the completion\npercentage. Triggers a `change` event.\n\n* tracker.completeWork(**completed**)\n\n * **completed** A number to add to the work complete\n\nIncrease the amount of work complete, thus increasing the completion percentage.\nWill never increase the work completed past the amount of work todo. That is,\npercentages > 100% are not allowed. Triggers a `change` event.\n\n* tracker.finish()\n\nMarks this tracker as finished, tracker.completed() will now be 1. Triggers\na `change` event.\n\nTrackerStream\n=============\n\n* var tracker = new TrackerStream(**name**, **size**, **options**)\n\n * **name** *(optional)* The name of this counter to report in change\n events. Defaults to undefined.\n * **size** *(optional)* The number of bytes being sent through this stream.\n * **options** *(optional)* A hash of stream options\n\nThe tracker stream object is a pass through stream that updates an internal\ntracker object each time a block passes through. It's intended to track\ndownloads, file extraction and other related activities. You use it by piping\nyour data source into it and then using it as your data source.\n\nIf your data has a length attribute then that's used as the amount of work\ncompleted when the chunk is passed through. If it does not (eg, object\nstreams) then each chunk counts as completing 1 unit of work, so your size\nshould be the total number of objects being streamed.\n\n* tracker.addWork(**todo**)\n\n * **todo** Increase the expected overall size by **todo** bytes.\n\nIncreases the amount of work to be done, thus decreasing the completion\npercentage. Triggers a `change` event.\n",
51
56
  "readmeFilename": "README.md",
52
57
  "repository": {
53
58
  "type": "git",
54
59
  "url": "git+https://github.com/iarna/are-we-there-yet.git"
55
60
  },
56
61
  "scripts": {
57
- "test": "tap test/*.js"
62
+ "test": "standard && tap test/*.js"
58
63
  },
59
- "version": "1.0.6"
64
+ "version": "1.1.2"
60
65
  }
@@ -0,0 +1,29 @@
1
+ 'use strict'
2
+ var util = require('util')
3
+
4
+ module.exports = function (obj, event, next) {
5
+ var timeout = setTimeout(gotTimeout, 10)
6
+ obj.once(event, gotResult)
7
+
8
+ function gotTimeout () {
9
+ obj.removeListener(event, gotResult)
10
+ next(new Error('Timeout listening for ' + event))
11
+ }
12
+ var result = []
13
+ function gotResult () {
14
+ result = Array.prototype.slice.call(arguments)
15
+ clearTimeout(timeout)
16
+ timeout = setTimeout(gotNoMoreResults, 10)
17
+ obj.once(event, gotTooManyResults)
18
+ }
19
+ function gotNoMoreResults () {
20
+ obj.removeListener(event, gotTooManyResults)
21
+ var args = [null].concat(result)
22
+ next.apply(null, args)
23
+ }
24
+ function gotTooManyResults () {
25
+ var secondResult = Array.prototype.slice.call(arguments)
26
+ clearTimeout(timeout)
27
+ next(new Error('Got too many results, first ' + util.inspect(result) + ' and then ' + util.inspect(secondResult)))
28
+ }
29
+ }
@@ -1,56 +1,57 @@
1
- "use strict"
2
- var test = require("tap").test
3
- var Tracker = require("../index.js").Tracker
4
-
5
- var timeoutError = new Error("timeout")
6
- var testEvent = function (obj,event,next) {
7
- var timeout = setTimeout(function(){
8
- obj.removeListener(event, eventHandler)
9
- next(timeoutError)
10
- }, 10)
11
- var eventHandler = function () {
12
- var args = Array.prototype.slice.call(arguments)
13
- args.unshift(null)
14
- clearTimeout(timeout)
15
- next.apply(null, args)
16
- }
17
- obj.once(event, eventHandler)
18
- }
1
+ 'use strict'
2
+ var test = require('tap').test
3
+ var Tracker = require('../index.js').Tracker
4
+
5
+ var testEvent = require('./lib/test-event.js')
19
6
 
20
- test("Tracker", function (t) {
21
- t.plan(10)
7
+ var name = 'test'
22
8
 
23
- var name = "test"
24
- var track = new Tracker(name)
9
+ test('initialization', function (t) {
10
+ var simple = new Tracker(name)
25
11
 
26
- t.is(track.completed(), 0, "Nothing todo is 0 completion")
12
+ t.is(simple.completed(), 0, 'Nothing todo is 0 completion')
13
+ t.done()
14
+ })
27
15
 
28
- var todo = 100
16
+ var track
17
+ var todo = 100
18
+ test('completion', function (t) {
29
19
  track = new Tracker(name, todo)
30
- t.is(track.completed(), 0, "Nothing done is 0 completion")
20
+ t.is(track.completed(), 0, 'Nothing done is 0 completion')
31
21
 
32
- testEvent(track, "change", afterCompleteWork)
33
- track.completeWork(100)
34
- function afterCompleteWork(er, onChangeName) {
35
- t.is(er, null, "completeWork: on change event fired")
36
- t.is(onChangeName, name, "completeWork: on change emits the correct name")
37
- }
38
- t.is(track.completed(), 1, "completeWork: 100% completed")
22
+ testEvent(track, 'change', afterCompleteWork)
23
+
24
+ track.completeWork(todo)
25
+ t.is(track.completed(), 1, 'completeWork: 100% completed')
39
26
 
40
- testEvent(track, "change", afterAddWork)
41
- track.addWork(100)
42
- function afterAddWork(er, onChangeName) {
43
- t.is(er, null, "addWork: on change event fired")
44
- t.is(onChangeName, name, "addWork: on change emits the correct name")
27
+ function afterCompleteWork (er, onChangeName) {
28
+ t.is(er, null, 'completeWork: on change event fired')
29
+ t.is(onChangeName, name, 'completeWork: on change emits the correct name')
30
+ t.done()
45
31
  }
46
- t.is(track.completed(), 0.5, "addWork: 50% completed")
32
+ })
47
33
 
34
+ test('add more work', function (t) {
35
+ testEvent(track, 'change', afterAddWork)
36
+ track.addWork(todo)
37
+ t.is(track.completed(), 0.5, 'addWork: 50% completed')
38
+ function afterAddWork (er, onChangeName) {
39
+ t.is(er, null, 'addWork: on change event fired')
40
+ t.is(onChangeName, name, 'addWork: on change emits the correct name')
41
+ t.done()
42
+ }
43
+ })
48
44
 
45
+ test('complete more work', function (t) {
49
46
  track.completeWork(200)
50
- t.is(track.completed(), 1, "completeWork: Over completion is still only 100% complete")
47
+ t.is(track.completed(), 1, 'completeWork: Over completion is still only 100% complete')
48
+ t.done()
49
+ })
51
50
 
52
- track = new Tracker(name, todo)
53
- track.completeWork(50)
54
- track.finish()
55
- t.is(track.completed(), 1, "finish: Explicitly finishing moves to 100%")
51
+ test('finish is always 100%', function (t) {
52
+ var finishtest = new Tracker(name, todo)
53
+ finishtest.completeWork(50)
54
+ finishtest.finish()
55
+ t.is(finishtest.completed(), 1, 'finish: Explicitly finishing moves to 100%')
56
+ t.done()
56
57
  })