holmes 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/README.md +10 -0
- data/Rakefile +1 -0
- data/holmes.gemspec +24 -0
- data/lib/holmes.rb +38 -0
- data/lib/holmes/node_modules/detective/README.markdown +64 -0
- data/lib/holmes/node_modules/detective/example/strings.js +6 -0
- data/lib/holmes/node_modules/detective/example/strings_src.js +3 -0
- data/lib/holmes/node_modules/detective/index.js +65 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/.npmignore +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/README.markdown +185 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/browserify.js +4296 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/example/microwave.js +7 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/example/web/bs.js +4832 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/example/web/index.html +14 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/example/web/main.js +17 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/example/web/server.js +12 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/example/wrap.js +7 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/index.html +8 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/index.js +208 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/main.js +11 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/.bin/uglifyjs +317 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/.npmignore +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/LICENSE +24 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/README.markdown +237 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/examples/json.js +16 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/examples/leaves.js +15 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/examples/negative.js +8 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/examples/scrub.js +10 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/examples/stringify.js +38 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/index.js +267 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/main.js +10 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/package.json +18 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/test/circular.js +115 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/test/date.js +35 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/test/equal.js +220 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/test/instance.js +17 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/test/interface.js +42 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/test/json.js +47 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/test/keys.js +29 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/test/leaves.js +21 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/test/lib/deep_equal.js +92 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/test/mutability.js +252 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/test/negative.js +20 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/test/obj.js +15 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/test/siblings.js +35 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/test/stop.js +41 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/test/stringify.js +36 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/test/subexpr.js +34 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/test/super_deep.js +55 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/.npmignore +4 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/README.html +888 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/README.org +463 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/bin/uglifyjs +317 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/docstyle.css +75 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/lib/object-ast.js +75 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/lib/parse-js.js +1341 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/lib/process.js +1949 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/lib/squeeze-more.js +51 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/package.json +22 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/beautify.js +28 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/testparser.js +402 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/array1.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/array2.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/array3.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/array4.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/assignment.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/concatstring.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/const.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/empty-blocks.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/forstatement.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/if.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/ifreturn.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/ifreturn2.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue10.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue11.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue13.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue14.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue16.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue17.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue20.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue21.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue25.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue27.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue28.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue29.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue30.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue34.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue4.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue48.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue50.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue53.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue54.1.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue68.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue69.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue9.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/mangle.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/strict-equals.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/var.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/with.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/array1.js +3 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/array2.js +4 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/array3.js +4 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/array4.js +6 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/assignment.js +20 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/concatstring.js +3 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/const.js +5 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/empty-blocks.js +4 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/forstatement.js +10 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/if.js +6 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/ifreturn.js +9 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/ifreturn2.js +16 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue10.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue11.js +3 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue13.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue14.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue16.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue17.js +4 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue20.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue21.js +6 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue25.js +7 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue27.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue28.js +3 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue29.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue30.js +3 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue34.js +3 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue4.js +3 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue48.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue50.js +9 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue53.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue54.1.js +3 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue68.js +5 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue69.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue9.js +4 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/mangle.js +5 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/strict-equals.js +3 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/var.js +3 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/with.js +2 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/scripts.js +55 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/tmp/hoist.js +33 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/tmp/instrument.js +97 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/tmp/instrument2.js +138 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/tmp/test.js +16 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/uglify-js.js +17 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/package.json +43 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/server.js +4 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/test/ast.js +29 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/test/err.js +47 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/test/fail.js +8 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/test/fail/src.js +60 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/test/label.js +110 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/test/microwave.js +33 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/test/parent.js +26 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/test/wrap.js +157 -0
- data/lib/holmes/node_modules/detective/package.json +39 -0
- data/lib/holmes/node_modules/detective/test/both.js +10 -0
- data/lib/holmes/node_modules/detective/test/files/both.js +4 -0
- data/lib/holmes/node_modules/detective/test/files/nested.js +22 -0
- data/lib/holmes/node_modules/detective/test/files/strings.js +13 -0
- data/lib/holmes/node_modules/detective/test/files/word.js +13 -0
- data/lib/holmes/node_modules/detective/test/nested.js +8 -0
- data/lib/holmes/node_modules/detective/test/strings.js +8 -0
- data/lib/holmes/node_modules/detective/test/word.js +11 -0
- data/lib/holmes/require.js +5 -0
- data/lib/holmes/runner.js +20 -0
- data/lib/holmes/version.rb +3 -0
- metadata +223 -0
data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/test/json.js
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
var assert = require('assert');
|
2
|
+
var Traverse = require('../');
|
3
|
+
|
4
|
+
exports['json test'] = function () {
|
5
|
+
var id = 54;
|
6
|
+
var callbacks = {};
|
7
|
+
var obj = { moo : function () {}, foo : [2,3,4, function () {}] };
|
8
|
+
|
9
|
+
var scrubbed = Traverse(obj).map(function (x) {
|
10
|
+
if (typeof x === 'function') {
|
11
|
+
callbacks[id] = { id : id, f : x, path : this.path };
|
12
|
+
this.update('[Function]');
|
13
|
+
id++;
|
14
|
+
}
|
15
|
+
});
|
16
|
+
|
17
|
+
assert.equal(
|
18
|
+
scrubbed.moo, '[Function]',
|
19
|
+
'obj.moo replaced with "[Function]"'
|
20
|
+
);
|
21
|
+
|
22
|
+
assert.equal(
|
23
|
+
scrubbed.foo[3], '[Function]',
|
24
|
+
'obj.foo[3] replaced with "[Function]"'
|
25
|
+
);
|
26
|
+
|
27
|
+
assert.deepEqual(scrubbed, {
|
28
|
+
moo : '[Function]',
|
29
|
+
foo : [ 2, 3, 4, "[Function]" ]
|
30
|
+
}, 'Full JSON string matches');
|
31
|
+
|
32
|
+
assert.deepEqual(
|
33
|
+
typeof obj.moo, 'function',
|
34
|
+
'Original obj.moo still a function'
|
35
|
+
);
|
36
|
+
|
37
|
+
assert.deepEqual(
|
38
|
+
typeof obj.foo[3], 'function',
|
39
|
+
'Original obj.foo[3] still a function'
|
40
|
+
);
|
41
|
+
|
42
|
+
assert.deepEqual(callbacks, {
|
43
|
+
54: { id: 54, f : obj.moo, path: [ 'moo' ] },
|
44
|
+
55: { id: 55, f : obj.foo[3], path: [ 'foo', '3' ] },
|
45
|
+
}, 'Check the generated callbacks list');
|
46
|
+
};
|
47
|
+
|
data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/test/keys.js
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
var assert = require('assert');
|
2
|
+
var Traverse = require('../');
|
3
|
+
|
4
|
+
exports['sort test'] = function () {
|
5
|
+
var acc = [];
|
6
|
+
Traverse({
|
7
|
+
a: 30,
|
8
|
+
b: 22,
|
9
|
+
id: 9
|
10
|
+
}).forEach(function (node) {
|
11
|
+
if ((! Array.isArray(node)) && typeof node === 'object') {
|
12
|
+
this.before(function(node) {
|
13
|
+
this.keys = Object.keys(node);
|
14
|
+
this.keys.sort(function(a, b) {
|
15
|
+
a = [a === "id" ? 0 : 1, a];
|
16
|
+
b = [b === "id" ? 0 : 1, b];
|
17
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
18
|
+
});
|
19
|
+
});
|
20
|
+
}
|
21
|
+
if (this.isLeaf) acc.push(node);
|
22
|
+
});
|
23
|
+
|
24
|
+
assert.equal(
|
25
|
+
acc.join(' '),
|
26
|
+
'9 30 22',
|
27
|
+
'Traversal in a custom order'
|
28
|
+
);
|
29
|
+
};
|
data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/test/leaves.js
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
var assert = require('assert');
|
2
|
+
var Traverse = require('../');
|
3
|
+
|
4
|
+
exports['leaves test'] = function () {
|
5
|
+
var acc = [];
|
6
|
+
Traverse({
|
7
|
+
a : [1,2,3],
|
8
|
+
b : 4,
|
9
|
+
c : [5,6],
|
10
|
+
d : { e : [7,8], f : 9 }
|
11
|
+
}).forEach(function (x) {
|
12
|
+
if (this.isLeaf) acc.push(x);
|
13
|
+
});
|
14
|
+
|
15
|
+
assert.equal(
|
16
|
+
acc.join(' '),
|
17
|
+
'1 2 3 4 5 6 7 8 9',
|
18
|
+
'Traversal in the right(?) order'
|
19
|
+
);
|
20
|
+
};
|
21
|
+
|
@@ -0,0 +1,92 @@
|
|
1
|
+
var traverse = require('../../');
|
2
|
+
|
3
|
+
module.exports = function (a, b) {
|
4
|
+
if (arguments.length !== 2) {
|
5
|
+
throw new Error(
|
6
|
+
'deepEqual requires exactly two objects to compare against'
|
7
|
+
);
|
8
|
+
}
|
9
|
+
|
10
|
+
var equal = true;
|
11
|
+
var node = b;
|
12
|
+
|
13
|
+
traverse(a).forEach(function (y) {
|
14
|
+
var notEqual = (function () {
|
15
|
+
equal = false;
|
16
|
+
//this.stop();
|
17
|
+
return undefined;
|
18
|
+
}).bind(this);
|
19
|
+
|
20
|
+
//if (node === undefined || node === null) return notEqual();
|
21
|
+
|
22
|
+
if (!this.isRoot) {
|
23
|
+
/*
|
24
|
+
if (!Object.hasOwnProperty.call(node, this.key)) {
|
25
|
+
return notEqual();
|
26
|
+
}
|
27
|
+
*/
|
28
|
+
if (typeof node !== 'object') return notEqual();
|
29
|
+
node = node[this.key];
|
30
|
+
}
|
31
|
+
|
32
|
+
var x = node;
|
33
|
+
|
34
|
+
this.post(function () {
|
35
|
+
node = x;
|
36
|
+
});
|
37
|
+
|
38
|
+
var toS = function (o) {
|
39
|
+
return Object.prototype.toString.call(o);
|
40
|
+
};
|
41
|
+
|
42
|
+
if (this.circular) {
|
43
|
+
if (traverse(b).get(this.circular.path) !== x) notEqual();
|
44
|
+
}
|
45
|
+
else if (typeof x !== typeof y) {
|
46
|
+
notEqual();
|
47
|
+
}
|
48
|
+
else if (x === null || y === null || x === undefined || y === undefined) {
|
49
|
+
if (x !== y) notEqual();
|
50
|
+
}
|
51
|
+
else if (x.__proto__ !== y.__proto__) {
|
52
|
+
notEqual();
|
53
|
+
}
|
54
|
+
else if (x === y) {
|
55
|
+
// nop
|
56
|
+
}
|
57
|
+
else if (typeof x === 'function') {
|
58
|
+
if (x instanceof RegExp) {
|
59
|
+
// both regexps on account of the __proto__ check
|
60
|
+
if (x.toString() != y.toString()) notEqual();
|
61
|
+
}
|
62
|
+
else if (x !== y) notEqual();
|
63
|
+
}
|
64
|
+
else if (typeof x === 'object') {
|
65
|
+
if (toS(y) === '[object Arguments]'
|
66
|
+
|| toS(x) === '[object Arguments]') {
|
67
|
+
if (toS(x) !== toS(y)) {
|
68
|
+
notEqual();
|
69
|
+
}
|
70
|
+
}
|
71
|
+
else if (x instanceof Date || y instanceof Date) {
|
72
|
+
if (!(x instanceof Date) || !(y instanceof Date)
|
73
|
+
|| x.getTime() !== y.getTime()) {
|
74
|
+
notEqual();
|
75
|
+
}
|
76
|
+
}
|
77
|
+
else {
|
78
|
+
var kx = Object.keys(x);
|
79
|
+
var ky = Object.keys(y);
|
80
|
+
if (kx.length !== ky.length) return notEqual();
|
81
|
+
for (var i = 0; i < kx.length; i++) {
|
82
|
+
var k = kx[i];
|
83
|
+
if (!Object.hasOwnProperty.call(y, k)) {
|
84
|
+
notEqual();
|
85
|
+
}
|
86
|
+
}
|
87
|
+
}
|
88
|
+
}
|
89
|
+
});
|
90
|
+
|
91
|
+
return equal;
|
92
|
+
};
|
data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/test/mutability.js
ADDED
@@ -0,0 +1,252 @@
|
|
1
|
+
var assert = require('assert');
|
2
|
+
var Traverse = require('../');
|
3
|
+
var deepEqual = require('./lib/deep_equal');
|
4
|
+
|
5
|
+
exports.mutate = function () {
|
6
|
+
var obj = { a : 1, b : 2, c : [ 3, 4 ] };
|
7
|
+
var res = Traverse(obj).forEach(function (x) {
|
8
|
+
if (typeof x === 'number' && x % 2 === 0) {
|
9
|
+
this.update(x * 10);
|
10
|
+
}
|
11
|
+
});
|
12
|
+
assert.deepEqual(obj, res);
|
13
|
+
assert.deepEqual(obj, { a : 1, b : 20, c : [ 3, 40 ] });
|
14
|
+
};
|
15
|
+
|
16
|
+
exports.mutateT = function () {
|
17
|
+
var obj = { a : 1, b : 2, c : [ 3, 4 ] };
|
18
|
+
var res = Traverse.forEach(obj, function (x) {
|
19
|
+
if (typeof x === 'number' && x % 2 === 0) {
|
20
|
+
this.update(x * 10);
|
21
|
+
}
|
22
|
+
});
|
23
|
+
assert.deepEqual(obj, res);
|
24
|
+
assert.deepEqual(obj, { a : 1, b : 20, c : [ 3, 40 ] });
|
25
|
+
};
|
26
|
+
|
27
|
+
exports.map = function () {
|
28
|
+
var obj = { a : 1, b : 2, c : [ 3, 4 ] };
|
29
|
+
var res = Traverse(obj).map(function (x) {
|
30
|
+
if (typeof x === 'number' && x % 2 === 0) {
|
31
|
+
this.update(x * 10);
|
32
|
+
}
|
33
|
+
});
|
34
|
+
assert.deepEqual(obj, { a : 1, b : 2, c : [ 3, 4 ] });
|
35
|
+
assert.deepEqual(res, { a : 1, b : 20, c : [ 3, 40 ] });
|
36
|
+
};
|
37
|
+
|
38
|
+
exports.mapT = function () {
|
39
|
+
var obj = { a : 1, b : 2, c : [ 3, 4 ] };
|
40
|
+
var res = Traverse.map(obj, function (x) {
|
41
|
+
if (typeof x === 'number' && x % 2 === 0) {
|
42
|
+
this.update(x * 10);
|
43
|
+
}
|
44
|
+
});
|
45
|
+
assert.deepEqual(obj, { a : 1, b : 2, c : [ 3, 4 ] });
|
46
|
+
assert.deepEqual(res, { a : 1, b : 20, c : [ 3, 40 ] });
|
47
|
+
};
|
48
|
+
|
49
|
+
exports.clone = function () {
|
50
|
+
var obj = { a : 1, b : 2, c : [ 3, 4 ] };
|
51
|
+
var res = Traverse(obj).clone();
|
52
|
+
assert.deepEqual(obj, res);
|
53
|
+
assert.ok(obj !== res);
|
54
|
+
obj.a ++;
|
55
|
+
assert.deepEqual(res.a, 1);
|
56
|
+
obj.c.push(5);
|
57
|
+
assert.deepEqual(res.c, [ 3, 4 ]);
|
58
|
+
};
|
59
|
+
|
60
|
+
exports.cloneT = function () {
|
61
|
+
var obj = { a : 1, b : 2, c : [ 3, 4 ] };
|
62
|
+
var res = Traverse.clone(obj);
|
63
|
+
assert.deepEqual(obj, res);
|
64
|
+
assert.ok(obj !== res);
|
65
|
+
obj.a ++;
|
66
|
+
assert.deepEqual(res.a, 1);
|
67
|
+
obj.c.push(5);
|
68
|
+
assert.deepEqual(res.c, [ 3, 4 ]);
|
69
|
+
};
|
70
|
+
|
71
|
+
exports.reduce = function () {
|
72
|
+
var obj = { a : 1, b : 2, c : [ 3, 4 ] };
|
73
|
+
var res = Traverse(obj).reduce(function (acc, x) {
|
74
|
+
if (this.isLeaf) acc.push(x);
|
75
|
+
return acc;
|
76
|
+
}, []);
|
77
|
+
assert.deepEqual(obj, { a : 1, b : 2, c : [ 3, 4 ] });
|
78
|
+
assert.deepEqual(res, [ 1, 2, 3, 4 ]);
|
79
|
+
};
|
80
|
+
|
81
|
+
exports.reduceInit = function () {
|
82
|
+
var obj = { a : 1, b : 2, c : [ 3, 4 ] };
|
83
|
+
var res = Traverse(obj).reduce(function (acc, x) {
|
84
|
+
if (this.isRoot) assert.fail('got root');
|
85
|
+
return acc;
|
86
|
+
});
|
87
|
+
assert.deepEqual(obj, { a : 1, b : 2, c : [ 3, 4 ] });
|
88
|
+
assert.deepEqual(res, obj);
|
89
|
+
};
|
90
|
+
|
91
|
+
exports.remove = function () {
|
92
|
+
var obj = { a : 1, b : 2, c : [ 3, 4 ] };
|
93
|
+
Traverse(obj).forEach(function (x) {
|
94
|
+
if (this.isLeaf && x % 2 == 0) this.remove();
|
95
|
+
});
|
96
|
+
|
97
|
+
assert.deepEqual(obj, { a : 1, c : [ 3 ] });
|
98
|
+
};
|
99
|
+
|
100
|
+
exports.removeNoStop = function() {
|
101
|
+
var obj = { a : 1, b : 2, c : { d: 3, e: 4 }, f: 5 };
|
102
|
+
|
103
|
+
var keys = [];
|
104
|
+
Traverse(obj).forEach(function (x) {
|
105
|
+
keys.push(this.key)
|
106
|
+
if (this.key == 'c') this.remove();
|
107
|
+
});
|
108
|
+
|
109
|
+
assert.deepEqual(keys, [undefined, 'a', 'b', 'c', 'd', 'e', 'f'])
|
110
|
+
}
|
111
|
+
|
112
|
+
exports.removeStop = function() {
|
113
|
+
var obj = { a : 1, b : 2, c : { d: 3, e: 4 }, f: 5 };
|
114
|
+
|
115
|
+
var keys = [];
|
116
|
+
Traverse(obj).forEach(function (x) {
|
117
|
+
keys.push(this.key)
|
118
|
+
if (this.key == 'c') this.remove(true);
|
119
|
+
});
|
120
|
+
|
121
|
+
assert.deepEqual(keys, [undefined, 'a', 'b', 'c', 'f'])
|
122
|
+
}
|
123
|
+
|
124
|
+
exports.removeMap = function () {
|
125
|
+
var obj = { a : 1, b : 2, c : [ 3, 4 ] };
|
126
|
+
var res = Traverse(obj).map(function (x) {
|
127
|
+
if (this.isLeaf && x % 2 == 0) this.remove();
|
128
|
+
});
|
129
|
+
|
130
|
+
assert.deepEqual(obj, { a : 1, b : 2, c : [ 3, 4 ] });
|
131
|
+
assert.deepEqual(res, { a : 1, c : [ 3 ] });
|
132
|
+
};
|
133
|
+
|
134
|
+
exports.delete = function () {
|
135
|
+
var obj = { a : 1, b : 2, c : [ 3, 4 ] };
|
136
|
+
Traverse(obj).forEach(function (x) {
|
137
|
+
if (this.isLeaf && x % 2 == 0) this.delete();
|
138
|
+
});
|
139
|
+
|
140
|
+
assert.ok(!deepEqual(
|
141
|
+
obj, { a : 1, c : [ 3, undefined ] }
|
142
|
+
));
|
143
|
+
|
144
|
+
assert.ok(deepEqual(
|
145
|
+
obj, { a : 1, c : [ 3 ] }
|
146
|
+
));
|
147
|
+
|
148
|
+
assert.ok(!deepEqual(
|
149
|
+
obj, { a : 1, c : [ 3, null ] }
|
150
|
+
));
|
151
|
+
};
|
152
|
+
|
153
|
+
exports.deleteNoStop = function() {
|
154
|
+
var obj = { a : 1, b : 2, c : { d: 3, e: 4 } };
|
155
|
+
|
156
|
+
var keys = [];
|
157
|
+
Traverse(obj).forEach(function (x) {
|
158
|
+
keys.push(this.key)
|
159
|
+
if (this.key == 'c') this.delete();
|
160
|
+
});
|
161
|
+
|
162
|
+
assert.deepEqual(keys, [undefined, 'a', 'b', 'c', 'd', 'e'])
|
163
|
+
}
|
164
|
+
|
165
|
+
exports.deleteStop = function() {
|
166
|
+
var obj = { a : 1, b : 2, c : { d: 3, e: 4 } };
|
167
|
+
|
168
|
+
var keys = [];
|
169
|
+
Traverse(obj).forEach(function (x) {
|
170
|
+
keys.push(this.key)
|
171
|
+
if (this.key == 'c') this.delete(true);
|
172
|
+
});
|
173
|
+
|
174
|
+
assert.deepEqual(keys, [undefined, 'a', 'b', 'c'])
|
175
|
+
}
|
176
|
+
|
177
|
+
exports.deleteRedux = function () {
|
178
|
+
var obj = { a : 1, b : 2, c : [ 3, 4, 5 ] };
|
179
|
+
Traverse(obj).forEach(function (x) {
|
180
|
+
if (this.isLeaf && x % 2 == 0) this.delete();
|
181
|
+
});
|
182
|
+
|
183
|
+
assert.ok(!deepEqual(
|
184
|
+
obj, { a : 1, c : [ 3, undefined, 5 ] }
|
185
|
+
));
|
186
|
+
|
187
|
+
assert.ok(deepEqual(
|
188
|
+
obj, { a : 1, c : [ 3 ,, 5 ] }
|
189
|
+
));
|
190
|
+
|
191
|
+
assert.ok(!deepEqual(
|
192
|
+
obj, { a : 1, c : [ 3, null, 5 ] }
|
193
|
+
));
|
194
|
+
|
195
|
+
assert.ok(!deepEqual(
|
196
|
+
obj, { a : 1, c : [ 3, 5 ] }
|
197
|
+
));
|
198
|
+
};
|
199
|
+
|
200
|
+
exports.deleteMap = function () {
|
201
|
+
var obj = { a : 1, b : 2, c : [ 3, 4 ] };
|
202
|
+
var res = Traverse(obj).map(function (x) {
|
203
|
+
if (this.isLeaf && x % 2 == 0) this.delete();
|
204
|
+
});
|
205
|
+
|
206
|
+
assert.ok(deepEqual(
|
207
|
+
obj,
|
208
|
+
{ a : 1, b : 2, c : [ 3, 4 ] }
|
209
|
+
));
|
210
|
+
|
211
|
+
var xs = [ 3, 4 ];
|
212
|
+
delete xs[1];
|
213
|
+
|
214
|
+
assert.ok(deepEqual(
|
215
|
+
res, { a : 1, c : xs }
|
216
|
+
));
|
217
|
+
|
218
|
+
assert.ok(deepEqual(
|
219
|
+
res, { a : 1, c : [ 3, ] }
|
220
|
+
));
|
221
|
+
|
222
|
+
assert.ok(deepEqual(
|
223
|
+
res, { a : 1, c : [ 3 ] }
|
224
|
+
));
|
225
|
+
};
|
226
|
+
|
227
|
+
exports.deleteMapRedux = function () {
|
228
|
+
var obj = { a : 1, b : 2, c : [ 3, 4, 5 ] };
|
229
|
+
var res = Traverse(obj).map(function (x) {
|
230
|
+
if (this.isLeaf && x % 2 == 0) this.delete();
|
231
|
+
});
|
232
|
+
|
233
|
+
assert.ok(deepEqual(
|
234
|
+
obj,
|
235
|
+
{ a : 1, b : 2, c : [ 3, 4, 5 ] }
|
236
|
+
));
|
237
|
+
|
238
|
+
var xs = [ 3, 4, 5 ];
|
239
|
+
delete xs[1];
|
240
|
+
|
241
|
+
assert.ok(deepEqual(
|
242
|
+
res, { a : 1, c : xs }
|
243
|
+
));
|
244
|
+
|
245
|
+
assert.ok(!deepEqual(
|
246
|
+
res, { a : 1, c : [ 3, 5 ] }
|
247
|
+
));
|
248
|
+
|
249
|
+
assert.ok(deepEqual(
|
250
|
+
res, { a : 1, c : [ 3 ,, 5 ] }
|
251
|
+
));
|
252
|
+
};
|
data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/test/negative.js
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
var Traverse = require('../');
|
2
|
+
var assert = require('assert');
|
3
|
+
|
4
|
+
exports['negative update test'] = function () {
|
5
|
+
var obj = [ 5, 6, -3, [ 7, 8, -2, 1 ], { f : 10, g : -13 } ];
|
6
|
+
var fixed = Traverse.map(obj, function (x) {
|
7
|
+
if (x < 0) this.update(x + 128);
|
8
|
+
});
|
9
|
+
|
10
|
+
assert.deepEqual(fixed,
|
11
|
+
[ 5, 6, 125, [ 7, 8, 126, 1 ], { f: 10, g: 115 } ],
|
12
|
+
'Negative values += 128'
|
13
|
+
);
|
14
|
+
|
15
|
+
assert.deepEqual(obj,
|
16
|
+
[ 5, 6, -3, [ 7, 8, -2, 1 ], { f: 10, g: -13 } ],
|
17
|
+
'Original references not modified'
|
18
|
+
);
|
19
|
+
}
|
20
|
+
|