Package: groovebasin / 1.4.0-1

bundle-curlydiff-module.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
Description: bundle curlydiff module
 FTP masters would reject node-curlydiff on the account of it being too small,
 so we bundle the module here.
Author: Andrew Kelley <superjoe30@gmail.com>
Forwarded: not-needed

--- /dev/null
+++ groovebasin-1.3.0/node_modules/curlydiff/index.js
@@ -0,0 +1,62 @@
+module.exports.diff = diff;
+module.exports.apply = apply;
+module.exports.isObject = isObject;
+
+function diff(from, to) {
+  if (!isObject(from) || !isObject(to)) {
+    // not both objects
+    if (from === to) return undefined;
+    if (from instanceof Date && to instanceof Date && from.getTime() === to.getTime()) return undefined;
+    // there's a difference
+    return to;
+  }
+  // both are objects
+  var result = {};
+  var anythingChanged = false;
+  for (var key in from) {
+    var childDiff;
+    if (key in to) {
+      childDiff = diff(from[key], to[key]);
+      if (childDiff === undefined) continue;
+    } else {
+      // deleted
+      childDiff = null;
+    }
+    // there's a difference
+    result[key] = childDiff;
+    anythingChanged = true;
+  }
+  for (var key in to) {
+    if (key in from) continue; // handled above
+    result[key] = to[key];
+    anythingChanged = true;
+  }
+  if (anythingChanged) return result;
+  // no change
+  return undefined;
+}
+
+function apply(object, patch) {
+  if (patch === undefined) return object;
+  if (!isObject(object) || !isObject(patch)) return patch;
+  // both are objects
+  for (var key in patch) {
+    var patchChild = patch[key];
+    if (patchChild == null) {
+      // removed
+      delete object[key];
+    } else {
+      // either this assignment or this function call will have side effects
+      object[key] = apply(object[key], patchChild);
+    }
+  }
+  return object;
+}
+
+function isObject(object) {
+  if (object == null) return false;
+  if (typeof object !== "object") return false;
+  if (Array.isArray(object)) return false;
+  if (object instanceof Date) return false;
+  return true;
+}
--- /dev/null
+++ groovebasin-1.3.0/node_modules/curlydiff/package.json
@@ -0,0 +1,46 @@
+{
+  "name": "curlydiff",
+  "version": "2.0.1",
+  "description": "diff nested JavaScript objects",
+  "main": "index.js",
+  "scripts": {
+    "test": "node test/test.js"
+  },
+  "repository": {
+    "type": "git",
+    "url": "git://github.com/thejoshwolfe/curlydiff.git"
+  },
+  "author": {
+    "name": "Josh Wolfe",
+    "email": "thejoshwolfe@gmail.com"
+  },
+  "license": "MIT",
+  "bugs": {
+    "url": "https://github.com/thejoshwolfe/curlydiff/issues"
+  },
+  "devDependencies": {
+    "whynoteq": "~1.0.2"
+  },
+  "gitHead": "b8f52b5906ec3e93873447e072c2d370c02cf869",
+  "homepage": "https://github.com/thejoshwolfe/curlydiff",
+  "_id": "curlydiff@2.0.1",
+  "_shasum": "6ac4b754ea5b63af2632022d03a152306f7eac0b",
+  "_from": "curlydiff@~2.0.1",
+  "_npmVersion": "1.4.28",
+  "_npmUser": {
+    "name": "thejoshwolfe",
+    "email": "thejoshwolfe@gmail.com"
+  },
+  "maintainers": [
+    {
+      "name": "thejoshwolfe",
+      "email": "thejoshwolfe@gmail.com"
+    }
+  ],
+  "dist": {
+    "shasum": "6ac4b754ea5b63af2632022d03a152306f7eac0b",
+    "tarball": "http://registry.npmjs.org/curlydiff/-/curlydiff-2.0.1.tgz"
+  },
+  "directories": {},
+  "_resolved": "https://registry.npmjs.org/curlydiff/-/curlydiff-2.0.1.tgz"
+}