fsevents 1.0.8 → 1.0.9

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.

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,114 +1,116 @@
1
- var test = require("tap").test
2
- , LRU = require("../")
1
+ var test = require('tap').test
2
+ var LRU = require('../')
3
3
 
4
- test("basic", function (t) {
4
+ test('basic', function (t) {
5
5
  var cache = new LRU({max: 10})
6
- cache.set("key", "value")
7
- t.equal(cache.get("key"), "value")
8
- t.equal(cache.get("nada"), undefined)
6
+ cache.set('key', 'value')
7
+ t.equal(cache.get('key'), 'value')
8
+ t.equal(cache.get('nada'), undefined)
9
9
  t.equal(cache.length, 1)
10
10
  t.equal(cache.max, 10)
11
11
  t.end()
12
12
  })
13
13
 
14
- test("least recently set", function (t) {
14
+ test('least recently set', function (t) {
15
15
  var cache = new LRU(2)
16
- cache.set("a", "A")
17
- cache.set("b", "B")
18
- cache.set("c", "C")
19
- t.equal(cache.get("c"), "C")
20
- t.equal(cache.get("b"), "B")
21
- t.equal(cache.get("a"), undefined)
16
+ cache.set('a', 'A')
17
+ cache.set('b', 'B')
18
+ cache.set('c', 'C')
19
+ t.equal(cache.get('c'), 'C')
20
+ t.equal(cache.get('b'), 'B')
21
+ t.equal(cache.get('a'), undefined)
22
22
  t.end()
23
23
  })
24
24
 
25
- test("lru recently gotten", function (t) {
25
+ test('lru recently gotten', function (t) {
26
26
  var cache = new LRU(2)
27
- cache.set("a", "A")
28
- cache.set("b", "B")
29
- cache.get("a")
30
- cache.set("c", "C")
31
- t.equal(cache.get("c"), "C")
32
- t.equal(cache.get("b"), undefined)
33
- t.equal(cache.get("a"), "A")
27
+ cache.set('a', 'A')
28
+ cache.set('b', 'B')
29
+ cache.get('a')
30
+ cache.set('c', 'C')
31
+ t.equal(cache.get('c'), 'C')
32
+ t.equal(cache.get('b'), undefined)
33
+ t.equal(cache.get('a'), 'A')
34
34
  t.end()
35
35
  })
36
36
 
37
- test("del", function (t) {
37
+ test('del', function (t) {
38
38
  var cache = new LRU(2)
39
- cache.set("a", "A")
40
- cache.del("a")
41
- t.equal(cache.get("a"), undefined)
39
+ cache.set('a', 'A')
40
+ cache.del('a')
41
+ t.equal(cache.get('a'), undefined)
42
42
  t.end()
43
43
  })
44
44
 
45
- test("max", function (t) {
45
+ test('max', function (t) {
46
46
  var cache = new LRU(3)
47
47
 
48
48
  // test changing the max, verify that the LRU items get dropped.
49
49
  cache.max = 100
50
- for (var i = 0; i < 100; i ++) cache.set(i, i)
50
+ var i
51
+ for (i = 0; i < 100; i++) cache.set(i, i)
51
52
  t.equal(cache.length, 100)
52
- for (var i = 0; i < 100; i ++) {
53
+ for (i = 0; i < 100; i++) {
53
54
  t.equal(cache.get(i), i)
54
55
  }
55
56
  cache.max = 3
56
57
  t.equal(cache.length, 3)
57
- for (var i = 0; i < 97; i ++) {
58
+ for (i = 0; i < 97; i++) {
58
59
  t.equal(cache.get(i), undefined)
59
60
  }
60
- for (var i = 98; i < 100; i ++) {
61
+ for (i = 98; i < 100; i++) {
61
62
  t.equal(cache.get(i), i)
62
63
  }
63
64
 
64
65
  // now remove the max restriction, and try again.
65
- cache.max = "hello"
66
- for (var i = 0; i < 100; i ++) cache.set(i, i)
66
+ cache.max = 'hello'
67
+ for (i = 0; i < 100; i++) cache.set(i, i)
67
68
  t.equal(cache.length, 100)
68
- for (var i = 0; i < 100; i ++) {
69
+ for (i = 0; i < 100; i++) {
69
70
  t.equal(cache.get(i), i)
70
71
  }
71
72
  // should trigger an immediate resize
72
73
  cache.max = 3
73
74
  t.equal(cache.length, 3)
74
- for (var i = 0; i < 97; i ++) {
75
+ for (i = 0; i < 97; i++) {
75
76
  t.equal(cache.get(i), undefined)
76
77
  }
77
- for (var i = 98; i < 100; i ++) {
78
+ for (i = 98; i < 100; i++) {
78
79
  t.equal(cache.get(i), i)
79
80
  }
80
81
  t.end()
81
82
  })
82
83
 
83
- test("reset", function (t) {
84
+ test('reset', function (t) {
84
85
  var cache = new LRU(10)
85
- cache.set("a", "A")
86
- cache.set("b", "B")
86
+ cache.set('a', 'A')
87
+ cache.set('b', 'B')
87
88
  cache.reset()
88
89
  t.equal(cache.length, 0)
89
90
  t.equal(cache.max, 10)
90
- t.equal(cache.get("a"), undefined)
91
- t.equal(cache.get("b"), undefined)
91
+ t.equal(cache.get('a'), undefined)
92
+ t.equal(cache.get('b'), undefined)
92
93
  t.end()
93
94
  })
94
95
 
95
-
96
- test("basic with weighed length", function (t) {
96
+ test('basic with weighed length', function (t) {
97
97
  var cache = new LRU({
98
98
  max: 100,
99
- length: function (item) { return item.size }
99
+ length: function (item, key) {
100
+ t.isa(key, 'string')
101
+ return item.size
102
+ }
100
103
  })
101
- cache.set("key", {val: "value", size: 50})
102
- t.equal(cache.get("key").val, "value")
103
- t.equal(cache.get("nada"), undefined)
104
- t.equal(cache.lengthCalculator(cache.get("key")), 50)
104
+ cache.set('key', {val: 'value', size: 50})
105
+ t.equal(cache.get('key').val, 'value')
106
+ t.equal(cache.get('nada'), undefined)
107
+ t.equal(cache.lengthCalculator(cache.get('key'), 'key'), 50)
105
108
  t.equal(cache.length, 50)
106
109
  t.equal(cache.max, 100)
107
110
  t.end()
108
111
  })
109
112
 
110
-
111
- test("weighed length item too large", function (t) {
113
+ test('weighed length item too large', function (t) {
112
114
  var cache = new LRU({
113
115
  max: 10,
114
116
  length: function (item) { return item.size }
@@ -116,146 +118,167 @@ test("weighed length item too large", function (t) {
116
118
  t.equal(cache.max, 10)
117
119
 
118
120
  // should fall out immediately
119
- cache.set("key", {val: "value", size: 50})
121
+ cache.set('key', {val: 'value', size: 50})
120
122
 
121
123
  t.equal(cache.length, 0)
122
- t.equal(cache.get("key"), undefined)
124
+ t.equal(cache.get('key'), undefined)
123
125
  t.end()
124
126
  })
125
127
 
126
- test("least recently set with weighed length", function (t) {
128
+ test('least recently set with weighed length', function (t) {
127
129
  var cache = new LRU({
128
- max:8,
130
+ max: 8,
129
131
  length: function (item) { return item.length }
130
132
  })
131
- cache.set("a", "A")
132
- cache.set("b", "BB")
133
- cache.set("c", "CCC")
134
- cache.set("d", "DDDD")
135
- t.equal(cache.get("d"), "DDDD")
136
- t.equal(cache.get("c"), "CCC")
137
- t.equal(cache.get("b"), undefined)
138
- t.equal(cache.get("a"), undefined)
133
+ cache.set('a', 'A')
134
+ cache.set('b', 'BB')
135
+ cache.set('c', 'CCC')
136
+ cache.set('d', 'DDDD')
137
+ t.equal(cache.get('d'), 'DDDD')
138
+ t.equal(cache.get('c'), 'CCC')
139
+ t.equal(cache.get('b'), undefined)
140
+ t.equal(cache.get('a'), undefined)
139
141
  t.end()
140
142
  })
141
143
 
142
- test("lru recently gotten with weighed length", function (t) {
144
+ test('lru recently gotten with weighed length', function (t) {
143
145
  var cache = new LRU({
144
146
  max: 8,
145
147
  length: function (item) { return item.length }
146
148
  })
147
- cache.set("a", "A")
148
- cache.set("b", "BB")
149
- cache.set("c", "CCC")
150
- cache.get("a")
151
- cache.get("b")
152
- cache.set("d", "DDDD")
153
- t.equal(cache.get("c"), undefined)
154
- t.equal(cache.get("d"), "DDDD")
155
- t.equal(cache.get("b"), "BB")
156
- t.equal(cache.get("a"), "A")
149
+ cache.set('a', 'A')
150
+ cache.set('b', 'BB')
151
+ cache.set('c', 'CCC')
152
+ cache.get('a')
153
+ cache.get('b')
154
+ cache.set('d', 'DDDD')
155
+ t.equal(cache.get('c'), undefined)
156
+ t.equal(cache.get('d'), 'DDDD')
157
+ t.equal(cache.get('b'), 'BB')
158
+ t.equal(cache.get('a'), 'A')
157
159
  t.end()
158
160
  })
159
161
 
160
- test("lru recently updated with weighed length", function (t) {
162
+ test('lru recently updated with weighed length', function (t) {
161
163
  var cache = new LRU({
162
164
  max: 8,
163
165
  length: function (item) { return item.length }
164
166
  })
165
- cache.set("a", "A")
166
- cache.set("b", "BB")
167
- cache.set("c", "CCC")
168
- t.equal(cache.length, 6) //CCC BB A
169
- cache.set("a", "+A")
170
- t.equal(cache.length, 7) //+A CCC BB
171
- cache.set("b", "++BB")
172
- t.equal(cache.length, 6) //++BB +A
173
- t.equal(cache.get("c"), undefined)
174
-
175
- cache.set("c", "oversized")
176
- t.equal(cache.length, 6) //++BB +A
177
- t.equal(cache.get("c"), undefined)
178
-
179
- cache.set("a", "oversized")
180
- t.equal(cache.length, 4) //++BB
181
- t.equal(cache.get("a"), undefined)
182
- t.equal(cache.get("b"), "++BB")
167
+ cache.set('a', 'A')
168
+ cache.set('b', 'BB')
169
+ cache.set('c', 'CCC')
170
+ t.equal(cache.length, 6) // CCC BB A
171
+ cache.set('a', '+A')
172
+ t.equal(cache.length, 7) // +A CCC BB
173
+ cache.set('b', '++BB')
174
+ t.equal(cache.length, 6) // ++BB +A
175
+ t.equal(cache.get('c'), undefined)
176
+
177
+ cache.set('c', 'oversized')
178
+ t.equal(cache.length, 6) // ++BB +A
179
+ t.equal(cache.get('c'), undefined)
180
+
181
+ cache.set('a', 'oversized')
182
+ t.equal(cache.length, 4) // ++BB
183
+ t.equal(cache.get('a'), undefined)
184
+ t.equal(cache.get('b'), '++BB')
183
185
  t.end()
184
186
  })
185
187
 
186
- test("set returns proper booleans", function(t) {
188
+ test('set returns proper booleans', function (t) {
187
189
  var cache = new LRU({
188
190
  max: 5,
189
191
  length: function (item) { return item.length }
190
192
  })
191
193
 
192
- t.equal(cache.set("a", "A"), true)
194
+ t.equal(cache.set('a', 'A'), true)
193
195
 
194
196
  // should return false for max exceeded
195
- t.equal(cache.set("b", "donuts"), false)
197
+ t.equal(cache.set('b', 'donuts'), false)
196
198
 
197
- t.equal(cache.set("b", "B"), true)
198
- t.equal(cache.set("c", "CCCC"), true)
199
+ t.equal(cache.set('b', 'B'), true)
200
+ t.equal(cache.set('c', 'CCCC'), true)
199
201
  t.end()
200
202
  })
201
203
 
202
- test("drop the old items", function(t) {
204
+ test('drop the old items', function (t) {
203
205
  var cache = new LRU({
204
206
  max: 5,
205
207
  maxAge: 50
206
208
  })
207
209
 
208
- cache.set("a", "A")
210
+ cache.set('a', 'A')
209
211
 
210
212
  setTimeout(function () {
211
- cache.set("b", "b")
212
- t.equal(cache.get("a"), "A")
213
+ cache.set('b', 'b')
214
+ t.equal(cache.get('a'), 'A')
213
215
  }, 25)
214
216
 
215
217
  setTimeout(function () {
216
- cache.set("c", "C")
218
+ cache.set('c', 'C')
217
219
  // timed out
218
- t.notOk(cache.get("a"))
220
+ t.notOk(cache.get('a'))
219
221
  }, 60 + 25)
220
222
 
221
223
  setTimeout(function () {
222
- t.notOk(cache.get("b"))
223
- t.equal(cache.get("c"), "C")
224
+ t.notOk(cache.get('b'))
225
+ t.equal(cache.get('c'), 'C')
224
226
  }, 90)
225
227
 
226
228
  setTimeout(function () {
227
- t.notOk(cache.get("c"))
229
+ t.notOk(cache.get('c'))
228
230
  t.end()
229
231
  }, 155)
230
232
  })
231
233
 
232
- test("individual item can have it's own maxAge", function(t) {
234
+ test('manual pruning', function (t) {
235
+ var cache = new LRU({
236
+ max: 5,
237
+ maxAge: 50
238
+ })
239
+
240
+ cache.set('a', 'A')
241
+ cache.set('b', 'b')
242
+ cache.set('c', 'C')
243
+
244
+ setTimeout(function () {
245
+ cache.prune()
246
+
247
+ t.notOk(cache.get('a'))
248
+ t.notOk(cache.get('b'))
249
+ t.notOk(cache.get('c'))
250
+
251
+ t.end()
252
+ }, 100)
253
+ })
254
+
255
+ test('individual item can have its own maxAge', function (t) {
233
256
  var cache = new LRU({
234
257
  max: 5,
235
258
  maxAge: 50
236
259
  })
237
260
 
238
- cache.set("a", "A", 20)
261
+ cache.set('a', 'A', 20)
239
262
  setTimeout(function () {
240
- t.notOk(cache.get("a"))
263
+ t.notOk(cache.get('a'))
241
264
  t.end()
242
265
  }, 25)
243
266
  })
244
267
 
245
- test("individual item can have it's own maxAge > cache's", function(t) {
268
+ test('individual item can have its own maxAge > cache', function (t) {
246
269
  var cache = new LRU({
247
270
  max: 5,
248
271
  maxAge: 20
249
272
  })
250
273
 
251
- cache.set("a", "A", 50)
274
+ cache.set('a', 'A', 50)
252
275
  setTimeout(function () {
253
- t.equal(cache.get("a"), "A")
276
+ t.equal(cache.get('a'), 'A')
254
277
  t.end()
255
278
  }, 25)
256
279
  })
257
280
 
258
- test("disposal function", function(t) {
281
+ test('disposal function', function (t) {
259
282
  var disposed = false
260
283
  var cache = new LRU({
261
284
  max: 1,
@@ -267,14 +290,16 @@ test("disposal function", function(t) {
267
290
  cache.set(1, 1)
268
291
  cache.set(2, 2)
269
292
  t.equal(disposed, 1)
270
- cache.set(3, 3)
293
+ cache.set(2, 10)
271
294
  t.equal(disposed, 2)
295
+ cache.set(3, 3)
296
+ t.equal(disposed, 10)
272
297
  cache.reset()
273
298
  t.equal(disposed, 3)
274
299
  t.end()
275
300
  })
276
301
 
277
- test("disposal function on too big of item", function(t) {
302
+ test('disposal function on too big of item', function (t) {
278
303
  var disposed = false
279
304
  var cache = new LRU({
280
305
  max: 1,
@@ -288,12 +313,12 @@ test("disposal function on too big of item", function(t) {
288
313
  var obj = [ 1, 2 ]
289
314
 
290
315
  t.equal(disposed, false)
291
- cache.set("obj", obj)
316
+ cache.set('obj', obj)
292
317
  t.equal(disposed, obj)
293
318
  t.end()
294
319
  })
295
320
 
296
- test("has()", function(t) {
321
+ test('has()', function (t) {
297
322
  var cache = new LRU({
298
323
  max: 1,
299
324
  maxAge: 10
@@ -304,22 +329,24 @@ test("has()", function(t) {
304
329
  cache.set('blu', 'baz')
305
330
  t.equal(cache.has('foo'), false)
306
331
  t.equal(cache.has('blu'), true)
307
- setTimeout(function() {
332
+ setTimeout(function () {
308
333
  t.equal(cache.has('blu'), false)
309
334
  t.end()
310
335
  }, 15)
311
336
  })
312
337
 
313
- test("stale", function(t) {
338
+ test('stale', function (t) {
314
339
  var cache = new LRU({
315
340
  maxAge: 10,
316
341
  stale: true
317
342
  })
318
343
 
344
+ t.equal(cache.allowStale, true)
345
+
319
346
  cache.set('foo', 'bar')
320
347
  t.equal(cache.get('foo'), 'bar')
321
348
  t.equal(cache.has('foo'), true)
322
- setTimeout(function() {
349
+ setTimeout(function () {
323
350
  t.equal(cache.has('foo'), false)
324
351
  t.equal(cache.get('foo'), 'bar')
325
352
  t.equal(cache.get('foo'), undefined)
@@ -327,14 +354,14 @@ test("stale", function(t) {
327
354
  }, 15)
328
355
  })
329
356
 
330
- test("lru update via set", function(t) {
331
- var cache = LRU({ max: 2 });
357
+ test('lru update via set', function (t) {
358
+ var cache = LRU({ max: 2 })
332
359
 
333
- cache.set('foo', 1);
334
- cache.set('bar', 2);
335
- cache.del('bar');
336
- cache.set('baz', 3);
337
- cache.set('qux', 4);
360
+ cache.set('foo', 1)
361
+ cache.set('bar', 2)
362
+ cache.del('bar')
363
+ cache.set('baz', 3)
364
+ cache.set('qux', 4)
338
365
 
339
366
  t.equal(cache.get('foo'), undefined)
340
367
  t.equal(cache.get('bar'), undefined)
@@ -343,47 +370,47 @@ test("lru update via set", function(t) {
343
370
  t.end()
344
371
  })
345
372
 
346
- test("least recently set w/ peek", function (t) {
373
+ test('least recently set w/ peek', function (t) {
347
374
  var cache = new LRU(2)
348
- cache.set("a", "A")
349
- cache.set("b", "B")
350
- t.equal(cache.peek("a"), "A")
351
- cache.set("c", "C")
352
- t.equal(cache.get("c"), "C")
353
- t.equal(cache.get("b"), "B")
354
- t.equal(cache.get("a"), undefined)
375
+ cache.set('a', 'A')
376
+ cache.set('b', 'B')
377
+ t.equal(cache.peek('a'), 'A')
378
+ cache.set('c', 'C')
379
+ t.equal(cache.get('c'), 'C')
380
+ t.equal(cache.get('b'), 'B')
381
+ t.equal(cache.get('a'), undefined)
355
382
  t.end()
356
383
  })
357
384
 
358
- test("pop the least used item", function (t) {
385
+ test('pop the least used item', function (t) {
359
386
  var cache = new LRU(3)
360
- , last
387
+ var last
361
388
 
362
- cache.set("a", "A")
363
- cache.set("b", "B")
364
- cache.set("c", "C")
389
+ cache.set('a', 'A')
390
+ cache.set('b', 'B')
391
+ cache.set('c', 'C')
365
392
 
366
393
  t.equal(cache.length, 3)
367
394
  t.equal(cache.max, 3)
368
395
 
369
396
  // Ensure we pop a, c, b
370
- cache.get("b", "B")
397
+ cache.get('b', 'B')
371
398
 
372
399
  last = cache.pop()
373
- t.equal(last.key, "a")
374
- t.equal(last.value, "A")
400
+ t.equal(last.key, 'a')
401
+ t.equal(last.value, 'A')
375
402
  t.equal(cache.length, 2)
376
403
  t.equal(cache.max, 3)
377
404
 
378
405
  last = cache.pop()
379
- t.equal(last.key, "c")
380
- t.equal(last.value, "C")
406
+ t.equal(last.key, 'c')
407
+ t.equal(last.value, 'C')
381
408
  t.equal(cache.length, 1)
382
409
  t.equal(cache.max, 3)
383
410
 
384
411
  last = cache.pop()
385
- t.equal(last.key, "b")
386
- t.equal(last.value, "B")
412
+ t.equal(last.key, 'b')
413
+ t.equal(last.value, 'B')
387
414
  t.equal(cache.length, 0)
388
415
  t.equal(cache.max, 3)
389
416
 
@@ -394,3 +421,100 @@ test("pop the least used item", function (t) {
394
421
 
395
422
  t.end()
396
423
  })
424
+
425
+ test('get and set only accepts strings and numbers as keys', function (t) {
426
+ var cache = new LRU()
427
+
428
+ cache.set('key', 'value')
429
+ cache.set(123, 456)
430
+
431
+ t.equal(cache.get('key'), 'value')
432
+ t.equal(cache.get(123), 456)
433
+
434
+ t.end()
435
+ })
436
+
437
+ test('peek with wierd keys', function (t) {
438
+ var cache = new LRU()
439
+
440
+ cache.set('key', 'value')
441
+ cache.set(123, 456)
442
+
443
+ t.equal(cache.peek('key'), 'value')
444
+ t.equal(cache.peek(123), 456)
445
+
446
+ t.equal(cache.peek({
447
+ toString: function () { return 'key' }
448
+ }), undefined)
449
+
450
+ t.end()
451
+ })
452
+
453
+ test('invalid length calc results in basic length', function (t) {
454
+ var l = new LRU({ length: true })
455
+ t.isa(l.lengthCalculator, 'function')
456
+ l.lengthCalculator = 'not a function'
457
+ t.isa(l.lengthCalculator, 'function')
458
+ t.end()
459
+ })
460
+
461
+ test('change length calculator recalculates', function (t) {
462
+ var l = new LRU({ max: 3 })
463
+ l.set(2, 2)
464
+ l.set(1, 1)
465
+ l.lengthCalculator = function (key, val) {
466
+ return key + val
467
+ }
468
+ t.equal(l.itemCount, 1)
469
+ t.equal(l.get(2), undefined)
470
+ t.equal(l.get(1), 1)
471
+ l.set(0, 1)
472
+ t.equal(l.itemCount, 2)
473
+ l.lengthCalculator = function (key, val) {
474
+ return key
475
+ }
476
+ t.equal(l.lengthCalculator(1, 10), 1)
477
+ t.equal(l.lengthCalculator(10, 1), 10)
478
+ l.lengthCalculator = { not: 'a function' }
479
+ t.equal(l.lengthCalculator(1, 10), 1)
480
+ t.equal(l.lengthCalculator(10, 1), 1)
481
+ t.end()
482
+ })
483
+
484
+ test('delete non-existent item has no effect', function (t) {
485
+ var l = new LRU({ max: 2 })
486
+ l.set('foo', 1)
487
+ l.set('bar', 2)
488
+ l.del('baz')
489
+ t.same(l.dumpLru().toArray().map(function (hit) {
490
+ return hit.key
491
+ }), [ 'bar', 'foo' ])
492
+ t.end()
493
+ })
494
+
495
+ test('maxAge on list, cleared in forEach', function (t) {
496
+ var l = new LRU({ stale: true })
497
+ l.set('foo', 1)
498
+
499
+ // hacky. make it seem older.
500
+ l.dumpLru().head.value.now = Date.now() - 100000
501
+
502
+ // setting maxAge to invalid values does nothing.
503
+ t.equal(l.maxAge, 0)
504
+ l.maxAge = -100
505
+ t.equal(l.maxAge, 0)
506
+ l.maxAge = {}
507
+ t.equal(l.maxAge, 0)
508
+
509
+ l.maxAge = 1
510
+
511
+ var saw = false
512
+ l.forEach(function (val, key) {
513
+ saw = true
514
+ t.equal(key, 'foo')
515
+ })
516
+ t.ok(saw)
517
+ t.equal(l.length, 0)
518
+
519
+ t.end()
520
+ })