delta-listener
Advanced tools
Comparing version 1.0.0-alpha.0 to 1.0.0-alpha.1
@@ -7,2 +7,3 @@ "use strict"; | ||
":string": /(\w+)/, | ||
"*": /(.*)/, | ||
}; | ||
@@ -30,6 +31,11 @@ var DeltaContainer = (function () { | ||
rules: segments.map(function (segment) { | ||
// replace placeholder matchers | ||
return (typeof (segment) === "string") | ||
? matcherPlaceholders[segment] || new RegExp(segment) | ||
: segment; | ||
if (typeof (segment) === "string") { | ||
// replace placeholder matchers | ||
return (segment.indexOf(":") === 0) | ||
? matcherPlaceholders[segment] || matcherPlaceholders["*"] | ||
: new RegExp(segment); | ||
} | ||
else { | ||
return segment; | ||
} | ||
}) | ||
@@ -59,6 +65,8 @@ }; | ||
var matches = patch.path[i].match(rule.rules[i]); | ||
pathVars = pathVars.concat(matches.slice(1)); | ||
if (matches.length === 0 || matches.length > 2) { | ||
if (!matches || matches.length === 0 || matches.length > 2) { | ||
return false; | ||
} | ||
else { | ||
pathVars = pathVars.concat(matches.slice(1)); | ||
} | ||
} | ||
@@ -65,0 +73,0 @@ return pathVars; |
{ | ||
"name": "delta-listener", | ||
"version": "1.0.0-alpha.0", | ||
"version": "1.0.0-alpha.1", | ||
"description": "Deeply compare JavaScript objects and listen to changes.", | ||
@@ -8,3 +8,4 @@ "main": "lib/index.js", | ||
"scripts": { | ||
"test": "mocha test/**.ts --require ts-node/register" | ||
"test": "mocha test/**.ts --require ts-node/register", | ||
"prepublish": "tsc" | ||
}, | ||
@@ -11,0 +12,0 @@ "keywords": [ |
@@ -23,3 +23,4 @@ delta-listener | ||
container.listen("entities/:id", "replace", (, ) => { | ||
container.listen("entities/:id", "add", (entityId: string, value: any) => { | ||
console.log("new entity", entityId, value); | ||
}) | ||
@@ -26,0 +27,0 @@ |
@@ -6,2 +6,3 @@ { | ||
"module": "commonjs", | ||
"declaration": true, | ||
"noImplicitAny": true | ||
@@ -8,0 +9,0 @@ }, |
17662
13
438
58