Skip to content

Commit 9bbbeac

Browse files
committed
dop.action and passed ESLint
1 parent 081d163 commit 9bbbeac

File tree

12 files changed

+42
-32
lines changed

12 files changed

+42
-32
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dop",
3-
"version": "0.24.3",
3+
"version": "0.25.0",
44
"main": "./dist/dop.nodejs.js",
55
"browser": "./dist/dop.js",
66
"unpkg": "./dist/dop.min.js",

src/api/action.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
dop.action = function(func) {
3+
return function() {
4+
var collector = dop.collect();
5+
func.apply(this, arguments);
6+
collector.emit();
7+
}
8+
};

src/api/getObjectPath.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ dop.getObjectPath = function(object, strict) {
55
// path_id = '',
66
parent,
77
prop,
8-
strict = strict !== false,
98
object_dop = object[dop.cons.DOP];
109

10+
strict = strict !== false;
11+
1112
while (object_dop._ !== undefined) {
1213
prop = object_dop.pr;
1314
parent = dop.getObjectTarget(object_dop._);

src/api/removeComputed.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ dop.removeComputed = function(object, property, callback) {
1414
derivation_pathid,
1515
derivations,
1616
index,
17-
total,
17+
// total,
1818
index2,
1919
total2;
2020

src/core/constructors/observer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ dop.core.observer.prototype.observe = function(object, property) {
1313
dop.util.invariant(isArray(path), 'observer.observe() The object you are passing is not allocated to a registered object');
1414

1515

16-
var path_id = dop.core.getPathId(path);
16+
var path_id = dop.core.getPathId(path),
1717
data_path = dop.data.path,
1818
type = 'observers';
1919

src/core/constructors/snapshot.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ dop.core.snapshot.prototype.getUnpatch = function() {
4646

4747

4848
dop.core.snapshot.prototype.setPatch = function(patch) {
49-
for (object_id in patch)
49+
for (var object_id in patch)
5050
dop.core.setPatch(
5151
patch[object_id].object,
5252
patch[object_id].chunks,

src/core/mutators/splice.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,16 @@ dop.core.splice = function(array, args) {
1212

1313
// If enviroment do not allow proxies (objectTarget and objectProxy are same object in that case)
1414
// or if the array is the proxy itself
15-
if (path = dop.getObjectPath(array)) {
15+
path = dop.getObjectPath(array)
16+
if (path) {
1617

1718
var argslength = args.length,
1819
length = objectTarget.length,
1920
index=2,
2021
start = Number(args[0]),
21-
deleteCount = (Number(args[1])>0) ? args[1] : 0,
22+
// deleteCount = (Number(args[1])>0) ? args[1] : 0,
2223
itemslength = (args.length>2) ? (args.length-2) : 0,
23-
end, item, object_dop;
24+
item;
2425

2526

2627
// Defaults for start
@@ -32,13 +33,13 @@ dop.core.splice = function(array, args) {
3233
start = originalLength;
3334

3435

35-
// We dont need update becase no items remaining after splice
36-
end = (argslength===1) ? 0 :
37-
// If deleteCount is the same of items to add means the new lengh is the same and we only need to update the new elements
38-
(argslength>2 && deleteCount===itemslength) ?
39-
start+deleteCount
40-
:
41-
objectTarget.length;
36+
// // We dont need update becase no items remaining after splice
37+
// end = (argslength===1) ? 0 :
38+
// // If deleteCount is the same of items to add means the new lengh is the same and we only need to update the new elements
39+
// (argslength>2 && deleteCount===itemslength) ?
40+
// start+deleteCount
41+
// :
42+
// objectTarget.length;
4243

4344

4445
// We must register new objects

src/core/objects/configureObject.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ dop.core.configureObject = function(object, propertyParent, parent) {
5858
value,
5959
path,
6060
is_array = isArray(object_target),
61-
is_function,
62-
computed_pending = [];
61+
is_function;
6362

6463
for (property in object_target) {
6564
if (is_array)

src/core/objects/createComputed.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11

22
dop.core.createComputed = function (object, prop, f, shallWeSet, oldValue) {
33
var data_path = dop.data.path,
4-
computed_id = dop.data.computed_inc++,
5-
computed = {
6-
object_root: dop.getObjectRoot(object),
7-
prop: prop,
8-
function: f,
9-
derivations: []
10-
},
11-
path = dop.getObjectPath(object, false);
4+
value,
5+
computed_id = dop.data.computed_inc++,
6+
computed = {
7+
object_root: dop.getObjectRoot(object),
8+
prop: prop,
9+
function: f,
10+
derivations: []
11+
},
12+
path = dop.getObjectPath(object, false);
1213

1314
computed.path = path.slice(1);
1415
computed.pathid = dop.core.getPathId(path.concat(prop));

src/core/objects/injectMutationInPatch.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@ dop.core.injectMutationInPatch = function(patch, mutation) {
99
isMutationArray = isMutationSplice || isMutationSwaps,
1010
typeofValue = dop.util.typeof(value),
1111
index = 1,
12-
chunk = chunkParent = patch.chunks[patch.chunks.length-1],
13-
chunkNext = chunkNextParent = chunkNextRoot = {},
12+
chunk = patch.chunks[patch.chunks.length-1],
13+
chunkParent = chunk,
14+
chunkNext = {},
15+
chunkNextParent = chunkNext,
16+
chunkNextRoot = chunkNext,
1417
tofCurrentObject,
1518
specialInstruction,
1619
instructionsPatchs = dop.protocol.instructionsPatchs,

0 commit comments

Comments
 (0)