deep-storage
Advanced tools
Comparing version 0.3.6 to 0.3.7
@@ -50,5 +50,3 @@ "use strict"; | ||
function isPathMatch(stateChangePath, subscriptionPath) { | ||
if (stateChangePath.length === 0) | ||
return true; | ||
for (var i = 0; i < subscriptionPath.length; i++) { | ||
for (var i = 0; i < Math.min(subscriptionPath.length, stateChangePath.length); i++) { | ||
if (stateChangePath[i] !== subscriptionPath[i]) | ||
@@ -55,0 +53,0 @@ return false; |
{ | ||
"name": "deep-storage", | ||
"version": "0.3.6", | ||
"version": "0.3.7", | ||
"description": "Simple observable state management for reactive applications", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
@@ -57,5 +57,8 @@ import deepStorage, { isPathMatch } from '../'; | ||
expect(isPathMatch(['test'], ['test', 'something'])).toBeFalsy(); | ||
expect(isPathMatch(['test'], ['test', 'something'])).toBeTruthy(); | ||
expect(isPathMatch(['notTest'], ['test'])).toBeFalsy(); | ||
expect(isPathMatch(['app', 'trello'], ['app', 'trello', 'connections'])).toBeTruthy(); | ||
}); | ||
@@ -70,4 +73,4 @@ | ||
expect(path).toEqual([]); | ||
expect(newState).toEqual({todos: [1]}); | ||
expect(oldState).toEqual({todos: []}); | ||
expect(newState).toEqual({ todos: [1] }); | ||
expect(oldState).toEqual({ todos: [] }); | ||
done(); | ||
@@ -74,0 +77,0 @@ }); |
@@ -79,4 +79,3 @@ export type StateUpdateCallback = <DeepState>(path: Path, newState: DeepState, oldState: DeepState) => void; | ||
export function isPathMatch<T>(stateChangePath: T[], subscriptionPath: T[]) { | ||
if(stateChangePath.length === 0) return true; | ||
for (let i = 0; i < subscriptionPath.length; i++) { | ||
for (let i = 0; i < Math.min(subscriptionPath.length, stateChangePath.length); i++) { | ||
if (stateChangePath[i] !== subscriptionPath[i]) return false; | ||
@@ -83,0 +82,0 @@ } |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
185149
1147