fsevents 1.0.0 → 1.0.1

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 (149) hide show
  1. package/node_modules/node-pre-gyp/CHANGELOG.md +9 -0
  2. package/node_modules/node-pre-gyp/lib/util/abi_crosswalk.json +32 -0
  3. package/node_modules/node-pre-gyp/node_modules/mkdirp/node_modules/minimist/package.json +2 -1
  4. package/node_modules/node-pre-gyp/node_modules/nopt/README.md +8 -7
  5. package/node_modules/node-pre-gyp/node_modules/nopt/package.json +16 -12
  6. package/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/core-util-is/package.json +1 -1
  7. package/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/inherits/package.json +1 -1
  8. package/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/package.json +1 -1
  9. package/node_modules/node-pre-gyp/node_modules/rc/lib/utils.js +2 -2
  10. package/node_modules/node-pre-gyp/node_modules/rc/node_modules/minimist/index.js +14 -2
  11. package/node_modules/node-pre-gyp/node_modules/rc/node_modules/minimist/package.json +10 -9
  12. package/node_modules/node-pre-gyp/node_modules/rc/node_modules/minimist/test/bool.js +23 -0
  13. package/node_modules/node-pre-gyp/node_modules/rc/node_modules/minimist/test/kv_short.js +16 -0
  14. package/node_modules/node-pre-gyp/node_modules/rc/package.json +9 -8
  15. package/node_modules/node-pre-gyp/node_modules/request/.travis.yml +1 -0
  16. package/node_modules/node-pre-gyp/node_modules/request/CHANGELOG.md +22 -2
  17. package/node_modules/node-pre-gyp/node_modules/request/README.md +42 -10
  18. package/node_modules/node-pre-gyp/node_modules/request/index.js +4 -0
  19. package/node_modules/node-pre-gyp/node_modules/request/node_modules/aws-sign2/package.json +1 -1
  20. package/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/core-util-is/package.json +1 -1
  21. package/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/inherits/package.json +1 -1
  22. package/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/process-nextick-args/index.js +1 -1
  23. package/node_modules/node-pre-gyp/node_modules/request/node_modules/{form-data/node_modules/async/LICENSE → bl/node_modules/readable-stream/node_modules/process-nextick-args/license.md} +6 -6
  24. package/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/process-nextick-args/package.json +10 -9
  25. package/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/process-nextick-args/test.js +7 -0
  26. package/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/package.json +2 -1
  27. package/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/package.json +2 -1
  28. package/node_modules/node-pre-gyp/node_modules/request/node_modules/caseless/package.json +2 -1
  29. package/node_modules/node-pre-gyp/node_modules/request/node_modules/extend/package.json +2 -1
  30. package/node_modules/node-pre-gyp/node_modules/request/node_modules/forever-agent/package.json +1 -1
  31. package/node_modules/node-pre-gyp/node_modules/request/node_modules/form-data/Readme.md +44 -9
  32. package/node_modules/node-pre-gyp/node_modules/request/node_modules/form-data/lib/form_data.js +48 -25
  33. package/node_modules/node-pre-gyp/node_modules/request/node_modules/form-data/node_modules/async/lib/async.js +13 -7
  34. package/node_modules/node-pre-gyp/node_modules/request/node_modules/form-data/node_modules/async/package.json +26 -11
  35. package/node_modules/node-pre-gyp/node_modules/request/node_modules/form-data/package.json +29 -20
  36. package/node_modules/node-pre-gyp/node_modules/request/node_modules/har-validator/node_modules/bluebird/README.md +4 -1
  37. package/node_modules/node-pre-gyp/node_modules/request/node_modules/har-validator/node_modules/bluebird/js/browser/bluebird.js +35 -11
  38. package/node_modules/node-pre-gyp/node_modules/request/node_modules/har-validator/node_modules/bluebird/js/browser/bluebird.min.js +5 -5
  39. package/node_modules/node-pre-gyp/node_modules/request/node_modules/har-validator/node_modules/bluebird/js/main/debuggability.js +2 -0
  40. package/node_modules/node-pre-gyp/node_modules/request/node_modules/har-validator/node_modules/bluebird/js/main/direct_resolve.js +2 -0
  41. package/node_modules/node-pre-gyp/node_modules/request/node_modules/har-validator/node_modules/bluebird/js/main/promise.js +5 -1
  42. package/node_modules/node-pre-gyp/node_modules/request/node_modules/har-validator/node_modules/bluebird/js/main/promisify.js +10 -5
  43. package/node_modules/node-pre-gyp/node_modules/request/node_modules/har-validator/node_modules/bluebird/js/main/using.js +14 -3
  44. package/node_modules/node-pre-gyp/node_modules/request/node_modules/har-validator/node_modules/bluebird/package.json +9 -8
  45. package/node_modules/node-pre-gyp/node_modules/request/node_modules/har-validator/node_modules/chalk/index.js +2 -2
  46. package/node_modules/node-pre-gyp/node_modules/request/node_modules/har-validator/node_modules/chalk/node_modules/escape-string-regexp/package.json +1 -1
  47. package/node_modules/node-pre-gyp/node_modules/request/node_modules/har-validator/node_modules/chalk/package.json +22 -15
  48. package/node_modules/node-pre-gyp/node_modules/request/node_modules/har-validator/node_modules/chalk/readme.md +3 -2
  49. package/node_modules/node-pre-gyp/node_modules/request/node_modules/har-validator/node_modules/commander/package.json +1 -1
  50. package/node_modules/node-pre-gyp/node_modules/request/node_modules/har-validator/node_modules/is-my-json-valid/README.md +1 -1
  51. package/node_modules/node-pre-gyp/node_modules/request/node_modules/har-validator/node_modules/is-my-json-valid/node_modules/generate-function/package.json +1 -1
  52. package/node_modules/node-pre-gyp/node_modules/request/node_modules/har-validator/node_modules/is-my-json-valid/node_modules/generate-object-property/package.json +1 -1
  53. package/node_modules/node-pre-gyp/node_modules/request/node_modules/har-validator/node_modules/is-my-json-valid/node_modules/jsonpointer/.travis.yml +6 -2
  54. package/node_modules/node-pre-gyp/node_modules/request/node_modules/har-validator/node_modules/is-my-json-valid/node_modules/jsonpointer/README.md +3 -2
  55. package/node_modules/node-pre-gyp/node_modules/request/node_modules/har-validator/node_modules/is-my-json-valid/node_modules/jsonpointer/jsonpointer.js +7 -10
  56. package/node_modules/node-pre-gyp/node_modules/request/node_modules/har-validator/node_modules/is-my-json-valid/node_modules/jsonpointer/package.json +24 -20
  57. package/node_modules/node-pre-gyp/node_modules/request/node_modules/har-validator/node_modules/is-my-json-valid/node_modules/jsonpointer/test.js +11 -13
  58. package/node_modules/node-pre-gyp/node_modules/request/node_modules/har-validator/node_modules/is-my-json-valid/package.json +11 -10
  59. package/node_modules/node-pre-gyp/node_modules/request/node_modules/hawk/node_modules/boom/.travis.yml +3 -2
  60. package/node_modules/node-pre-gyp/node_modules/request/node_modules/hawk/node_modules/boom/lib/index.js +39 -28
  61. package/node_modules/node-pre-gyp/node_modules/request/node_modules/hawk/node_modules/boom/package.json +11 -12
  62. package/node_modules/node-pre-gyp/node_modules/request/node_modules/hawk/node_modules/boom/test/index.js +1 -1
  63. package/node_modules/node-pre-gyp/node_modules/request/node_modules/hawk/node_modules/cryptiles/.npmignore +18 -18
  64. package/node_modules/node-pre-gyp/node_modules/request/node_modules/hawk/node_modules/cryptiles/.travis.yml +8 -5
  65. package/node_modules/node-pre-gyp/node_modules/request/node_modules/hawk/node_modules/cryptiles/README.md +2 -0
  66. package/node_modules/node-pre-gyp/node_modules/request/node_modules/hawk/node_modules/cryptiles/package.json +24 -28
  67. package/node_modules/node-pre-gyp/node_modules/request/node_modules/hawk/node_modules/cryptiles/test/index.js +57 -63
  68. package/node_modules/node-pre-gyp/node_modules/request/node_modules/hawk/node_modules/hoek/.travis.yml +2 -2
  69. package/node_modules/node-pre-gyp/node_modules/request/node_modules/hawk/node_modules/hoek/LICENSE +0 -0
  70. package/node_modules/node-pre-gyp/node_modules/request/node_modules/hawk/node_modules/hoek/README.md +16 -6
  71. package/node_modules/node-pre-gyp/node_modules/request/node_modules/hawk/node_modules/hoek/images/hoek.png +0 -0
  72. package/node_modules/node-pre-gyp/node_modules/request/node_modules/hawk/node_modules/hoek/lib/escape.js +0 -0
  73. package/node_modules/node-pre-gyp/node_modules/request/node_modules/hawk/node_modules/hoek/lib/index.js +24 -8
  74. package/node_modules/node-pre-gyp/node_modules/request/node_modules/hawk/node_modules/hoek/package.json +13 -13
  75. package/node_modules/node-pre-gyp/node_modules/request/node_modules/hawk/node_modules/hoek/test/escaper.js +0 -0
  76. package/node_modules/node-pre-gyp/node_modules/request/node_modules/hawk/node_modules/hoek/test/index.js +866 -778
  77. package/node_modules/node-pre-gyp/node_modules/request/node_modules/hawk/node_modules/hoek/test/modules/test1.js +0 -0
  78. package/node_modules/node-pre-gyp/node_modules/request/node_modules/hawk/node_modules/hoek/test/modules/test2.js +0 -0
  79. package/node_modules/node-pre-gyp/node_modules/request/node_modules/hawk/node_modules/hoek/test/modules/test3.js +0 -0
  80. package/node_modules/node-pre-gyp/node_modules/request/node_modules/hawk/node_modules/sntp/package.json +1 -1
  81. package/node_modules/node-pre-gyp/node_modules/request/node_modules/hawk/package.json +2 -1
  82. package/node_modules/node-pre-gyp/node_modules/request/node_modules/http-signature/node_modules/assert-plus/package.json +1 -1
  83. package/node_modules/node-pre-gyp/node_modules/request/node_modules/http-signature/node_modules/ctype/package.json +1 -1
  84. package/node_modules/node-pre-gyp/node_modules/request/node_modules/isstream/package.json +1 -1
  85. package/node_modules/node-pre-gyp/node_modules/request/node_modules/mime-types/HISTORY.md +24 -0
  86. package/node_modules/node-pre-gyp/node_modules/request/node_modules/mime-types/index.js +1 -1
  87. package/node_modules/node-pre-gyp/node_modules/request/node_modules/mime-types/node_modules/mime-db/HISTORY.md +33 -0
  88. package/node_modules/node-pre-gyp/node_modules/request/node_modules/mime-types/node_modules/mime-db/db.json +50 -0
  89. package/node_modules/node-pre-gyp/node_modules/request/node_modules/mime-types/node_modules/mime-db/package.json +12 -13
  90. package/node_modules/node-pre-gyp/node_modules/request/node_modules/mime-types/package.json +9 -10
  91. package/node_modules/node-pre-gyp/node_modules/request/node_modules/node-uuid/package.json +1 -1
  92. package/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/.npmignore +0 -1
  93. package/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/.travis.yml +3 -2
  94. package/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/CHANGELOG.md +13 -2
  95. package/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/README.md +11 -4
  96. package/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/bower.json +1 -1
  97. package/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/component.json +15 -0
  98. package/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/dist/qs.js +523 -0
  99. package/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/lib/parse.js +3 -2
  100. package/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/lib/stringify.js +28 -7
  101. package/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/package.json +20 -18
  102. package/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/test/parse.js +14 -14
  103. package/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/test/stringify.js +23 -1
  104. package/node_modules/node-pre-gyp/node_modules/request/node_modules/stringstream/package.json +1 -1
  105. package/node_modules/node-pre-gyp/node_modules/request/package.json +12 -12
  106. package/node_modules/node-pre-gyp/node_modules/request/request.js +51 -30
  107. package/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/inherits/package.json +1 -1
  108. package/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/package.json +3 -2
  109. package/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/package.json +2 -1
  110. package/node_modules/node-pre-gyp/node_modules/rimraf/package.json +9 -8
  111. package/node_modules/node-pre-gyp/node_modules/rimraf/rimraf.js +1 -1
  112. package/node_modules/node-pre-gyp/node_modules/semver/package.json +10 -12
  113. package/node_modules/node-pre-gyp/node_modules/semver/semver.js +1 -0
  114. package/node_modules/node-pre-gyp/node_modules/semver/test/index.js +21 -8
  115. package/node_modules/node-pre-gyp/node_modules/tar/lib/entry.js +7 -0
  116. package/node_modules/node-pre-gyp/node_modules/tar/lib/parse.js +5 -1
  117. package/node_modules/node-pre-gyp/node_modules/tar/node_modules/fstream/node_modules/graceful-fs/fs.js +21 -11
  118. package/node_modules/node-pre-gyp/node_modules/tar/node_modules/fstream/node_modules/graceful-fs/graceful-fs.js +208 -115
  119. package/node_modules/node-pre-gyp/node_modules/tar/node_modules/fstream/node_modules/graceful-fs/legacy-streams.js +118 -0
  120. package/node_modules/node-pre-gyp/node_modules/tar/node_modules/fstream/node_modules/graceful-fs/package.json +18 -17
  121. package/node_modules/node-pre-gyp/node_modules/tar/node_modules/fstream/node_modules/graceful-fs/polyfills.js +130 -133
  122. package/node_modules/node-pre-gyp/node_modules/tar/node_modules/fstream/package.json +18 -14
  123. package/node_modules/node-pre-gyp/node_modules/tar/node_modules/inherits/package.json +1 -1
  124. package/node_modules/node-pre-gyp/node_modules/tar/package.json +22 -15
  125. package/node_modules/node-pre-gyp/node_modules/tar/test/parse-discard.js +29 -0
  126. package/node_modules/node-pre-gyp/node_modules/tar-pack/node_modules/fstream-ignore/node_modules/inherits/package.json +1 -1
  127. package/node_modules/node-pre-gyp/node_modules/tar-pack/node_modules/fstream-ignore/node_modules/minimatch/node_modules/lru-cache/README.md +12 -2
  128. package/node_modules/node-pre-gyp/node_modules/tar-pack/node_modules/fstream-ignore/node_modules/minimatch/node_modules/lru-cache/lib/lru-cache.js +48 -4
  129. package/node_modules/node-pre-gyp/node_modules/tar-pack/node_modules/fstream-ignore/node_modules/minimatch/node_modules/lru-cache/package.json +9 -9
  130. package/node_modules/node-pre-gyp/node_modules/tar-pack/node_modules/fstream-ignore/node_modules/minimatch/node_modules/lru-cache/test/basic.js +26 -25
  131. package/node_modules/node-pre-gyp/node_modules/tar-pack/node_modules/fstream-ignore/node_modules/minimatch/node_modules/lru-cache/test/serialize.js +216 -0
  132. package/node_modules/node-pre-gyp/node_modules/tar-pack/node_modules/readable-stream/node_modules/core-util-is/package.json +1 -1
  133. package/node_modules/node-pre-gyp/node_modules/tar-pack/node_modules/readable-stream/package.json +1 -1
  134. package/node_modules/node-pre-gyp/package.json +10 -10
  135. package/package.json +2 -2
  136. package/node_modules/node-pre-gyp/node_modules/request/node_modules/form-data/node_modules/async/.jscsrc +0 -3
  137. package/node_modules/node-pre-gyp/node_modules/request/node_modules/form-data/node_modules/async/CHANGELOG.md +0 -81
  138. package/node_modules/node-pre-gyp/node_modules/request/node_modules/form-data/node_modules/async/README.md +0 -1789
  139. package/node_modules/node-pre-gyp/node_modules/request/node_modules/form-data/node_modules/async/support/sync-package-managers.js +0 -53
  140. package/node_modules/node-pre-gyp/node_modules/request/node_modules/hawk/node_modules/cryptiles/Makefile +0 -9
  141. package/node_modules/node-pre-gyp/node_modules/request/node_modules/hawk/node_modules/cryptiles/index.js +0 -1
  142. package/node_modules/node-pre-gyp/node_modules/request/node_modules/hawk/node_modules/hoek/Makefile +0 -8
  143. package/node_modules/node-pre-gyp/node_modules/request/node_modules/hawk/node_modules/hoek/index.js +0 -1
  144. package/node_modules/node-pre-gyp/node_modules/tar/node_modules/fstream/node_modules/graceful-fs/.npmignore +0 -1
  145. package/node_modules/node-pre-gyp/node_modules/tar/node_modules/fstream/node_modules/graceful-fs/LICENSE +0 -15
  146. package/node_modules/node-pre-gyp/node_modules/tar/node_modules/fstream/node_modules/graceful-fs/test/max-open.js +0 -69
  147. package/node_modules/node-pre-gyp/node_modules/tar/node_modules/fstream/node_modules/graceful-fs/test/open.js +0 -39
  148. package/node_modules/node-pre-gyp/node_modules/tar/node_modules/fstream/node_modules/graceful-fs/test/readdir-sort.js +0 -20
  149. package/node_modules/node-pre-gyp/node_modules/tar/node_modules/fstream/node_modules/graceful-fs/test/write-then-read.js +0 -47
@@ -20,70 +20,70 @@ var it = lab.test;
20
20
  var expect = Code.expect;
21
21
 
22
22
 
23
- var nestedObj = {
23
+ var nestedObj = {
24
24
  v: [7, 8, 9],
25
25
  w: /^something$/igm,
26
- x: {
26
+ x: {
27
27
  a: [1, 2, 3],
28
28
  b: 123456,
29
29
  c: new Date(),
30
30
  d: /hi/igm,
31
- e: /hello/
31
+ e: /hello/
32
32
  },
33
33
  y: 'y',
34
- z: new Date(1378775452757)
34
+ z: new Date(1378775452757)
35
35
  };
36
36
 
37
37
  var dupsArray = [nestedObj, { z: 'z' }, nestedObj];
38
38
  var reducedDupsArray = [nestedObj, { z: 'z' }];
39
39
 
40
- describe('clone()', function () {
40
+ describe('clone()', function () {
41
41
 
42
- it('clones a nested object', function (done) {
42
+ it('clones a nested object', function (done) {
43
43
 
44
44
  var a = nestedObj;
45
45
  var b = Hoek.clone(a);
46
46
 
47
47
  expect(a).to.deep.equal(b);
48
48
  expect(a.z.getTime()).to.equal(b.z.getTime());
49
- done();
49
+ done();
50
50
  });
51
51
 
52
- it('clones a null object', function (done) {
52
+ it('clones a null object', function (done) {
53
53
 
54
54
  var b = Hoek.clone(null);
55
55
 
56
56
  expect(b).to.equal(null);
57
- done();
57
+ done();
58
58
  });
59
59
 
60
- it('should not convert undefined properties to null', function (done) {
60
+ it('should not convert undefined properties to null', function (done) {
61
61
 
62
62
  var obj = { something: undefined };
63
63
  var b = Hoek.clone(obj);
64
64
 
65
65
  expect(typeof b.something).to.equal('undefined');
66
- done();
66
+ done();
67
67
  });
68
68
 
69
- it('should not throw on circular reference', function (done) {
69
+ it('should not throw on circular reference', function (done) {
70
70
 
71
71
  var a = {};
72
72
  a.x = a;
73
73
 
74
- var test = function () {
74
+ var test = function () {
75
75
 
76
- var b = Hoek.clone(a);
76
+ var b = Hoek.clone(a);
77
77
  };
78
78
 
79
79
  expect(test).to.not.throw();
80
- done();
80
+ done();
81
81
  });
82
82
 
83
- it('clones circular reference', function (done) {
83
+ it('clones circular reference', function (done) {
84
84
 
85
- var x = {
86
- 'z': new Date()
85
+ var x = {
86
+ 'z': new Date()
87
87
  };
88
88
  x.y = x;
89
89
 
@@ -94,50 +94,50 @@ describe('clone()', function () {
94
94
  expect(b.y.z).to.not.equal(x.y.z);
95
95
  expect(b.y).to.equal(b);
96
96
  expect(b.y.y.y.y).to.equal(b);
97
- done();
97
+ done();
98
98
  });
99
99
 
100
- it('clones an object with a null prototype', function (done) {
100
+ it('clones an object with a null prototype', function (done) {
101
101
 
102
102
  var obj = Object.create(null);
103
103
  var b = Hoek.clone(obj);
104
104
 
105
105
  expect(b).to.deep.equal(obj);
106
- done();
106
+ done();
107
107
  });
108
108
 
109
- it('clones deeply nested object', function (done) {
109
+ it('clones deeply nested object', function (done) {
110
110
 
111
- var a = {
112
- x: {
113
- y: {
111
+ var a = {
112
+ x: {
113
+ y: {
114
114
  a: [1, 2, 3],
115
115
  b: 123456,
116
116
  c: new Date(),
117
117
  d: /hi/igm,
118
- e: /hello/
119
- }
120
- }
118
+ e: /hello/
119
+ }
120
+ }
121
121
  };
122
122
 
123
123
  var b = Hoek.clone(a);
124
124
 
125
125
  expect(a).to.deep.equal(b);
126
126
  expect(a.x.y.c.getTime()).to.equal(b.x.y.c.getTime());
127
- done();
127
+ done();
128
128
  });
129
129
 
130
- it('clones arrays', function (done) {
130
+ it('clones arrays', function (done) {
131
131
 
132
132
  var a = [1, 2, 3];
133
133
 
134
134
  var b = Hoek.clone(a);
135
135
 
136
136
  expect(a).to.deep.equal(b);
137
- done();
137
+ done();
138
138
  });
139
139
 
140
- it('performs actual copy for shallow keys (no pass by reference)', function (done) {
140
+ it('performs actual copy for shallow keys (no pass by reference)', function (done) {
141
141
 
142
142
  var x = Hoek.clone(nestedObj);
143
143
  var y = Hoek.clone(nestedObj);
@@ -159,10 +159,10 @@ describe('clone()', function () {
159
159
  expect(x.y).to.not.equal(nestedObj.y);
160
160
  expect(x.y).to.not.equal(y.y);
161
161
 
162
- done();
162
+ done();
163
163
  });
164
164
 
165
- it('performs actual copy for deep keys (no pass by reference)', function (done) {
165
+ it('performs actual copy for deep keys (no pass by reference)', function (done) {
166
166
 
167
167
  var x = Hoek.clone(nestedObj);
168
168
  var y = Hoek.clone(nestedObj);
@@ -172,22 +172,22 @@ describe('clone()', function () {
172
172
 
173
173
  expect(x.x.c.getTime()).to.equal(nestedObj.x.c.getTime());
174
174
  expect(x.x.c.getTime()).to.equal(y.x.c.getTime());
175
- done();
175
+ done();
176
176
  });
177
177
 
178
- it('copies functions with properties', function (done) {
178
+ it('copies functions with properties', function (done) {
179
+
180
+ var a = {
181
+ x: function () {
179
182
 
180
- var a = {
181
- x: function () {
182
-
183
- return 1;
183
+ return 1;
184
184
  },
185
- y: {}
185
+ y: {}
186
186
  };
187
187
  a.x.z = 'string in function';
188
- a.x.v = function () {
189
-
190
- return 2;
188
+ a.x.v = function () {
189
+
190
+ return 2;
191
191
  };
192
192
  a.y.u = a.x;
193
193
 
@@ -196,14 +196,14 @@ describe('clone()', function () {
196
196
  expect(b.x.v()).to.equal(2);
197
197
  expect(b.y.u).to.equal(b.x);
198
198
  expect(b.x.z).to.equal('string in function');
199
- done();
199
+ done();
200
200
  });
201
201
 
202
202
  it('should copy a buffer', function (done) {
203
203
 
204
204
  var tls = {
205
205
  key: new Buffer([1, 2, 3, 4, 5]),
206
- cert: new Buffer([1, 2, 3, 4, 5, 6, 10])
206
+ cert: new Buffer([1, 2, 3, 4, 5, 6, 10])
207
207
  };
208
208
 
209
209
  var copiedTls = Hoek.clone(tls);
@@ -211,14 +211,14 @@ describe('clone()', function () {
211
211
  expect(JSON.stringify(copiedTls.key)).to.equal(JSON.stringify(tls.key));
212
212
  expect(Buffer.isBuffer(copiedTls.cert)).to.equal(true);
213
213
  expect(JSON.stringify(copiedTls.cert)).to.equal(JSON.stringify(tls.cert));
214
- done();
214
+ done();
215
215
  });
216
216
 
217
- it('clones an object with a prototype', function (done) {
217
+ it('clones an object with a prototype', function (done) {
218
218
 
219
- var Obj = function () {
219
+ var Obj = function () {
220
220
 
221
- this.a = 5;
221
+ this.a = 5;
222
222
  };
223
223
 
224
224
  Obj.prototype.b = function () {
@@ -232,38 +232,38 @@ describe('clone()', function () {
232
232
  expect(b.a).to.equal(5);
233
233
  expect(b.b()).to.equal('c');
234
234
  expect(a).to.deep.equal(b);
235
- done();
235
+ done();
236
236
  });
237
237
 
238
- it('reuses cloned Date object', function (done) {
238
+ it('reuses cloned Date object', function (done) {
239
239
 
240
- var obj = {
241
- a: new Date()
240
+ var obj = {
241
+ a: new Date()
242
242
  };
243
243
 
244
244
  obj.b = obj.a;
245
245
 
246
246
  var copy = Hoek.clone(obj);
247
247
  expect(copy.a).to.equal(copy.b);
248
- done();
248
+ done();
249
249
  });
250
250
 
251
- it('shallow copies an object with a prototype and isImmutable flag', function (done) {
251
+ it('shallow copies an object with a prototype and isImmutable flag', function (done) {
252
252
 
253
- var Obj = function () {
253
+ var Obj = function () {
254
254
 
255
- this.value = 5;
255
+ this.value = 5;
256
256
  };
257
257
 
258
- Obj.prototype.b = function () {
259
-
260
- return 'c';
258
+ Obj.prototype.b = function () {
259
+
260
+ return 'c';
261
261
  };
262
262
 
263
263
  Obj.prototype.isImmutable = true;
264
264
 
265
- var obj = {
266
- a: new Obj()
265
+ var obj = {
266
+ a: new Obj()
267
267
  };
268
268
 
269
269
  var copy = Hoek.clone(obj);
@@ -272,117 +272,132 @@ describe('clone()', function () {
272
272
  expect(copy.a.value).to.equal(5);
273
273
  expect(copy.a.b()).to.equal('c');
274
274
  expect(obj.a).to.equal(copy.a);
275
- done();
275
+ done();
276
276
  });
277
277
 
278
- it('clones an object with property getter without executing it', function (done) {
278
+ it('clones an object with property getter without executing it', function (done) {
279
279
 
280
280
  var obj = {};
281
281
  var value = 1;
282
282
  var execCount = 0;
283
283
 
284
- Object.defineProperty(obj, 'test', {
284
+ Object.defineProperty(obj, 'test', {
285
285
  enumerable: true,
286
286
  configurable: true,
287
- get: function () {
287
+ get: function () {
288
288
 
289
289
  ++execCount;
290
- return value;
291
- }
290
+ return value;
291
+ }
292
292
  });
293
293
 
294
294
  var copy = Hoek.clone(obj);
295
295
  expect(execCount).to.equal(0);
296
296
  expect(copy.test).to.equal(1);
297
297
  expect(execCount).to.equal(1);
298
- done();
298
+ done();
299
299
  });
300
300
 
301
- it('clones an object with property getter and setter', function (done) {
301
+ it('clones an object with property getter and setter', function (done) {
302
302
 
303
- var obj = {
304
- _test: 0
303
+ var obj = {
304
+ _test: 0
305
305
  };
306
306
 
307
- Object.defineProperty(obj, 'test', {
307
+ Object.defineProperty(obj, 'test', {
308
308
  enumerable: true,
309
309
  configurable: true,
310
- get: function () {
310
+ get: function () {
311
311
 
312
- return this._test;
312
+ return this._test;
313
313
  },
314
- set: function (value) {
314
+ set: function (value) {
315
315
 
316
- this._test = value - 1;
317
- }
316
+ this._test = value - 1;
317
+ }
318
318
  });
319
319
 
320
320
  var copy = Hoek.clone(obj);
321
321
  expect(copy.test).to.equal(0);
322
322
  copy.test = 5;
323
323
  expect(copy.test).to.equal(4);
324
- done();
324
+ done();
325
325
  });
326
326
 
327
- it('clones an object with only property setter', function (done) {
327
+ it('clones an object with only property setter', function (done) {
328
328
 
329
- var obj = {
330
- _test: 0
329
+ var obj = {
330
+ _test: 0
331
331
  };
332
332
 
333
- Object.defineProperty(obj, 'test', {
333
+ Object.defineProperty(obj, 'test', {
334
334
  enumerable: true,
335
335
  configurable: true,
336
- set: function (value) {
336
+ set: function (value) {
337
337
 
338
- this._test = value - 1;
339
- }
338
+ this._test = value - 1;
339
+ }
340
340
  });
341
341
 
342
342
  var copy = Hoek.clone(obj);
343
343
  expect(copy._test).to.equal(0);
344
344
  copy.test = 5;
345
345
  expect(copy._test).to.equal(4);
346
- done();
346
+ done();
347
347
  });
348
348
 
349
- it('clones an object with non-enumerable properties', function (done) {
349
+ it('clones an object with non-enumerable properties', function (done) {
350
350
 
351
- var obj = {
352
- _test: 0
351
+ var obj = {
352
+ _test: 0
353
353
  };
354
354
 
355
- Object.defineProperty(obj, 'test', {
355
+ Object.defineProperty(obj, 'test', {
356
356
  enumerable: false,
357
357
  configurable: true,
358
- set: function (value) {
358
+ set: function (value) {
359
359
 
360
- this._test = value - 1;
361
- }
360
+ this._test = value - 1;
361
+ }
362
362
  });
363
363
 
364
364
  var copy = Hoek.clone(obj);
365
365
  expect(copy._test).to.equal(0);
366
366
  copy.test = 5;
367
367
  expect(copy._test).to.equal(4);
368
- done();
369
- });
368
+ done();
369
+ });
370
+
371
+ it('clones an object where getOwnPropertyDescriptor returns undefined', function (done) {
372
+
373
+ var oldGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
374
+ var obj = { a: 'b' };
375
+ Object.getOwnPropertyDescriptor = function () {
376
+
377
+ return undefined;
378
+ };
379
+
380
+ var copy = Hoek.clone(obj);
381
+ Object.getOwnPropertyDescriptor = oldGetOwnPropertyDescriptor;
382
+ expect(copy).to.deep.equal(obj);
383
+ done();
384
+ });
370
385
  });
371
386
 
372
- describe('merge()', function () {
387
+ describe('merge()', function () {
373
388
 
374
- it('deep copies source items', function (done) {
389
+ it('deep copies source items', function (done) {
375
390
 
376
- var target = {
391
+ var target = {
377
392
  b: 3,
378
- d: []
393
+ d: []
379
394
  };
380
395
 
381
- var source = {
382
- c: {
383
- d: 1
396
+ var source = {
397
+ c: {
398
+ d: 1
384
399
  },
385
- d: [{ e: 1 }]
400
+ d: [{ e: 1 }]
386
401
  };
387
402
 
388
403
  Hoek.merge(target, source);
@@ -391,123 +406,123 @@ describe('merge()', function () {
391
406
  expect(target.d).to.not.equal(source.d);
392
407
  expect(target.d[0]).to.not.equal(source.d[0]);
393
408
  expect(target.d).to.deep.equal(source.d);
394
- done();
409
+ done();
395
410
  });
396
411
 
397
- it('merges array over an object', function (done) {
412
+ it('merges array over an object', function (done) {
398
413
 
399
- var a = {
400
- x: ['n', 'm']
414
+ var a = {
415
+ x: ['n', 'm']
401
416
  };
402
417
 
403
- var b = {
404
- x: {
418
+ var b = {
419
+ x: {
405
420
  n: '1',
406
- m: '2'
407
- }
421
+ m: '2'
422
+ }
408
423
  };
409
424
 
410
425
  Hoek.merge(b, a);
411
426
  expect(a.x[0]).to.equal('n');
412
427
  expect(a.x.n).to.not.exist();
413
- done();
428
+ done();
414
429
  });
415
430
 
416
- it('merges object over an array', function (done) {
431
+ it('merges object over an array', function (done) {
417
432
 
418
- var a = {
419
- x: ['n', 'm']
433
+ var a = {
434
+ x: ['n', 'm']
420
435
  };
421
436
 
422
- var b = {
423
- x: {
437
+ var b = {
438
+ x: {
424
439
  n: '1',
425
- m: '2'
426
- }
440
+ m: '2'
441
+ }
427
442
  };
428
443
 
429
444
  Hoek.merge(a, b);
430
445
  expect(a.x.n).to.equal('1');
431
446
  expect(a.x[0]).to.not.exist();
432
- done();
447
+ done();
433
448
  });
434
449
 
435
- it('does not throw if source is null', function (done) {
450
+ it('does not throw if source is null', function (done) {
436
451
 
437
452
  var a = {};
438
453
  var b = null;
439
454
  var c = null;
440
455
 
441
- expect(function () {
456
+ expect(function () {
442
457
 
443
- c = Hoek.merge(a, b);
458
+ c = Hoek.merge(a, b);
444
459
  }).to.not.throw();
445
460
 
446
461
  expect(c).to.equal(a);
447
- done();
462
+ done();
448
463
  });
449
464
 
450
- it('does not throw if source is undefined', function (done) {
465
+ it('does not throw if source is undefined', function (done) {
451
466
 
452
467
  var a = {};
453
468
  var b;
454
469
  var c = null;
455
470
 
456
- expect(function () {
471
+ expect(function () {
457
472
 
458
- c = Hoek.merge(a, b);
473
+ c = Hoek.merge(a, b);
459
474
  }).to.not.throw();
460
475
 
461
476
  expect(c).to.equal(a);
462
- done();
477
+ done();
463
478
  });
464
479
 
465
- it('throws if source is not an object', function (done) {
480
+ it('throws if source is not an object', function (done) {
466
481
 
467
- expect(function () {
482
+ expect(function () {
468
483
 
469
484
  var a = {};
470
485
  var b = 0;
471
486
 
472
- Hoek.merge(a, b);
487
+ Hoek.merge(a, b);
473
488
  }).to.throw('Invalid source value: must be null, undefined, or an object');
474
- done();
489
+ done();
475
490
  });
476
491
 
477
- it('throws if target is not an object', function (done) {
492
+ it('throws if target is not an object', function (done) {
478
493
 
479
- expect(function () {
494
+ expect(function () {
480
495
 
481
496
  var a = 0;
482
497
  var b = {};
483
498
 
484
- Hoek.merge(a, b);
499
+ Hoek.merge(a, b);
485
500
  }).to.throw('Invalid target value: must be an object');
486
- done();
501
+ done();
487
502
  });
488
503
 
489
- it('throws if target is not an array and source is', function (done) {
504
+ it('throws if target is not an array and source is', function (done) {
490
505
 
491
- expect(function () {
506
+ expect(function () {
492
507
 
493
508
  var a = {};
494
509
  var b = [1, 2];
495
510
 
496
- Hoek.merge(a, b);
511
+ Hoek.merge(a, b);
497
512
  }).to.throw('Cannot merge array onto an object');
498
- done();
513
+ done();
499
514
  });
500
515
 
501
- it('returns the same object when merging arrays', function (done) {
516
+ it('returns the same object when merging arrays', function (done) {
502
517
 
503
518
  var a = [];
504
519
  var b = [1, 2];
505
520
 
506
521
  expect(Hoek.merge(a, b)).to.equal(a);
507
- done();
522
+ done();
508
523
  });
509
524
 
510
- it('combines an empty object with a non-empty object', function (done) {
525
+ it('combines an empty object with a non-empty object', function (done) {
511
526
 
512
527
  var a = {};
513
528
  var b = nestedObj;
@@ -515,10 +530,10 @@ describe('merge()', function () {
515
530
  var c = Hoek.merge(a, b);
516
531
  expect(a).to.deep.equal(b);
517
532
  expect(c).to.deep.equal(b);
518
- done();
533
+ done();
519
534
  });
520
535
 
521
- it('overrides values in target', function (done) {
536
+ it('overrides values in target', function (done) {
522
537
 
523
538
  var a = { x: 1, y: 2, z: 3, v: 5, t: 'test', m: 'abc' };
524
539
  var b = { x: null, z: 4, v: 0, t: { u: 6 }, m: '123' };
@@ -530,10 +545,10 @@ describe('merge()', function () {
530
545
  expect(c.v).to.equal(0);
531
546
  expect(c.m).to.equal('123');
532
547
  expect(c.t).to.deep.equal({ u: 6 });
533
- done();
548
+ done();
534
549
  });
535
550
 
536
- it('overrides values in target (flip)', function (done) {
551
+ it('overrides values in target (flip)', function (done) {
537
552
 
538
553
  var a = { x: 1, y: 2, z: 3, v: 5, t: 'test', m: 'abc' };
539
554
  var b = { x: null, z: 4, v: 0, t: { u: 6 }, m: '123' };
@@ -545,98 +560,98 @@ describe('merge()', function () {
545
560
  expect(d.v).to.equal(5);
546
561
  expect(d.m).to.equal('abc');
547
562
  expect(d.t).to.deep.equal('test');
548
- done();
563
+ done();
549
564
  });
550
565
 
551
- it('retains Date properties', function (done) {
566
+ it('retains Date properties', function (done) {
552
567
 
553
568
  var a = { x: new Date(1378776452757) };
554
569
 
555
570
  var b = Hoek.merge({}, a);
556
571
  expect(a.x.getTime()).to.equal(b.x.getTime());
557
- done();
572
+ done();
558
573
  });
559
574
 
560
- it('retains Date properties when merging keys', function (done) {
575
+ it('retains Date properties when merging keys', function (done) {
561
576
 
562
577
  var a = { x: new Date(1378776452757) };
563
578
 
564
579
  var b = Hoek.merge({ x: {} }, a);
565
580
  expect(a.x.getTime()).to.equal(b.x.getTime());
566
- done();
581
+ done();
567
582
  });
568
583
 
569
- it('overrides Buffer', function (done) {
584
+ it('overrides Buffer', function (done) {
570
585
 
571
586
  var a = { x: new Buffer('abc') };
572
587
 
573
588
  var b = Hoek.merge({ x: {} }, a);
574
589
  expect(a.x.toString()).to.equal('abc');
575
- done();
576
- });
590
+ done();
591
+ });
577
592
  });
578
593
 
579
- describe('applyToDefaults()', function () {
594
+ describe('applyToDefaults()', function () {
580
595
 
581
- var defaults = {
596
+ var defaults = {
582
597
  a: 1,
583
598
  b: 2,
584
- c: {
599
+ c: {
585
600
  d: 3,
586
- e: [5, 6]
601
+ e: [5, 6]
587
602
  },
588
603
  f: 6,
589
- g: 'test'
604
+ g: 'test'
590
605
  };
591
606
 
592
- it('throws when target is null', function (done) {
607
+ it('throws when target is null', function (done) {
593
608
 
594
- expect(function () {
609
+ expect(function () {
595
610
 
596
- Hoek.applyToDefaults(null, {});
611
+ Hoek.applyToDefaults(null, {});
597
612
  }).to.throw('Invalid defaults value: must be an object');
598
- done();
613
+ done();
599
614
  });
600
615
 
601
- it('returns null if options is false', function (done) {
616
+ it('returns null if options is false', function (done) {
602
617
 
603
618
  var result = Hoek.applyToDefaults(defaults, false);
604
619
  expect(result).to.equal(null);
605
- done();
620
+ done();
606
621
  });
607
622
 
608
- it('returns null if options is null', function (done) {
623
+ it('returns null if options is null', function (done) {
609
624
 
610
625
  var result = Hoek.applyToDefaults(defaults, null);
611
626
  expect(result).to.equal(null);
612
- done();
627
+ done();
613
628
  });
614
629
 
615
- it('returns null if options is undefined', function (done) {
630
+ it('returns null if options is undefined', function (done) {
616
631
 
617
632
  var result = Hoek.applyToDefaults(defaults, undefined);
618
633
  expect(result).to.equal(null);
619
- done();
634
+ done();
620
635
  });
621
636
 
622
- it('returns a copy of defaults if options is true', function (done) {
637
+ it('returns a copy of defaults if options is true', function (done) {
623
638
 
624
639
  var result = Hoek.applyToDefaults(defaults, true);
625
640
  expect(result).to.deep.equal(defaults);
626
- done();
641
+ done();
627
642
  });
628
643
 
629
- it('applies object to defaults', function (done) {
644
+ it('applies object to defaults', function (done) {
630
645
 
631
- var obj = {
646
+ var obj = {
632
647
  a: null,
633
- c: {
634
- e: [4]
648
+ c: {
649
+ e: [4]
635
650
  },
636
651
  f: 0,
637
- g: {
638
- h: 5
639
- }
652
+ g: {
653
+ h: 5
654
+ }
640
655
  };
641
656
 
642
657
  var result = Hoek.applyToDefaults(defaults, obj);
@@ -645,20 +660,20 @@ describe('applyToDefaults()', function () {
645
660
  expect(result.b).to.equal(2);
646
661
  expect(result.f).to.equal(0);
647
662
  expect(result.g).to.deep.equal({ h: 5 });
648
- done();
663
+ done();
649
664
  });
650
665
 
651
- it('applies object to defaults with null', function (done) {
666
+ it('applies object to defaults with null', function (done) {
652
667
 
653
- var obj = {
668
+ var obj = {
654
669
  a: null,
655
- c: {
656
- e: [4]
670
+ c: {
671
+ e: [4]
657
672
  },
658
673
  f: 0,
659
- g: {
660
- h: 5
661
- }
674
+ g: {
675
+ h: 5
676
+ }
662
677
  };
663
678
 
664
679
  var result = Hoek.applyToDefaults(defaults, obj, true);
@@ -667,21 +682,21 @@ describe('applyToDefaults()', function () {
667
682
  expect(result.b).to.equal(2);
668
683
  expect(result.f).to.equal(0);
669
684
  expect(result.g).to.deep.equal({ h: 5 });
670
- done();
671
- });
685
+ done();
686
+ });
672
687
  });
673
688
 
674
- describe('cloneWithShallow()', function () {
689
+ describe('cloneWithShallow()', function () {
675
690
 
676
- it('deep clones except for listed keys', function (done) {
691
+ it('deep clones except for listed keys', function (done) {
677
692
 
678
- var source = {
679
- a: {
680
- b: 5
693
+ var source = {
694
+ a: {
695
+ b: 5
681
696
  },
682
- c: {
683
- d: 6
684
- }
697
+ c: {
698
+ d: 6
699
+ }
685
700
  };
686
701
 
687
702
  var copy = Hoek.cloneWithShallow(source, ['c']);
@@ -689,36 +704,36 @@ describe('cloneWithShallow()', function () {
689
704
  expect(copy).to.not.equal(source);
690
705
  expect(copy.a).to.not.equal(source.a);
691
706
  expect(copy.b).to.equal(source.b);
692
- done();
707
+ done();
693
708
  });
694
709
 
695
- it('returns immutable value', function (done) {
710
+ it('returns immutable value', function (done) {
696
711
 
697
712
  expect(Hoek.cloneWithShallow(5)).to.equal(5);
698
- done();
713
+ done();
699
714
  });
700
715
 
701
- it('returns null value', function (done) {
716
+ it('returns null value', function (done) {
702
717
 
703
718
  expect(Hoek.cloneWithShallow(null)).to.equal(null);
704
- done();
719
+ done();
705
720
  });
706
721
 
707
- it('returns undefined value', function (done) {
722
+ it('returns undefined value', function (done) {
708
723
 
709
724
  expect(Hoek.cloneWithShallow(undefined)).to.equal(undefined);
710
- done();
725
+ done();
711
726
  });
712
727
 
713
- it('deep clones except for listed keys (including missing keys)', function (done) {
728
+ it('deep clones except for listed keys (including missing keys)', function (done) {
714
729
 
715
- var source = {
716
- a: {
717
- b: 5
730
+ var source = {
731
+ a: {
732
+ b: 5
718
733
  },
719
- c: {
720
- d: 6
721
- }
734
+ c: {
735
+ d: 6
736
+ }
722
737
  };
723
738
 
724
739
  var copy = Hoek.cloneWithShallow(source, ['c', 'v']);
@@ -726,33 +741,33 @@ describe('cloneWithShallow()', function () {
726
741
  expect(copy).to.not.equal(source);
727
742
  expect(copy.a).to.not.equal(source.a);
728
743
  expect(copy.b).to.equal(source.b);
729
- done();
730
- });
744
+ done();
745
+ });
731
746
  });
732
747
 
733
- describe('applyToDefaultsWithShallow()', function () {
748
+ describe('applyToDefaultsWithShallow()', function () {
734
749
 
735
- it('shallow copies the listed keys from options without merging', function (done) {
750
+ it('shallow copies the listed keys from options without merging', function (done) {
736
751
 
737
- var defaults = {
738
- a: {
752
+ var defaults = {
753
+ a: {
739
754
  b: 5,
740
- e: 3
755
+ e: 3
741
756
  },
742
- c: {
757
+ c: {
743
758
  d: 7,
744
- g: 1
745
- }
759
+ g: 1
760
+ }
746
761
  };
747
762
 
748
- var options = {
749
- a: {
750
- b: 4
763
+ var options = {
764
+ a: {
765
+ b: 4
751
766
  },
752
- c: {
767
+ c: {
753
768
  d: 6,
754
- f: 7
755
- }
769
+ f: 7
770
+ }
756
771
  };
757
772
 
758
773
  var merged = Hoek.applyToDefaultsWithShallow(defaults, options, ['a']);
@@ -761,235 +776,235 @@ describe('applyToDefaultsWithShallow()', function () {
761
776
  expect(merged.a).to.not.equal(defaults.a);
762
777
  expect(merged.c).to.not.equal(options.c);
763
778
  expect(merged.c).to.not.equal(defaults.c);
764
- done();
779
+ done();
765
780
  });
766
781
 
767
- it('shallow copies the nested keys (override)', function (done) {
782
+ it('shallow copies the nested keys (override)', function (done) {
768
783
 
769
- var defaults = {
770
- a: {
771
- b: 5
784
+ var defaults = {
785
+ a: {
786
+ b: 5
772
787
  },
773
- c: {
788
+ c: {
774
789
  d: 7,
775
- g: 1
776
- }
790
+ g: 1
791
+ }
777
792
  };
778
793
 
779
- var options = {
780
- a: {
781
- b: 4
794
+ var options = {
795
+ a: {
796
+ b: 4
782
797
  },
783
- c: {
798
+ c: {
784
799
  d: 6,
785
- g: {
786
- h: 8
787
- }
788
- }
800
+ g: {
801
+ h: 8
802
+ }
803
+ }
789
804
  };
790
805
 
791
806
  var merged = Hoek.applyToDefaultsWithShallow(defaults, options, ['c.g']);
792
807
  expect(merged).to.deep.equal({ a: { b: 4 }, c: { d: 6, g: { h: 8 } } });
793
808
  expect(merged.c.g).to.equal(options.c.g);
794
- done();
809
+ done();
795
810
  });
796
811
 
797
- it('shallow copies the nested keys (missing)', function (done) {
812
+ it('shallow copies the nested keys (missing)', function (done) {
798
813
 
799
- var defaults = {
800
- a: {
801
- b: 5
802
- }
814
+ var defaults = {
815
+ a: {
816
+ b: 5
817
+ }
803
818
  };
804
819
 
805
- var options = {
806
- a: {
807
- b: 4
820
+ var options = {
821
+ a: {
822
+ b: 4
808
823
  },
809
- c: {
810
- g: {
811
- h: 8
812
- }
813
- }
824
+ c: {
825
+ g: {
826
+ h: 8
827
+ }
828
+ }
814
829
  };
815
830
 
816
831
  var merged = Hoek.applyToDefaultsWithShallow(defaults, options, ['c.g']);
817
832
  expect(merged).to.deep.equal({ a: { b: 4 }, c: { g: { h: 8 } } });
818
833
  expect(merged.c.g).to.equal(options.c.g);
819
- done();
834
+ done();
820
835
  });
821
836
 
822
- it('shallow copies the nested keys (override)', function (done) {
837
+ it('shallow copies the nested keys (override)', function (done) {
823
838
 
824
- var defaults = {
825
- a: {
826
- b: 5
839
+ var defaults = {
840
+ a: {
841
+ b: 5
827
842
  },
828
- c: {
829
- g: {
830
- d: 7
831
- }
832
- }
843
+ c: {
844
+ g: {
845
+ d: 7
846
+ }
847
+ }
833
848
  };
834
849
 
835
- var options = {
836
- a: {
837
- b: 4
850
+ var options = {
851
+ a: {
852
+ b: 4
838
853
  },
839
- c: {
840
- g: {
841
- h: 8
842
- }
843
- }
854
+ c: {
855
+ g: {
856
+ h: 8
857
+ }
858
+ }
844
859
  };
845
860
 
846
861
  var merged = Hoek.applyToDefaultsWithShallow(defaults, options, ['c.g']);
847
862
  expect(merged).to.deep.equal({ a: { b: 4 }, c: { g: { h: 8 } } });
848
863
  expect(merged.c.g).to.equal(options.c.g);
849
- done();
864
+ done();
850
865
  });
851
866
 
852
- it('shallow copies the nested keys (deeper)', function (done) {
867
+ it('shallow copies the nested keys (deeper)', function (done) {
853
868
 
854
- var defaults = {
855
- a: {
856
- b: 5
857
- }
869
+ var defaults = {
870
+ a: {
871
+ b: 5
872
+ }
858
873
  };
859
874
 
860
- var options = {
861
- a: {
862
- b: 4
875
+ var options = {
876
+ a: {
877
+ b: 4
863
878
  },
864
- c: {
865
- g: {
866
- r: {
867
- h: 8
868
- }
869
- }
870
- }
879
+ c: {
880
+ g: {
881
+ r: {
882
+ h: 8
883
+ }
884
+ }
885
+ }
871
886
  };
872
887
 
873
888
  var merged = Hoek.applyToDefaultsWithShallow(defaults, options, ['c.g.r']);
874
889
  expect(merged).to.deep.equal({ a: { b: 4 }, c: { g: { r: { h: 8 } } } });
875
890
  expect(merged.c.g.r).to.equal(options.c.g.r);
876
- done();
891
+ done();
877
892
  });
878
893
 
879
- it('shallow copies the nested keys (not present)', function (done) {
894
+ it('shallow copies the nested keys (not present)', function (done) {
880
895
 
881
- var defaults = {
882
- a: {
883
- b: 5
884
- }
896
+ var defaults = {
897
+ a: {
898
+ b: 5
899
+ }
885
900
  };
886
901
 
887
- var options = {
888
- a: {
889
- b: 4
902
+ var options = {
903
+ a: {
904
+ b: 4
890
905
  },
891
- c: {
892
- g: {
893
- r: {
894
- h: 8
895
- }
896
- }
897
- }
906
+ c: {
907
+ g: {
908
+ r: {
909
+ h: 8
910
+ }
911
+ }
912
+ }
898
913
  };
899
914
 
900
915
  var merged = Hoek.applyToDefaultsWithShallow(defaults, options, ['x.y']);
901
916
  expect(merged).to.deep.equal({ a: { b: 4 }, c: { g: { r: { h: 8 } } } });
902
- done();
917
+ done();
903
918
  });
904
919
 
905
- it('shallow copies the listed keys in the defaults', function (done) {
920
+ it('shallow copies the listed keys in the defaults', function (done) {
906
921
 
907
- var defaults = {
908
- a: {
909
- b: 1
910
- }
922
+ var defaults = {
923
+ a: {
924
+ b: 1
925
+ }
911
926
  };
912
927
 
913
928
  var merged = Hoek.applyToDefaultsWithShallow(defaults, {}, ['a']);
914
929
  expect(merged.a).to.equal(defaults.a);
915
- done();
930
+ done();
916
931
  });
917
932
 
918
- it('shallow copies the listed keys in the defaults (true)', function (done) {
933
+ it('shallow copies the listed keys in the defaults (true)', function (done) {
919
934
 
920
- var defaults = {
921
- a: {
922
- b: 1
923
- }
935
+ var defaults = {
936
+ a: {
937
+ b: 1
938
+ }
924
939
  };
925
940
 
926
941
  var merged = Hoek.applyToDefaultsWithShallow(defaults, true, ['a']);
927
942
  expect(merged.a).to.equal(defaults.a);
928
- done();
943
+ done();
929
944
  });
930
945
 
931
- it('returns null on false', function (done) {
946
+ it('returns null on false', function (done) {
932
947
 
933
- var defaults = {
934
- a: {
935
- b: 1
936
- }
948
+ var defaults = {
949
+ a: {
950
+ b: 1
951
+ }
937
952
  };
938
953
 
939
954
  var merged = Hoek.applyToDefaultsWithShallow(defaults, false, ['a']);
940
955
  expect(merged).to.equal(null);
941
- done();
956
+ done();
942
957
  });
943
958
 
944
- it('throws on missing defaults', function (done) {
959
+ it('throws on missing defaults', function (done) {
945
960
 
946
- expect(function () {
961
+ expect(function () {
947
962
 
948
- Hoek.applyToDefaultsWithShallow(null, {}, ['a']);
963
+ Hoek.applyToDefaultsWithShallow(null, {}, ['a']);
949
964
  }).to.throw('Invalid defaults value: must be an object');
950
- done();
965
+ done();
951
966
  });
952
967
 
953
- it('throws on invalid defaults', function (done) {
968
+ it('throws on invalid defaults', function (done) {
954
969
 
955
- expect(function () {
970
+ expect(function () {
956
971
 
957
- Hoek.applyToDefaultsWithShallow('abc', {}, ['a']);
972
+ Hoek.applyToDefaultsWithShallow('abc', {}, ['a']);
958
973
  }).to.throw('Invalid defaults value: must be an object');
959
- done();
974
+ done();
960
975
  });
961
976
 
962
- it('throws on invalid options', function (done) {
977
+ it('throws on invalid options', function (done) {
963
978
 
964
- expect(function () {
979
+ expect(function () {
965
980
 
966
- Hoek.applyToDefaultsWithShallow({}, 'abc', ['a']);
981
+ Hoek.applyToDefaultsWithShallow({}, 'abc', ['a']);
967
982
  }).to.throw('Invalid options value: must be true, falsy or an object');
968
- done();
983
+ done();
969
984
  });
970
985
 
971
- it('throws on missing keys', function (done) {
986
+ it('throws on missing keys', function (done) {
972
987
 
973
- expect(function () {
988
+ expect(function () {
974
989
 
975
- Hoek.applyToDefaultsWithShallow({}, true);
990
+ Hoek.applyToDefaultsWithShallow({}, true);
976
991
  }).to.throw('Invalid keys');
977
- done();
992
+ done();
978
993
  });
979
994
 
980
- it('throws on invalid keys', function (done) {
995
+ it('throws on invalid keys', function (done) {
981
996
 
982
- expect(function () {
997
+ expect(function () {
983
998
 
984
- Hoek.applyToDefaultsWithShallow({}, true, 'a');
999
+ Hoek.applyToDefaultsWithShallow({}, true, 'a');
985
1000
  }).to.throw('Invalid keys');
986
- done();
987
- });
1001
+ done();
1002
+ });
988
1003
  });
989
1004
 
990
- describe('deepEqual()', function () {
1005
+ describe('deepEqual()', function () {
991
1006
 
992
- it('compares simple values', function (done) {
1007
+ it('compares simple values', function (done) {
993
1008
 
994
1009
  expect(Hoek.deepEqual('x', 'x')).to.be.true();
995
1010
  expect(Hoek.deepEqual('x', 'y')).to.be.false();
@@ -1003,10 +1018,10 @@ describe('deepEqual()', function () {
1003
1018
  expect(Hoek.deepEqual(-1, 1)).to.be.false();
1004
1019
  expect(Hoek.deepEqual(NaN, 0)).to.be.false();
1005
1020
  expect(Hoek.deepEqual(NaN, NaN)).to.be.true();
1006
- done();
1021
+ done();
1007
1022
  });
1008
1023
 
1009
- it('compares different types', function (done) {
1024
+ it('compares different types', function (done) {
1010
1025
 
1011
1026
  expect(Hoek.deepEqual([], 5)).to.be.false();
1012
1027
  expect(Hoek.deepEqual(5, [])).to.be.false();
@@ -1014,116 +1029,116 @@ describe('deepEqual()', function () {
1014
1029
  expect(Hoek.deepEqual(null, {})).to.be.false();
1015
1030
  expect(Hoek.deepEqual('abc', {})).to.be.false();
1016
1031
  expect(Hoek.deepEqual({}, 'abc')).to.be.false();
1017
- done();
1032
+ done();
1018
1033
  });
1019
1034
 
1020
- it('compares empty structures', function (done) {
1035
+ it('compares empty structures', function (done) {
1021
1036
 
1022
1037
  expect(Hoek.deepEqual([], [])).to.be.true();
1023
1038
  expect(Hoek.deepEqual({}, {})).to.be.true();
1024
1039
  expect(Hoek.deepEqual([], {})).to.be.false();
1025
- done();
1040
+ done();
1026
1041
  });
1027
1042
 
1028
- it('compares empty arguments object', function (done) {
1043
+ it('compares empty arguments object', function (done) {
1029
1044
 
1030
- var compare = function () {
1045
+ var compare = function () {
1031
1046
 
1032
- expect(Hoek.deepEqual([], arguments)).to.be.false();
1047
+ expect(Hoek.deepEqual([], arguments)).to.be.false();
1033
1048
  };
1034
1049
 
1035
1050
  compare();
1036
- done();
1051
+ done();
1037
1052
  });
1038
1053
 
1039
- it('compares empty arguments objects', function (done) {
1054
+ it('compares empty arguments objects', function (done) {
1040
1055
 
1041
- var compare = function () {
1056
+ var compare = function () {
1042
1057
 
1043
1058
  var arg1 = arguments;
1044
1059
 
1045
- var inner = function () {
1060
+ var inner = function () {
1046
1061
 
1047
1062
  expect(Hoek.deepEqual(arg1, arguments)).to.be.false(); // callee is not the same
1048
1063
  };
1049
1064
 
1050
- inner();
1065
+ inner();
1051
1066
  };
1052
1067
 
1053
1068
  compare();
1054
- done();
1069
+ done();
1055
1070
  });
1056
1071
 
1057
- it('compares dates', function (done) {
1072
+ it('compares dates', function (done) {
1058
1073
 
1059
1074
  expect(Hoek.deepEqual(new Date(2015, 1, 1), new Date(2015, 1, 1))).to.be.true();
1060
1075
  expect(Hoek.deepEqual(new Date(100), new Date(101))).to.be.false();
1061
1076
  expect(Hoek.deepEqual(new Date(), {})).to.be.false();
1062
- done();
1077
+ done();
1063
1078
  });
1064
1079
 
1065
- it('compares regular expressions', function (done) {
1080
+ it('compares regular expressions', function (done) {
1066
1081
 
1067
1082
  expect(Hoek.deepEqual(/\s/, new RegExp('\\\s'))).to.be.true();
1068
1083
  expect(Hoek.deepEqual(/\s/g, /\s/g)).to.be.true();
1069
1084
  expect(Hoek.deepEqual(/a/, {})).to.be.false();
1070
1085
  expect(Hoek.deepEqual(/\s/g, /\s/i)).to.be.false();
1071
1086
  expect(Hoek.deepEqual(/a/g, /b/g)).to.be.false();
1072
- done();
1087
+ done();
1073
1088
  });
1074
1089
 
1075
- it('compares arrays', function (done) {
1090
+ it('compares arrays', function (done) {
1076
1091
 
1077
1092
  expect(Hoek.deepEqual([[1]], [[1]])).to.be.true();
1078
1093
  expect(Hoek.deepEqual([1, 2, 3], [1, 2, 3])).to.be.true();
1079
1094
  expect(Hoek.deepEqual([1, 2, 3], [1, 3, 2])).to.be.false();
1080
1095
  expect(Hoek.deepEqual([1, 2, 3], [1, 2])).to.be.false();
1081
1096
  expect(Hoek.deepEqual([1], [1])).to.be.true();
1082
- done();
1097
+ done();
1083
1098
  });
1084
1099
 
1085
- it('compares buffers', function (done) {
1100
+ it('compares buffers', function (done) {
1086
1101
 
1087
1102
  expect(Hoek.deepEqual(new Buffer([1, 2, 3]), new Buffer([1, 2, 3]))).to.be.true();
1088
1103
  expect(Hoek.deepEqual(new Buffer([1, 2, 3]), new Buffer([1, 3, 2]))).to.be.false();
1089
1104
  expect(Hoek.deepEqual(new Buffer([1, 2, 3]), new Buffer([1, 2]))).to.be.false();
1090
1105
  expect(Hoek.deepEqual(new Buffer([1, 2, 3]), {})).to.be.false();
1091
1106
  expect(Hoek.deepEqual(new Buffer([1, 2, 3]), [1, 2, 3])).to.be.false();
1092
- done();
1107
+ done();
1093
1108
  });
1094
1109
 
1095
- it('compares objects', function (done) {
1110
+ it('compares objects', function (done) {
1096
1111
 
1097
1112
  expect(Hoek.deepEqual({ a: 1, b: 2, c: 3 }, { a: 1, b: 2, c: 3 })).to.be.true();
1098
1113
  expect(Hoek.deepEqual({ foo: 'bar' }, { foo: 'baz' })).to.be.false();
1099
1114
  expect(Hoek.deepEqual({ foo: { bar: 'foo' } }, { foo: { bar: 'baz' } })).to.be.false();
1100
- done();
1115
+ done();
1101
1116
  });
1102
1117
 
1103
- it('handles circular dependency', function (done) {
1118
+ it('handles circular dependency', function (done) {
1104
1119
 
1105
1120
  var a = {};
1106
1121
  a.x = a;
1107
1122
 
1108
1123
  var b = Hoek.clone(a);
1109
1124
  expect(Hoek.deepEqual(a, b)).to.be.true();
1110
- done();
1125
+ done();
1111
1126
  });
1112
1127
 
1113
- it('compares an object with property getter without executing it', function (done) {
1128
+ it('compares an object with property getter without executing it', function (done) {
1114
1129
 
1115
1130
  var obj = {};
1116
1131
  var value = 1;
1117
1132
  var execCount = 0;
1118
1133
 
1119
- Object.defineProperty(obj, 'test', {
1134
+ Object.defineProperty(obj, 'test', {
1120
1135
  enumerable: true,
1121
1136
  configurable: true,
1122
- get: function () {
1137
+ get: function () {
1123
1138
 
1124
1139
  ++execCount;
1125
- return value;
1126
- }
1140
+ return value;
1141
+ }
1127
1142
  });
1128
1143
 
1129
1144
  var copy = Hoek.clone(obj);
@@ -1131,13 +1146,13 @@ describe('deepEqual()', function () {
1131
1146
  expect(execCount).to.equal(0);
1132
1147
  expect(copy.test).to.equal(1);
1133
1148
  expect(execCount).to.equal(1);
1134
- done();
1149
+ done();
1135
1150
  });
1136
1151
 
1137
- it('compares objects with property getters', function (done) {
1152
+ it('compares objects with property getters', function (done) {
1138
1153
 
1139
1154
  var obj = {};
1140
- Object.defineProperty(obj, 'test', {
1155
+ Object.defineProperty(obj, 'test', {
1141
1156
  enumerable: true,
1142
1157
  configurable: true,
1143
1158
  get: function () {
@@ -1147,7 +1162,7 @@ describe('deepEqual()', function () {
1147
1162
  });
1148
1163
 
1149
1164
  var ref = {};
1150
- Object.defineProperty(ref, 'test', {
1165
+ Object.defineProperty(ref, 'test', {
1151
1166
  enumerable: true,
1152
1167
  configurable: true,
1153
1168
  get: function () {
@@ -1157,14 +1172,14 @@ describe('deepEqual()', function () {
1157
1172
  });
1158
1173
 
1159
1174
  expect(Hoek.deepEqual(obj, ref)).to.be.false();
1160
- done();
1175
+ done();
1161
1176
  });
1162
1177
 
1163
- it('compares object prototypes', function (done) {
1178
+ it('compares object prototypes', function (done) {
1164
1179
 
1165
- var Obj = function () {
1180
+ var Obj = function () {
1166
1181
 
1167
- this.a = 5;
1182
+ this.a = 5;
1168
1183
  };
1169
1184
 
1170
1185
  Obj.prototype.b = function () {
@@ -1172,9 +1187,9 @@ describe('deepEqual()', function () {
1172
1187
  return this.a;
1173
1188
  };
1174
1189
 
1175
- var Ref = function () {
1190
+ var Ref = function () {
1176
1191
 
1177
- this.a = 5;
1192
+ this.a = 5;
1178
1193
  };
1179
1194
 
1180
1195
  Ref.prototype.b = function () {
@@ -1185,10 +1200,10 @@ describe('deepEqual()', function () {
1185
1200
  expect(Hoek.deepEqual(new Obj(), new Ref())).to.be.false();
1186
1201
  expect(Hoek.deepEqual(new Obj(), new Obj())).to.be.true();
1187
1202
  expect(Hoek.deepEqual(new Ref(), new Ref())).to.be.true();
1188
- done();
1203
+ done();
1189
1204
  });
1190
1205
 
1191
- it('compares plain objects', function (done) {
1206
+ it('compares plain objects', function (done) {
1192
1207
 
1193
1208
  var a = Object.create(null);
1194
1209
  var b = Object.create(null);
@@ -1198,131 +1213,131 @@ describe('deepEqual()', function () {
1198
1213
 
1199
1214
  expect(Hoek.deepEqual(a, b)).to.be.true();
1200
1215
  expect(Hoek.deepEqual(a, { b: 'c' })).to.be.false();
1201
- done();
1216
+ done();
1202
1217
  });
1203
1218
 
1204
- it('compares an object with an empty object', function (done) {
1219
+ it('compares an object with an empty object', function (done) {
1205
1220
 
1206
1221
  var a = { a: 1, b: 2 };
1207
1222
 
1208
1223
  expect(Hoek.deepEqual({}, a)).to.be.false();
1209
1224
  expect(Hoek.deepEqual(a, {})).to.be.false();
1210
- done();
1225
+ done();
1211
1226
  });
1212
1227
 
1213
- it('compares an object ignoring the prototype', function (done) {
1228
+ it('compares an object ignoring the prototype', function (done) {
1214
1229
 
1215
1230
  var a = Object.create(null);
1216
1231
  var b = {};
1217
1232
 
1218
1233
  expect(Hoek.deepEqual(a, b, { prototype: false })).to.be.true();
1219
- done();
1234
+ done();
1220
1235
  });
1221
1236
 
1222
- it('compares an object ignoring the prototype recursively', function (done) {
1237
+ it('compares an object ignoring the prototype recursively', function (done) {
1223
1238
 
1224
1239
  var a = [Object.create(null)];
1225
1240
  var b = [{}];
1226
1241
 
1227
1242
  expect(Hoek.deepEqual(a, b, { prototype: false })).to.be.true();
1228
- done();
1229
- });
1243
+ done();
1244
+ });
1230
1245
  });
1231
1246
 
1232
- describe('unique()', function () {
1247
+ describe('unique()', function () {
1233
1248
 
1234
- it('ensures uniqueness within array of objects based on subkey', function (done) {
1249
+ it('ensures uniqueness within array of objects based on subkey', function (done) {
1235
1250
 
1236
1251
  var a = Hoek.unique(dupsArray, 'x');
1237
1252
  expect(a).to.deep.equal(reducedDupsArray);
1238
- done();
1253
+ done();
1239
1254
  });
1240
1255
 
1241
- it('removes duplicated without key', function (done) {
1256
+ it('removes duplicated without key', function (done) {
1242
1257
 
1243
1258
  expect(Hoek.unique([1, 2, 3, 4, 2, 1, 5])).to.deep.equal([1, 2, 3, 4, 5]);
1244
- done();
1245
- });
1259
+ done();
1260
+ });
1246
1261
  });
1247
1262
 
1248
- describe('mapToObject()', function () {
1263
+ describe('mapToObject()', function () {
1249
1264
 
1250
- it('returns null on null array', function (done) {
1265
+ it('returns null on null array', function (done) {
1251
1266
 
1252
1267
  var a = Hoek.mapToObject(null);
1253
1268
  expect(a).to.equal(null);
1254
- done();
1269
+ done();
1255
1270
  });
1256
1271
 
1257
- it('converts basic array to existential object', function (done) {
1272
+ it('converts basic array to existential object', function (done) {
1258
1273
 
1259
1274
  var keys = [1, 2, 3, 4];
1260
1275
  var a = Hoek.mapToObject(keys);
1261
- for (var i in keys) {
1262
- expect(a[keys[i]]).to.equal(true);
1276
+ for (var i in keys) {
1277
+ expect(a[keys[i]]).to.equal(true);
1263
1278
  }
1264
- done();
1279
+ done();
1265
1280
  });
1266
1281
 
1267
- it('converts array of objects to existential object', function (done) {
1282
+ it('converts array of objects to existential object', function (done) {
1268
1283
 
1269
1284
  var keys = [{ x: 1 }, { x: 2 }, { x: 3 }, { y: 4 }];
1270
1285
  var subkey = 'x';
1271
1286
  var a = Hoek.mapToObject(keys, subkey);
1272
1287
  expect(a).to.deep.equal({ 1: true, 2: true, 3: true });
1273
- done();
1274
- });
1288
+ done();
1289
+ });
1275
1290
  });
1276
1291
 
1277
- describe('intersect()', function () {
1292
+ describe('intersect()', function () {
1278
1293
 
1279
- it('returns the common objects of two arrays', function (done) {
1294
+ it('returns the common objects of two arrays', function (done) {
1280
1295
 
1281
1296
  var array1 = [1, 2, 3, 4, 4, 5, 5];
1282
1297
  var array2 = [5, 4, 5, 6, 7];
1283
1298
  var common = Hoek.intersect(array1, array2);
1284
1299
  expect(common.length).to.equal(2);
1285
- done();
1300
+ done();
1286
1301
  });
1287
1302
 
1288
- it('returns just the first common object of two arrays', function (done) {
1303
+ it('returns just the first common object of two arrays', function (done) {
1289
1304
 
1290
1305
  var array1 = [1, 2, 3, 4, 4, 5, 5];
1291
1306
  var array2 = [5, 4, 5, 6, 7];
1292
1307
  var common = Hoek.intersect(array1, array2, true);
1293
1308
  expect(common).to.equal(5);
1294
- done();
1309
+ done();
1295
1310
  });
1296
1311
 
1297
- it('returns null when no common and returning just the first common object of two arrays', function (done) {
1312
+ it('returns null when no common and returning just the first common object of two arrays', function (done) {
1298
1313
 
1299
1314
  var array1 = [1, 2, 3, 4, 4, 5, 5];
1300
1315
  var array2 = [6, 7];
1301
1316
  var common = Hoek.intersect(array1, array2, true);
1302
1317
  expect(common).to.equal(null);
1303
- done();
1318
+ done();
1304
1319
  });
1305
1320
 
1306
- it('returns an empty array if either input is null', function (done) {
1321
+ it('returns an empty array if either input is null', function (done) {
1307
1322
 
1308
1323
  expect(Hoek.intersect([1], null).length).to.equal(0);
1309
1324
  expect(Hoek.intersect(null, [1]).length).to.equal(0);
1310
- done();
1325
+ done();
1311
1326
  });
1312
1327
 
1313
- it('returns the common objects of object and array', function (done) {
1328
+ it('returns the common objects of object and array', function (done) {
1314
1329
 
1315
1330
  var array1 = [1, 2, 3, 4, 4, 5, 5];
1316
1331
  var array2 = [5, 4, 5, 6, 7];
1317
1332
  var common = Hoek.intersect(Hoek.mapToObject(array1), array2);
1318
1333
  expect(common.length).to.equal(2);
1319
- done();
1320
- });
1334
+ done();
1335
+ });
1321
1336
  });
1322
1337
 
1323
- describe('contain()', function () {
1338
+ describe('contain()', function () {
1324
1339
 
1325
- it('tests strings', function (done) {
1340
+ it('tests strings', function (done) {
1326
1341
 
1327
1342
  expect(Hoek.contain('abc', 'ab')).to.be.true();
1328
1343
  expect(Hoek.contain('abc', 'abc', { only: true })).to.be.true();
@@ -1337,10 +1352,10 @@ describe('contain()', function () {
1337
1352
  expect(Hoek.contain('abb', 'b', { once: true })).to.be.false();
1338
1353
  expect(Hoek.contain('abc', ['a', 'd'])).to.be.false();
1339
1354
  expect(Hoek.contain('abc', ['ab', 'bc'])).to.be.false(); // Overlapping values not supported
1340
- done();
1355
+ done();
1341
1356
  });
1342
1357
 
1343
- it('tests arrays', function (done) {
1358
+ it('tests arrays', function (done) {
1344
1359
 
1345
1360
  expect(Hoek.contain([1, 2, 3], 1)).to.be.true();
1346
1361
  expect(Hoek.contain([{ a: 1 }], { a: 1 }, { deep: true })).to.be.true();
@@ -1361,10 +1376,10 @@ describe('contain()', function () {
1361
1376
  expect(Hoek.contain([1, 3, 2], [1, 2], { only: true })).to.be.false();
1362
1377
  expect(Hoek.contain([1, 2, 2], [1, 2], { once: true })).to.be.false();
1363
1378
  expect(Hoek.contain([0, 2, 3], [1, 4], { part: true })).to.be.false();
1364
- done();
1379
+ done();
1365
1380
  });
1366
1381
 
1367
- it('tests objects', function (done) {
1382
+ it('tests objects', function (done) {
1368
1383
 
1369
1384
  expect(Hoek.contain({ a: 1, b: 2, c: 3 }, 'a')).to.be.true();
1370
1385
  expect(Hoek.contain({ a: 1, b: 2, c: 3 }, ['a', 'c'])).to.be.true();
@@ -1399,10 +1414,10 @@ describe('contain()', function () {
1399
1414
  // Getter check
1400
1415
  var Foo = function (bar) {
1401
1416
 
1402
- this.bar = bar;
1417
+ this.bar = bar;
1403
1418
  };
1404
1419
 
1405
- Object.defineProperty(Foo.prototype, 'baz', {
1420
+ Object.defineProperty(Foo.prototype, 'baz', {
1406
1421
  enumerable: true,
1407
1422
  get: function () {
1408
1423
 
@@ -1417,230 +1432,238 @@ describe('contain()', function () {
1417
1432
  expect(Hoek.contain({ a: new Foo('b') }, { a: { baz: 'b' } }, { deep: true, part: false })).to.be.false();
1418
1433
  expect(Hoek.contain({ a: new Foo('b') }, { a: { baz: 'b' } }, { deep: true, part: true })).to.be.true();
1419
1434
 
1420
- done();
1421
- });
1435
+ done();
1436
+ });
1422
1437
  });
1423
1438
 
1424
- describe('flatten()', function () {
1439
+ describe('flatten()', function () {
1425
1440
 
1426
- it('returns a flat array', function (done) {
1441
+ it('returns a flat array', function (done) {
1427
1442
 
1428
1443
  var result = Hoek.flatten([1, 2, [3, 4, [5, 6], [7], 8], [9], [10, [11, 12]], 13]);
1429
1444
  expect(result.length).to.equal(13);
1430
1445
  expect(result).to.deep.equal([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]);
1431
- done();
1432
- });
1446
+ done();
1447
+ });
1433
1448
  });
1434
1449
 
1435
- describe('reach()', function () {
1450
+ describe('reach()', function () {
1436
1451
 
1437
- var obj = {
1438
- a: {
1439
- b: {
1440
- c: {
1452
+ var obj = {
1453
+ a: {
1454
+ b: {
1455
+ c: {
1441
1456
  d: 1,
1442
- e: 2
1457
+ e: 2
1443
1458
  },
1444
- f: 'hello'
1459
+ f: 'hello'
1445
1460
  },
1446
- g: {
1447
- h: 3
1448
- }
1461
+ g: {
1462
+ h: 3
1463
+ }
1449
1464
  },
1450
1465
  i: function () { },
1451
1466
  j: null,
1452
- k: [4, 8, 9, 1]
1467
+ k: [4, 8, 9, 1]
1453
1468
  };
1454
1469
 
1455
1470
  obj.i.x = 5;
1456
1471
 
1457
- it('returns first value of array', function (done) {
1472
+ it('returns object itself', function (done) {
1473
+
1474
+ expect(Hoek.reach(obj, null)).to.equal(obj);
1475
+ expect(Hoek.reach(obj, false)).to.equal(obj);
1476
+ expect(Hoek.reach(obj)).to.equal(obj);
1477
+ done();
1478
+ });
1479
+
1480
+ it('returns first value of array', function (done) {
1458
1481
 
1459
1482
  expect(Hoek.reach(obj, 'k.0')).to.equal(4);
1460
- done();
1483
+ done();
1461
1484
  });
1462
1485
 
1463
- it('returns last value of array using negative index', function (done) {
1486
+ it('returns last value of array using negative index', function (done) {
1464
1487
 
1465
1488
  expect(Hoek.reach(obj, 'k.-2')).to.equal(9);
1466
- done();
1489
+ done();
1467
1490
  });
1468
1491
 
1469
- it('returns a valid member', function (done) {
1492
+ it('returns a valid member', function (done) {
1470
1493
 
1471
1494
  expect(Hoek.reach(obj, 'a.b.c.d')).to.equal(1);
1472
- done();
1495
+ done();
1473
1496
  });
1474
1497
 
1475
- it('returns a valid member with separator override', function (done) {
1498
+ it('returns a valid member with separator override', function (done) {
1476
1499
 
1477
1500
  expect(Hoek.reach(obj, 'a/b/c/d', '/')).to.equal(1);
1478
- done();
1501
+ done();
1479
1502
  });
1480
1503
 
1481
- it('returns undefined on null object', function (done) {
1504
+ it('returns undefined on null object', function (done) {
1482
1505
 
1483
1506
  expect(Hoek.reach(null, 'a.b.c.d')).to.equal(undefined);
1484
- done();
1507
+ done();
1485
1508
  });
1486
1509
 
1487
- it('returns undefined on missing object member', function (done) {
1510
+ it('returns undefined on missing object member', function (done) {
1488
1511
 
1489
1512
  expect(Hoek.reach(obj, 'a.b.c.d.x')).to.equal(undefined);
1490
- done();
1513
+ done();
1491
1514
  });
1492
1515
 
1493
- it('returns undefined on missing function member', function (done) {
1516
+ it('returns undefined on missing function member', function (done) {
1494
1517
 
1495
1518
  expect(Hoek.reach(obj, 'i.y', { functions: true })).to.equal(undefined);
1496
- done();
1519
+ done();
1497
1520
  });
1498
1521
 
1499
- it('throws on missing member in strict mode', function (done) {
1522
+ it('throws on missing member in strict mode', function (done) {
1500
1523
 
1501
- expect(function () {
1524
+ expect(function () {
1502
1525
 
1503
- Hoek.reach(obj, 'a.b.c.o.x', { strict: true });
1526
+ Hoek.reach(obj, 'a.b.c.o.x', { strict: true });
1504
1527
  }).to.throw('Missing segment o in reach path a.b.c.o.x');
1505
1528
 
1506
- done();
1529
+ done();
1507
1530
  });
1508
1531
 
1509
- it('returns undefined on invalid member', function (done) {
1532
+ it('returns undefined on invalid member', function (done) {
1510
1533
 
1511
1534
  expect(Hoek.reach(obj, 'a.b.c.d-.x')).to.equal(undefined);
1512
- done();
1535
+ done();
1513
1536
  });
1514
1537
 
1515
- it('returns function member', function (done) {
1538
+ it('returns function member', function (done) {
1516
1539
 
1517
1540
  expect(typeof Hoek.reach(obj, 'i')).to.equal('function');
1518
- done();
1541
+ done();
1519
1542
  });
1520
1543
 
1521
- it('returns function property', function (done) {
1544
+ it('returns function property', function (done) {
1522
1545
 
1523
1546
  expect(Hoek.reach(obj, 'i.x')).to.equal(5);
1524
- done();
1547
+ done();
1525
1548
  });
1526
1549
 
1527
- it('returns null', function (done) {
1550
+ it('returns null', function (done) {
1528
1551
 
1529
1552
  expect(Hoek.reach(obj, 'j')).to.equal(null);
1530
- done();
1553
+ done();
1531
1554
  });
1532
1555
 
1533
- it('throws on function property when functions not allowed', function (done) {
1556
+ it('throws on function property when functions not allowed', function (done) {
1534
1557
 
1535
- expect(function () {
1558
+ expect(function () {
1536
1559
 
1537
- Hoek.reach(obj, 'i.x', { functions: false });
1560
+ Hoek.reach(obj, 'i.x', { functions: false });
1538
1561
  }).to.throw('Invalid segment x in reach path i.x');
1539
1562
 
1540
- done();
1563
+ done();
1541
1564
  });
1542
1565
 
1543
- it('will return a default value if property is not found', function (done) {
1566
+ it('will return a default value if property is not found', function (done) {
1544
1567
 
1545
1568
  expect(Hoek.reach(obj, 'a.b.q', { default: 'defaultValue' })).to.equal('defaultValue');
1546
- done();
1569
+ done();
1547
1570
  });
1548
1571
 
1549
- it('will return a default value if path is not found', function (done) {
1572
+ it('will return a default value if path is not found', function (done) {
1550
1573
 
1551
1574
  expect(Hoek.reach(obj, 'q', { default: 'defaultValue' })).to.equal('defaultValue');
1552
- done();
1575
+ done();
1553
1576
  });
1554
1577
 
1555
- it('allows a falsey value to be used as the default value', function (done) {
1578
+ it('allows a falsey value to be used as the default value', function (done) {
1556
1579
 
1557
1580
  expect(Hoek.reach(obj, 'q', { default: '' })).to.equal('');
1558
- done();
1559
- });
1581
+ done();
1582
+ });
1560
1583
  });
1561
1584
 
1562
- describe('reachTemplate()', function () {
1585
+ describe('reachTemplate()', function () {
1563
1586
 
1564
- it('applies object to template', function (done) {
1587
+ it('applies object to template', function (done) {
1565
1588
 
1566
- var obj = {
1567
- a: {
1568
- b: {
1569
- c: {
1570
- d: 1
1571
- }
1572
- }
1589
+ var obj = {
1590
+ a: {
1591
+ b: {
1592
+ c: {
1593
+ d: 1
1594
+ }
1595
+ }
1573
1596
  },
1574
1597
  j: null,
1575
- k: [4, 8, 9, 1]
1598
+ k: [4, 8, 9, 1]
1576
1599
  };
1577
1600
 
1578
1601
  var template = '{k.0}:{k.-2}:{a.b.c.d}:{x.y}:{j}';
1579
1602
 
1580
1603
  expect(Hoek.reachTemplate(obj, template)).to.equal('4:9:1::');
1581
- done();
1582
- });
1583
-
1584
- it('applies object to template (options)', function (done) {
1585
-
1586
- var obj = {
1587
- a: {
1588
- b: {
1589
- c: {
1590
- d: 1
1591
- }
1592
- }
1604
+ done();
1605
+ });
1606
+
1607
+ it('applies object to template (options)', function (done) {
1608
+
1609
+ var obj = {
1610
+ a: {
1611
+ b: {
1612
+ c: {
1613
+ d: 1
1614
+ }
1615
+ }
1593
1616
  },
1594
1617
  j: null,
1595
- k: [4, 8, 9, 1]
1618
+ k: [4, 8, 9, 1]
1596
1619
  };
1597
1620
 
1598
1621
  var template = '{k/0}:{k/-2}:{a/b/c/d}:{x/y}:{j}';
1599
1622
 
1600
1623
  expect(Hoek.reachTemplate(obj, template, '/')).to.equal('4:9:1::');
1601
- done();
1602
- });
1624
+ done();
1625
+ });
1603
1626
  });
1604
1627
 
1605
- describe('callStack()', function () {
1628
+ describe('callStack()', function () {
1606
1629
 
1607
- it('returns the full call stack', function (done) {
1630
+ it('returns the full call stack', function (done) {
1608
1631
 
1609
1632
  var stack = Hoek.callStack();
1610
1633
  expect(stack[0][0]).to.contain('index.js');
1611
1634
  expect(stack[0][2]).to.equal(26);
1612
- done();
1613
- });
1635
+ done();
1636
+ });
1614
1637
  });
1615
1638
 
1616
- describe('displayStack ()', function () {
1639
+ describe('displayStack ()', function () {
1617
1640
 
1618
- it('returns the full call stack for display', function (done) {
1641
+ it('returns the full call stack for display', function (done) {
1619
1642
 
1620
1643
  var stack = Hoek.displayStack();
1621
1644
  expect(stack[0]).to.contain(Path.normalize('/test/index.js') + ':');
1622
- done();
1645
+ done();
1623
1646
  });
1624
1647
 
1625
- it('includes constructor functions correctly', function (done) {
1648
+ it('includes constructor functions correctly', function (done) {
1626
1649
 
1627
- var Something = function (next) {
1650
+ var Something = function (next) {
1628
1651
 
1629
- next();
1652
+ next();
1630
1653
  };
1631
1654
 
1632
- var something = new Something(function () {
1655
+ var something = new Something(function () {
1633
1656
 
1634
1657
  var stack = Hoek.displayStack();
1635
1658
  expect(stack[1]).to.contain('new Something');
1636
- done();
1637
- });
1638
- });
1659
+ done();
1660
+ });
1661
+ });
1639
1662
  });
1640
1663
 
1641
- describe('abort()', function () {
1664
+ describe('abort()', function () {
1642
1665
 
1643
- it('exits process when not in test mode', function (done) {
1666
+ it('exits process when not in test mode', function (done) {
1644
1667
 
1645
1668
  var env = process.env.NODE_ENV;
1646
1669
  var write = process.stdout.write;
@@ -1648,38 +1671,38 @@ describe('abort()', function () {
1648
1671
 
1649
1672
  process.env.NODE_ENV = 'nottatest';
1650
1673
  process.stdout.write = function () { };
1651
- process.exit = function (state) {
1674
+ process.exit = function (state) {
1652
1675
 
1653
1676
  process.exit = exit;
1654
1677
  process.env.NODE_ENV = env;
1655
1678
  process.stdout.write = write;
1656
1679
 
1657
1680
  expect(state).to.equal(1);
1658
- done();
1681
+ done();
1659
1682
  };
1660
1683
 
1661
- Hoek.abort('Boom');
1684
+ Hoek.abort('Boom');
1662
1685
  });
1663
1686
 
1664
- it('throws when not in test mode and abortThrow is true', function (done) {
1687
+ it('throws when not in test mode and abortThrow is true', function (done) {
1665
1688
 
1666
1689
  var env = process.env.NODE_ENV;
1667
1690
  process.env.NODE_ENV = 'nottatest';
1668
1691
  Hoek.abortThrow = true;
1669
1692
 
1670
- var fn = function () {
1693
+ var fn = function () {
1671
1694
 
1672
- Hoek.abort('my error message');
1695
+ Hoek.abort('my error message');
1673
1696
  };
1674
1697
 
1675
1698
  expect(fn).to.throw('my error message');
1676
1699
  Hoek.abortThrow = false;
1677
1700
  process.env.NODE_ENV = env;
1678
1701
 
1679
- done();
1702
+ done();
1680
1703
  });
1681
1704
 
1682
- it('respects hideStack argument', function (done) {
1705
+ it('respects hideStack argument', function (done) {
1683
1706
 
1684
1707
  var env = process.env.NODE_ENV;
1685
1708
  var write = process.stdout.write;
@@ -1688,9 +1711,9 @@ describe('abort()', function () {
1688
1711
 
1689
1712
  process.exit = function () { };
1690
1713
  process.env.NODE_ENV = '';
1691
- process.stdout.write = function (message) {
1714
+ process.stdout.write = function (message) {
1692
1715
 
1693
- output = message;
1716
+ output = message;
1694
1717
  };
1695
1718
 
1696
1719
  Hoek.abort('my error message', true);
@@ -1701,38 +1724,38 @@ describe('abort()', function () {
1701
1724
 
1702
1725
  expect(output).to.equal('ABORT: my error message\n\t\n');
1703
1726
 
1704
- done();
1727
+ done();
1705
1728
  });
1706
1729
 
1707
- it('throws in test mode', function (done) {
1730
+ it('throws in test mode', function (done) {
1708
1731
 
1709
1732
  var env = process.env.NODE_ENV;
1710
1733
  process.env.NODE_ENV = 'test';
1711
1734
 
1712
- expect(function () {
1735
+ expect(function () {
1713
1736
 
1714
- Hoek.abort('my error message', true);
1737
+ Hoek.abort('my error message', true);
1715
1738
  }).to.throw('my error message');
1716
1739
 
1717
1740
  process.env.NODE_ENV = env;
1718
- done();
1741
+ done();
1719
1742
  });
1720
1743
 
1721
- it('throws in test mode with default message', function (done) {
1744
+ it('throws in test mode with default message', function (done) {
1722
1745
 
1723
1746
  var env = process.env.NODE_ENV;
1724
1747
  process.env.NODE_ENV = 'test';
1725
1748
 
1726
- expect(function () {
1749
+ expect(function () {
1727
1750
 
1728
- Hoek.abort('', true);
1751
+ Hoek.abort('', true);
1729
1752
  }).to.throw('Unknown error');
1730
1753
 
1731
1754
  process.env.NODE_ENV = env;
1732
- done();
1755
+ done();
1733
1756
  });
1734
1757
 
1735
- it('defaults to showing stack', function (done) {
1758
+ it('defaults to showing stack', function (done) {
1736
1759
 
1737
1760
  var env = process.env.NODE_ENV;
1738
1761
  var write = process.stdout.write;
@@ -1741,9 +1764,9 @@ describe('abort()', function () {
1741
1764
 
1742
1765
  process.exit = function () { };
1743
1766
  process.env.NODE_ENV = '';
1744
- process.stdout.write = function (message) {
1767
+ process.stdout.write = function (message) {
1745
1768
 
1746
- output = message;
1769
+ output = message;
1747
1770
  };
1748
1771
 
1749
1772
  Hoek.abort('my error message');
@@ -1754,173 +1777,173 @@ describe('abort()', function () {
1754
1777
 
1755
1778
  expect(output).to.contain('index.js');
1756
1779
 
1757
- done();
1758
- });
1780
+ done();
1781
+ });
1759
1782
  });
1760
1783
 
1761
- describe('assert()', function () {
1784
+ describe('assert()', function () {
1762
1785
 
1763
- it('throws an Error when using assert in a test', function (done) {
1786
+ it('throws an Error when using assert in a test', function (done) {
1764
1787
 
1765
- var fn = function () {
1788
+ var fn = function () {
1766
1789
 
1767
- Hoek.assert(false, 'my error message');
1790
+ Hoek.assert(false, 'my error message');
1768
1791
  };
1769
1792
 
1770
1793
  expect(fn).to.throw('my error message');
1771
- done();
1794
+ done();
1772
1795
  });
1773
1796
 
1774
- it('throws an Error when using assert in a test with no message', function (done) {
1797
+ it('throws an Error when using assert in a test with no message', function (done) {
1775
1798
 
1776
- var fn = function () {
1799
+ var fn = function () {
1777
1800
 
1778
- Hoek.assert(false);
1801
+ Hoek.assert(false);
1779
1802
  };
1780
1803
 
1781
1804
  expect(fn).to.throw('Unknown error');
1782
- done();
1805
+ done();
1783
1806
  });
1784
1807
 
1785
- it('throws an Error when using assert in a test with multipart message', function (done) {
1808
+ it('throws an Error when using assert in a test with multipart message', function (done) {
1786
1809
 
1787
- var fn = function () {
1810
+ var fn = function () {
1788
1811
 
1789
- Hoek.assert(false, 'This', 'is', 'my message');
1812
+ Hoek.assert(false, 'This', 'is', 'my message');
1790
1813
  };
1791
1814
 
1792
1815
  expect(fn).to.throw('This is my message');
1793
- done();
1816
+ done();
1794
1817
  });
1795
1818
 
1796
- it('throws an Error when using assert in a test with multipart message (empty)', function (done) {
1819
+ it('throws an Error when using assert in a test with multipart message (empty)', function (done) {
1797
1820
 
1798
- var fn = function () {
1821
+ var fn = function () {
1799
1822
 
1800
- Hoek.assert(false, 'This', 'is', '', 'my message');
1823
+ Hoek.assert(false, 'This', 'is', '', 'my message');
1801
1824
  };
1802
1825
 
1803
1826
  expect(fn).to.throw('This is my message');
1804
- done();
1827
+ done();
1805
1828
  });
1806
1829
 
1807
- it('throws an Error when using assert in a test with object message', function (done) {
1830
+ it('throws an Error when using assert in a test with object message', function (done) {
1808
1831
 
1809
- var fn = function () {
1832
+ var fn = function () {
1810
1833
 
1811
- Hoek.assert(false, 'This', 'is', { spinal: 'tap' });
1834
+ Hoek.assert(false, 'This', 'is', { spinal: 'tap' });
1812
1835
  };
1813
1836
 
1814
1837
  expect(fn).to.throw('This is {"spinal":"tap"}');
1815
- done();
1838
+ done();
1816
1839
  });
1817
1840
 
1818
- it('throws an Error when using assert in a test with multipart string and error messages', function (done) {
1841
+ it('throws an Error when using assert in a test with multipart string and error messages', function (done) {
1819
1842
 
1820
- var fn = function () {
1843
+ var fn = function () {
1821
1844
 
1822
- Hoek.assert(false, 'This', 'is', new Error('spinal'), new Error('tap'));
1845
+ Hoek.assert(false, 'This', 'is', new Error('spinal'), new Error('tap'));
1823
1846
  };
1824
1847
 
1825
1848
  expect(fn).to.throw('This is spinal tap');
1826
- done();
1849
+ done();
1827
1850
  });
1828
1851
 
1829
- it('throws an Error when using assert in a test with error object message', function (done) {
1852
+ it('throws an Error when using assert in a test with error object message', function (done) {
1830
1853
 
1831
- var fn = function () {
1854
+ var fn = function () {
1832
1855
 
1833
- Hoek.assert(false, new Error('This is spinal tap'));
1856
+ Hoek.assert(false, new Error('This is spinal tap'));
1834
1857
  };
1835
1858
 
1836
1859
  expect(fn).to.throw('This is spinal tap');
1837
- done();
1860
+ done();
1838
1861
  });
1839
1862
 
1840
- it('throws the same Error that is passed to it if there is only one error passed', function (done) {
1863
+ it('throws the same Error that is passed to it if there is only one error passed', function (done) {
1841
1864
 
1842
1865
  var error = new Error('ruh roh');
1843
1866
  var error2 = new Error('ruh roh');
1844
1867
 
1845
- var fn = function () {
1868
+ var fn = function () {
1846
1869
 
1847
- Hoek.assert(false, error);
1870
+ Hoek.assert(false, error);
1848
1871
  };
1849
1872
 
1850
- try {
1851
- fn();
1852
- } catch (err) {
1873
+ try {
1874
+ fn();
1875
+ } catch (err) {
1853
1876
  expect(error).to.equal(error); // should be the same reference
1854
1877
  expect(error).to.not.equal(error2); // error with the same message should not match
1855
1878
  }
1856
1879
 
1857
- done();
1858
- });
1880
+ done();
1881
+ });
1859
1882
  });
1860
1883
 
1861
- describe('Timer', function () {
1884
+ describe('Timer', function () {
1862
1885
 
1863
- it('returns time elapsed', function (done) {
1886
+ it('returns time elapsed', function (done) {
1864
1887
 
1865
1888
  var timer = new Hoek.Timer();
1866
- setTimeout(function () {
1889
+ setTimeout(function () {
1867
1890
 
1868
1891
  expect(timer.elapsed()).to.be.above(9);
1869
- done();
1870
- }, 12);
1871
- });
1892
+ done();
1893
+ }, 12);
1894
+ });
1872
1895
  });
1873
1896
 
1874
- describe('Bench', function () {
1897
+ describe('Bench', function () {
1875
1898
 
1876
- it('returns time elapsed', function (done) {
1899
+ it('returns time elapsed', function (done) {
1877
1900
 
1878
1901
  var timer = new Hoek.Bench();
1879
- setTimeout(function () {
1902
+ setTimeout(function () {
1880
1903
 
1881
1904
  expect(timer.elapsed()).to.be.above(9);
1882
- done();
1883
- }, 12);
1884
- });
1905
+ done();
1906
+ }, 12);
1907
+ });
1885
1908
  });
1886
1909
 
1887
- describe('escapeRegex()', function () {
1910
+ describe('escapeRegex()', function () {
1888
1911
 
1889
- it('escapes all special regular expression characters', function (done) {
1912
+ it('escapes all special regular expression characters', function (done) {
1890
1913
 
1891
1914
  var a = Hoek.escapeRegex('4^f$s.4*5+-_?%=#!:@|~\\/`"(>)[<]d{}s,');
1892
1915
  expect(a).to.equal('4\\^f\\$s\\.4\\*5\\+\\-_\\?%\\=#\\!\\:@\\|~\\\\\\/`"\\(>\\)\\[<\\]d\\{\\}s\\,');
1893
- done();
1894
- });
1916
+ done();
1917
+ });
1895
1918
  });
1896
1919
 
1897
- describe('Base64Url', function () {
1920
+ describe('Base64Url', function () {
1898
1921
 
1899
1922
  var base64str = 'AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0-P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn-AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq-wsbKztLW2t7i5uru8vb6_wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t_g4eLj5OXm5-jp6uvs7e7v8PHy8_T19vf4-fr7_P3-_w';
1900
1923
  var str = unescape('%00%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F%20%21%22%23%24%25%26%27%28%29*+%2C-./0123456789%3A%3B%3C%3D%3E%3F@ABCDEFGHIJKLMNOPQRSTUVWXYZ%5B%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D%7E%7F%80%81%82%83%84%85%86%87%88%89%8A%8B%8C%8D%8E%8F%90%91%92%93%94%95%96%97%98%99%9A%9B%9C%9D%9E%9F%A0%A1%A2%A3%A4%A5%A6%A7%A8%A9%AA%AB%AC%AD%AE%AF%B0%B1%B2%B3%B4%B5%B6%B7%B8%B9%BA%BB%BC%BD%BE%BF%C0%C1%C2%C3%C4%C5%C6%C7%C8%C9%CA%CB%CC%CD%CE%CF%D0%D1%D2%D3%D4%D5%D6%D7%D8%D9%DA%DB%DC%DD%DE%DF%E0%E1%E2%E3%E4%E5%E6%E7%E8%E9%EA%EB%EC%ED%EE%EF%F0%F1%F2%F3%F4%F5%F6%F7%F8%F9%FA%FB%FC%FD%FE%FF');
1901
1924
 
1902
- describe('base64urlEncode()', function () {
1925
+ describe('base64urlEncode()', function () {
1903
1926
 
1904
- it('should base64 URL-safe a string', function (done) {
1927
+ it('should base64 URL-safe a string', function (done) {
1905
1928
 
1906
1929
  expect(Hoek.base64urlEncode(str)).to.equal(base64str);
1907
- done();
1930
+ done();
1908
1931
  });
1909
1932
 
1910
- it('encodes a buffer', function (done) {
1933
+ it('encodes a buffer', function (done) {
1911
1934
 
1912
1935
  expect(Hoek.base64urlEncode(new Buffer(str, 'binary'))).to.equal(base64str);
1913
- done();
1936
+ done();
1914
1937
  });
1915
1938
 
1916
- it('should base64 URL-safe a hex string', function (done) {
1939
+ it('should base64 URL-safe a hex string', function (done) {
1917
1940
 
1918
1941
  var buffer = new Buffer(str, 'binary');
1919
1942
  expect(Hoek.base64urlEncode(buffer.toString('hex'), 'hex')).to.equal(base64str);
1920
- done();
1943
+ done();
1921
1944
  });
1922
1945
 
1923
- it('works on larger input strings', function (done) {
1946
+ it('works on larger input strings', function (done) {
1924
1947
 
1925
1948
  var input = Fs.readFileSync(Path.join(__dirname, 'index.js')).toString();
1926
1949
  var encoded = Hoek.base64urlEncode(input);
@@ -1931,145 +1954,145 @@ describe('Base64Url', function () {
1931
1954
  var decoded = Hoek.base64urlDecode(encoded);
1932
1955
 
1933
1956
  expect(decoded).to.equal(input);
1934
- done();
1935
- });
1957
+ done();
1958
+ });
1936
1959
  });
1937
1960
 
1938
- describe('base64urlDecode()', function () {
1961
+ describe('base64urlDecode()', function () {
1939
1962
 
1940
- it('should un-base64 URL-safe a string', function (done) {
1963
+ it('should un-base64 URL-safe a string', function (done) {
1941
1964
 
1942
1965
  expect(Hoek.base64urlDecode(base64str)).to.equal(str);
1943
- done();
1966
+ done();
1944
1967
  });
1945
1968
 
1946
- it('should un-base64 URL-safe a string into hex', function (done) {
1969
+ it('should un-base64 URL-safe a string into hex', function (done) {
1947
1970
 
1948
1971
  expect(Hoek.base64urlDecode(base64str, 'hex')).to.equal(new Buffer(str, 'binary').toString('hex'));
1949
- done();
1972
+ done();
1950
1973
  });
1951
1974
 
1952
- it('should un-base64 URL-safe a string and return a buffer', function (done) {
1975
+ it('should un-base64 URL-safe a string and return a buffer', function (done) {
1953
1976
 
1954
1977
  var buf = Hoek.base64urlDecode(base64str, 'buffer');
1955
1978
  expect(buf instanceof Buffer).to.equal(true);
1956
1979
  expect(buf.toString('binary')).to.equal(str);
1957
- done();
1980
+ done();
1958
1981
  });
1959
1982
 
1960
- it('returns error on undefined input', function (done) {
1983
+ it('returns error on undefined input', function (done) {
1961
1984
 
1962
1985
  expect(Hoek.base64urlDecode().message).to.exist();
1963
- done();
1986
+ done();
1964
1987
  });
1965
1988
 
1966
- it('returns error on invalid input', function (done) {
1989
+ it('returns error on invalid input', function (done) {
1967
1990
 
1968
1991
  expect(Hoek.base64urlDecode('*').message).to.exist();
1969
- done();
1970
- });
1971
- });
1992
+ done();
1993
+ });
1994
+ });
1972
1995
  });
1973
1996
 
1974
- describe('escapeHeaderAttribute()', function () {
1997
+ describe('escapeHeaderAttribute()', function () {
1975
1998
 
1976
- it('should not alter ascii values', function (done) {
1999
+ it('should not alter ascii values', function (done) {
1977
2000
 
1978
2001
  var a = Hoek.escapeHeaderAttribute('My Value');
1979
2002
  expect(a).to.equal('My Value');
1980
- done();
2003
+ done();
1981
2004
  });
1982
2005
 
1983
- it('escapes all special HTTP header attribute characters', function (done) {
2006
+ it('escapes all special HTTP header attribute characters', function (done) {
1984
2007
 
1985
2008
  var a = Hoek.escapeHeaderAttribute('I said go!!!#"' + String.fromCharCode(92));
1986
2009
  expect(a).to.equal('I said go!!!#\\"\\\\');
1987
- done();
2010
+ done();
1988
2011
  });
1989
2012
 
1990
- it('throws on large unicode characters', function (done) {
2013
+ it('throws on large unicode characters', function (done) {
1991
2014
 
1992
- var fn = function () {
2015
+ var fn = function () {
1993
2016
 
1994
- Hoek.escapeHeaderAttribute('this is a test' + String.fromCharCode(500) + String.fromCharCode(300));
2017
+ Hoek.escapeHeaderAttribute('this is a test' + String.fromCharCode(500) + String.fromCharCode(300));
1995
2018
  };
1996
2019
 
1997
2020
  expect(fn).to.throw(Error);
1998
- done();
2021
+ done();
1999
2022
  });
2000
2023
 
2001
- it('throws on CRLF to prevent response splitting', function (done) {
2024
+ it('throws on CRLF to prevent response splitting', function (done) {
2002
2025
 
2003
- var fn = function () {
2026
+ var fn = function () {
2004
2027
 
2005
- Hoek.escapeHeaderAttribute('this is a test\r\n');
2028
+ Hoek.escapeHeaderAttribute('this is a test\r\n');
2006
2029
  };
2007
2030
 
2008
2031
  expect(fn).to.throw(Error);
2009
- done();
2010
- });
2032
+ done();
2033
+ });
2011
2034
  });
2012
2035
 
2013
- describe('escapeHtml()', function () {
2036
+ describe('escapeHtml()', function () {
2014
2037
 
2015
- it('escapes all special HTML characters', function (done) {
2038
+ it('escapes all special HTML characters', function (done) {
2016
2039
 
2017
2040
  var a = Hoek.escapeHtml('&<>"\'`');
2018
2041
  expect(a).to.equal('&amp;&lt;&gt;&quot;&#x27;&#x60;');
2019
- done();
2042
+ done();
2020
2043
  });
2021
2044
 
2022
- it('returns empty string on falsy input', function (done) {
2045
+ it('returns empty string on falsy input', function (done) {
2023
2046
 
2024
2047
  var a = Hoek.escapeHtml('');
2025
2048
  expect(a).to.equal('');
2026
- done();
2049
+ done();
2027
2050
  });
2028
2051
 
2029
- it('returns unchanged string on no reserved input', function (done) {
2052
+ it('returns unchanged string on no reserved input', function (done) {
2030
2053
 
2031
2054
  var a = Hoek.escapeHtml('abc');
2032
2055
  expect(a).to.equal('abc');
2033
- done();
2034
- });
2056
+ done();
2057
+ });
2035
2058
  });
2036
2059
 
2037
- describe('nextTick()', function () {
2060
+ describe('nextTick()', function () {
2038
2061
 
2039
- it('calls the provided callback on nextTick', function (done) {
2062
+ it('calls the provided callback on nextTick', function (done) {
2040
2063
 
2041
2064
  var a = 0;
2042
2065
 
2043
- var inc = function (step, next) {
2066
+ var inc = function (step, next) {
2044
2067
 
2045
2068
  a += step;
2046
- next();
2069
+ next();
2047
2070
  };
2048
2071
 
2049
2072
  var ticked = Hoek.nextTick(inc);
2050
2073
 
2051
- ticked(5, function () {
2074
+ ticked(5, function () {
2052
2075
 
2053
2076
  expect(a).to.equal(6);
2054
- done();
2077
+ done();
2055
2078
  });
2056
2079
 
2057
2080
  expect(a).to.equal(0);
2058
- inc(1, function () {
2081
+ inc(1, function () {
2059
2082
 
2060
- expect(a).to.equal(1);
2061
- });
2062
- });
2083
+ expect(a).to.equal(1);
2084
+ });
2085
+ });
2063
2086
  });
2064
2087
 
2065
- describe('once()', function () {
2088
+ describe('once()', function () {
2066
2089
 
2067
- it('allows function to only execute once', function (done) {
2090
+ it('allows function to only execute once', function (done) {
2068
2091
 
2069
2092
  var gen = 0;
2070
- var add = function (x) {
2093
+ var add = function (x) {
2071
2094
 
2072
- gen += x;
2095
+ gen += x;
2073
2096
  };
2074
2097
 
2075
2098
  add(5);
@@ -2079,23 +2102,23 @@ describe('once()', function () {
2079
2102
  expect(gen).to.equal(10);
2080
2103
  add(5);
2081
2104
  expect(gen).to.equal(10);
2082
- done();
2105
+ done();
2083
2106
  });
2084
2107
 
2085
- it('double once wraps one time', function (done) {
2108
+ it('double once wraps one time', function (done) {
2086
2109
 
2087
2110
  var method = function () { };
2088
2111
  method = Hoek.once(method);
2089
2112
  method.x = 1;
2090
2113
  method = Hoek.once(method);
2091
2114
  expect(method.x).to.equal(1);
2092
- done();
2093
- });
2115
+ done();
2116
+ });
2094
2117
  });
2095
2118
 
2096
- describe('isAbsoltePath()', function () {
2119
+ describe('isAbsoltePath()', function () {
2097
2120
 
2098
- it('identifies if path is absolute on Unix without node support', { parallel: false }, function (done) {
2121
+ it('identifies if path is absolute on Unix without node support', { parallel: false }, function (done) {
2099
2122
 
2100
2123
  var orig = Path.isAbsolute;
2101
2124
  Path.isAbsolute = undefined;
@@ -2108,15 +2131,15 @@ describe('isAbsoltePath()', function () {
2108
2131
 
2109
2132
  Path.isAbsolute = orig;
2110
2133
 
2111
- done();
2134
+ done();
2112
2135
  });
2113
2136
 
2114
- it('identifies if path is absolute with fake node support', { parallel: false }, function (done) {
2137
+ it('identifies if path is absolute with fake node support', { parallel: false }, function (done) {
2115
2138
 
2116
2139
  var orig = Path.isAbsolute;
2117
- Path.isAbsolute = function (path) {
2118
-
2119
- return path[0] === '/';
2140
+ Path.isAbsolute = function (path) {
2141
+
2142
+ return path[0] === '/';
2120
2143
  };
2121
2144
 
2122
2145
  expect(Hoek.isAbsolutePath('', 'linux')).to.equal(false);
@@ -2127,10 +2150,10 @@ describe('isAbsoltePath()', function () {
2127
2150
 
2128
2151
  Path.isAbsolute = orig;
2129
2152
 
2130
- done();
2153
+ done();
2131
2154
  });
2132
2155
 
2133
- it('identifies if path is absolute on Windows without node support', { parallel: false }, function (done) {
2156
+ it('identifies if path is absolute on Windows without node support', { parallel: false }, function (done) {
2134
2157
 
2135
2158
  var orig = Path.isAbsolute;
2136
2159
  Path.isAbsolute = undefined;
@@ -2147,13 +2170,13 @@ describe('isAbsoltePath()', function () {
2147
2170
 
2148
2171
  Path.isAbsolute = orig;
2149
2172
 
2150
- done();
2151
- });
2173
+ done();
2174
+ });
2152
2175
  });
2153
2176
 
2154
- describe('isInteger()', function () {
2177
+ describe('isInteger()', function () {
2155
2178
 
2156
- it('validates integers', function (done) {
2179
+ it('validates integers', function (done) {
2157
2180
 
2158
2181
  expect(Hoek.isInteger(0)).to.equal(true);
2159
2182
  expect(Hoek.isInteger(1)).to.equal(true);
@@ -2161,142 +2184,207 @@ describe('isInteger()', function () {
2161
2184
  expect(Hoek.isInteger('0')).to.equal(false);
2162
2185
  expect(Hoek.isInteger(1.0)).to.equal(true);
2163
2186
  expect(Hoek.isInteger(1.1)).to.equal(false);
2164
- done();
2165
- });
2187
+ done();
2188
+ });
2166
2189
  });
2167
2190
 
2168
- describe('ignore()', function () {
2191
+ describe('ignore()', function () {
2169
2192
 
2170
- it('exists', function (done) {
2193
+ it('exists', function (done) {
2171
2194
 
2172
2195
  expect(Hoek.ignore).to.exist();
2173
2196
  expect(typeof Hoek.ignore).to.equal('function');
2174
- done();
2175
- });
2197
+ done();
2198
+ });
2176
2199
  });
2177
2200
 
2178
- describe('inherits()', function () {
2201
+ describe('inherits()', function () {
2179
2202
 
2180
- it('exists', function (done) {
2203
+ it('exists', function (done) {
2181
2204
 
2182
2205
  expect(Hoek.inherits).to.exist();
2183
2206
  expect(typeof Hoek.inherits).to.equal('function');
2184
- done();
2185
- });
2207
+ done();
2208
+ });
2186
2209
  });
2187
2210
 
2188
- describe('format()', function () {
2211
+ describe('format()', function () {
2189
2212
 
2190
- it('exists', function (done) {
2213
+ it('exists', function (done) {
2191
2214
 
2192
2215
  expect(Hoek.format).to.exist();
2193
2216
  expect(typeof Hoek.format).to.equal('function');
2194
- done();
2217
+ done();
2195
2218
  });
2196
2219
 
2197
- it('is a reference to Util.format', function (done) {
2220
+ it('is a reference to Util.format', function (done) {
2198
2221
 
2199
2222
  expect(Hoek.format('hello %s', 'world')).to.equal('hello world');
2200
- done();
2201
- });
2223
+ done();
2224
+ });
2202
2225
  });
2203
2226
 
2204
- describe('transform()', function () {
2227
+ describe('transform()', function () {
2205
2228
 
2206
- var source = {
2207
- address: {
2229
+ var source = {
2230
+ address: {
2208
2231
  one: '123 main street',
2209
- two: 'PO Box 1234'
2232
+ two: 'PO Box 1234'
2210
2233
  },
2211
- zip: {
2234
+ zip: {
2212
2235
  code: 3321232,
2213
- province: null
2236
+ province: null
2214
2237
  },
2215
2238
  title: 'Warehouse',
2216
- state: 'CA'
2239
+ state: 'CA'
2217
2240
  };
2218
2241
 
2219
- it('transforms an object based on the input object', function (done) {
2242
+ var sourcesArray = [{
2243
+ address: {
2244
+ one: '123 main street',
2245
+ two: 'PO Box 1234'
2246
+ },
2247
+ zip: {
2248
+ code: 3321232,
2249
+ province: null
2250
+ },
2251
+ title: 'Warehouse',
2252
+ state: 'CA'
2253
+ }, {
2254
+ address: {
2255
+ one: '456 market street',
2256
+ two: 'PO Box 5678'
2257
+ },
2258
+ zip: {
2259
+ code: 9876,
2260
+ province: null
2261
+ },
2262
+ title: 'Garage',
2263
+ state: 'NY'
2264
+ }];
2265
+
2266
+ it('transforms an object based on the input object', function (done) {
2220
2267
 
2221
- var result = Hoek.transform(source, {
2268
+ var result = Hoek.transform(source, {
2222
2269
  'person.address.lineOne': 'address.one',
2223
2270
  'person.address.lineTwo': 'address.two',
2224
2271
  'title': 'title',
2225
2272
  'person.address.region': 'state',
2226
2273
  'person.address.zip': 'zip.code',
2227
- 'person.address.location': 'zip.province'
2274
+ 'person.address.location': 'zip.province'
2228
2275
  });
2229
2276
 
2230
- expect(result).to.deep.equal({
2231
- person: {
2232
- address: {
2277
+ expect(result).to.deep.equal({
2278
+ person: {
2279
+ address: {
2233
2280
  lineOne: '123 main street',
2234
2281
  lineTwo: 'PO Box 1234',
2235
2282
  region: 'CA',
2236
2283
  zip: 3321232,
2237
- location: null
2238
- }
2284
+ location: null
2285
+ }
2239
2286
  },
2240
- title: 'Warehouse'
2287
+ title: 'Warehouse'
2288
+ });
2289
+
2290
+ done();
2291
+ });
2292
+
2293
+ it('transforms an array of objects based on the input object', function (done) {
2294
+
2295
+ var result = Hoek.transform(sourcesArray, {
2296
+ 'person.address.lineOne': 'address.one',
2297
+ 'person.address.lineTwo': 'address.two',
2298
+ 'title': 'title',
2299
+ 'person.address.region': 'state',
2300
+ 'person.address.zip': 'zip.code',
2301
+ 'person.address.location': 'zip.province'
2241
2302
  });
2242
2303
 
2243
- done();
2304
+ expect(result).to.deep.equal([
2305
+ {
2306
+ person: {
2307
+ address: {
2308
+ lineOne: '123 main street',
2309
+ lineTwo: 'PO Box 1234',
2310
+ region: 'CA',
2311
+ zip: 3321232,
2312
+ location: null
2313
+ }
2314
+ },
2315
+ title: 'Warehouse'
2316
+ },
2317
+ {
2318
+ person: {
2319
+ address: {
2320
+ lineOne: '456 market street',
2321
+ lineTwo: 'PO Box 5678',
2322
+ region: 'NY',
2323
+ zip: 9876,
2324
+ location: null
2325
+ }
2326
+ },
2327
+ title: 'Garage'
2328
+ }
2329
+ ]);
2330
+
2331
+ done();
2244
2332
  });
2245
2333
 
2246
- it('uses the reach options passed into it', function (done) {
2334
+ it('uses the reach options passed into it', function (done) {
2247
2335
 
2248
- var schema = {
2336
+ var schema = {
2249
2337
  'person.address.lineOne': 'address-one',
2250
2338
  'person.address.lineTwo': 'address-two',
2251
2339
  'title': 'title',
2252
2340
  'person.address.region': 'state',
2253
2341
  'person.prefix': 'person-title',
2254
- 'person.zip': 'zip-code'
2342
+ 'person.zip': 'zip-code'
2255
2343
  };
2256
- var options = {
2344
+ var options = {
2257
2345
  separator: '-',
2258
- default: 'unknown'
2346
+ default: 'unknown'
2259
2347
  };
2260
2348
  var result = Hoek.transform(source, schema, options);
2261
2349
 
2262
- expect(result).to.deep.equal({
2263
- person: {
2264
- address: {
2350
+ expect(result).to.deep.equal({
2351
+ person: {
2352
+ address: {
2265
2353
  lineOne: '123 main street',
2266
2354
  lineTwo: 'PO Box 1234',
2267
- region: 'CA'
2355
+ region: 'CA'
2268
2356
  },
2269
2357
  prefix: 'unknown',
2270
- zip: 3321232
2358
+ zip: 3321232
2271
2359
  },
2272
- title: 'Warehouse'
2360
+ title: 'Warehouse'
2273
2361
  });
2274
2362
 
2275
- done();
2363
+ done();
2276
2364
  });
2277
2365
 
2278
- it('works to create shallow objects', function (done) {
2366
+ it('works to create shallow objects', function (done) {
2279
2367
 
2280
- var result = Hoek.transform(source, {
2368
+ var result = Hoek.transform(source, {
2281
2369
  lineOne: 'address.one',
2282
2370
  lineTwo: 'address.two',
2283
2371
  title: 'title',
2284
2372
  region: 'state',
2285
- province: 'zip.province'
2373
+ province: 'zip.province'
2286
2374
  });
2287
2375
 
2288
- expect(result).to.deep.equal({
2376
+ expect(result).to.deep.equal({
2289
2377
  lineOne: '123 main street',
2290
2378
  lineTwo: 'PO Box 1234',
2291
2379
  title: 'Warehouse',
2292
2380
  region: 'CA',
2293
- province: null
2381
+ province: null
2294
2382
  });
2295
2383
 
2296
- done();
2384
+ done();
2297
2385
  });
2298
2386
 
2299
- it('only allows strings in the map', function (done) {
2387
+ it('only allows strings in the map', function (done) {
2300
2388
 
2301
2389
  expect(function () {
2302
2390
 
@@ -2305,121 +2393,121 @@ describe('transform()', function () {
2305
2393
  });
2306
2394
  }).to.throw('All mappings must be "." delineated strings');
2307
2395
 
2308
- done();
2396
+ done();
2309
2397
  });
2310
2398
 
2311
- it('throws an error on invalid arguments', function (done) {
2399
+ it('throws an error on invalid arguments', function (done) {
2312
2400
 
2313
- expect(function () {
2401
+ expect(function () {
2314
2402
 
2315
- var result = Hoek.transform(NaN, {});
2316
- }).to.throw('Invalid source object: must be null, undefined, or an object');
2403
+ var result = Hoek.transform(NaN, {});
2404
+ }).to.throw('Invalid source object: must be null, undefined, an object, or an array');
2317
2405
 
2318
- done();
2406
+ done();
2319
2407
  });
2320
2408
 
2321
- it('is safe to pass null', function (done) {
2409
+ it('is safe to pass null', function (done) {
2322
2410
 
2323
2411
  var result = Hoek.transform(null, {});
2324
2412
  expect(result).to.deep.equal({});
2325
2413
 
2326
- done();
2414
+ done();
2327
2415
  });
2328
2416
 
2329
- it('is safe to pass undefined', function (done) {
2417
+ it('is safe to pass undefined', function (done) {
2330
2418
 
2331
2419
  var result = Hoek.transform(undefined, {});
2332
2420
  expect(result).to.deep.equal({});
2333
2421
 
2334
- done();
2335
- });
2422
+ done();
2423
+ });
2336
2424
  });
2337
2425
 
2338
- describe('uniqueFilename()', function () {
2426
+ describe('uniqueFilename()', function () {
2339
2427
 
2340
- it('generates a random file path', function (done) {
2428
+ it('generates a random file path', function (done) {
2341
2429
 
2342
2430
  var result = Hoek.uniqueFilename('./test/modules');
2343
2431
 
2344
2432
  expect(result).to.exist();
2345
2433
  expect(result).to.be.a.string();
2346
2434
  expect(result).to.contain('test/modules');
2347
- done();
2435
+ done();
2348
2436
  });
2349
2437
 
2350
- it('is random enough to use in fast loops', function (done) {
2438
+ it('is random enough to use in fast loops', function (done) {
2351
2439
 
2352
2440
  var results = [];
2353
2441
 
2354
- for (var i = 0; i < 10; ++i) {
2355
- results[i] = Hoek.uniqueFilename('./test/modules');
2442
+ for (var i = 0; i < 10; ++i) {
2443
+ results[i] = Hoek.uniqueFilename('./test/modules');
2356
2444
  }
2357
2445
 
2358
- var filter = results.filter(function (item, index, array) {
2446
+ var filter = results.filter(function (item, index, array) {
2359
2447
 
2360
- return array.indexOf(item) === index;
2448
+ return array.indexOf(item) === index;
2361
2449
  });
2362
2450
 
2363
2451
  expect(filter.length).to.equal(10);
2364
2452
  expect(results.length).to.equal(10);
2365
- done();
2453
+ done();
2366
2454
 
2367
2455
  });
2368
2456
 
2369
- it('combines the random elements with a supplied character', function (done) {
2457
+ it('combines the random elements with a supplied character', function (done) {
2370
2458
 
2371
2459
  var result = Hoek.uniqueFilename('./test', 'txt');
2372
2460
 
2373
2461
  expect(result).to.contain('test/');
2374
2462
  expect(result).to.contain('.txt');
2375
2463
 
2376
- done();
2464
+ done();
2377
2465
  });
2378
2466
 
2379
- it('accepts extensions with a "." in it', function (done) {
2467
+ it('accepts extensions with a "." in it', function (done) {
2380
2468
 
2381
2469
  var result = Hoek.uniqueFilename('./test', '.mp3');
2382
2470
 
2383
2471
  expect(result).to.contain('test/');
2384
2472
  expect(result).to.contain('.mp3');
2385
2473
 
2386
- done();
2387
- });
2474
+ done();
2475
+ });
2388
2476
  });
2389
2477
 
2390
- describe('stringify()', function (done) {
2478
+ describe('stringify()', function (done) {
2391
2479
 
2392
- it('converts object to string', function (done) {
2480
+ it('converts object to string', function (done) {
2393
2481
 
2394
2482
  var obj = { a: 1 };
2395
2483
  expect(Hoek.stringify(obj)).to.equal('{"a":1}');
2396
- done();
2484
+ done();
2397
2485
  });
2398
2486
 
2399
- it('returns error in result string', function (done) {
2487
+ it('returns error in result string', function (done) {
2400
2488
 
2401
2489
  var obj = { a: 1 };
2402
2490
  obj.b = obj;
2403
2491
  expect(Hoek.stringify(obj)).to.equal('[Cannot display object: Converting circular structure to JSON]');
2404
- done();
2405
- });
2492
+ done();
2493
+ });
2406
2494
  });
2407
2495
 
2408
- describe('shallow()', function (done) {
2496
+ describe('shallow()', function (done) {
2409
2497
 
2410
- it('shallow copies an object', function (done) {
2498
+ it('shallow copies an object', function (done) {
2411
2499
 
2412
- var obj = {
2500
+ var obj = {
2413
2501
  a: 5,
2414
- b: {
2415
- c: 6
2416
- }
2502
+ b: {
2503
+ c: 6
2504
+ }
2417
2505
  };
2418
2506
 
2419
2507
  var shallow = Hoek.shallow(obj);
2420
2508
  expect(shallow).to.not.equal(obj);
2421
2509
  expect(shallow).to.deep.equal(obj);
2422
2510
  expect(shallow.b).to.equal(obj.b);
2423
- done();
2424
- });
2511
+ done();
2512
+ });
2425
2513
  });