@push-rpc/core
Advanced tools
Comparing version 1.6.3 to 1.6.5
@@ -41,3 +41,3 @@ import { DataConsumer, DataSupplier, Topic, TopicImpl } from "./rpc"; | ||
*/ | ||
export declare function prepareLocal(services: any, prefix?: string): void; | ||
export declare function prepareLocal(services: any, prefix?: string, visited?: Set<unknown>): void; | ||
export {}; |
@@ -201,15 +201,15 @@ "use strict"; | ||
exports.LocalTopicImpl = LocalTopicImpl; | ||
function filterContains(container, filter) { | ||
if (filter == null) | ||
function filterContains(triggerFilter, subscriptionFilter) { | ||
if (subscriptionFilter == null) | ||
return true; // subscribe to all data | ||
if (container == null) | ||
if (triggerFilter == null) | ||
return true; // all data modified | ||
for (var _i = 0, _a = Object.keys(filter); _i < _a.length; _i++) { | ||
for (var _i = 0, _a = Object.keys(subscriptionFilter); _i < _a.length; _i++) { | ||
var key = _a[_i]; | ||
if (container[key] == undefined) | ||
if (triggerFilter[key] == undefined) | ||
continue; | ||
if (filter[key] == container[key]) | ||
if (subscriptionFilter[key] == triggerFilter[key]) | ||
continue; | ||
if (Array.isArray(container[key]) && Array.isArray(filter[key])) { | ||
if (JSON.stringify(container[key]) == JSON.stringify(filter[key])) { | ||
if (Array.isArray(triggerFilter[key]) && Array.isArray(subscriptionFilter[key])) { | ||
if (JSON.stringify(triggerFilter[key]) == JSON.stringify(subscriptionFilter[key])) { | ||
continue; | ||
@@ -226,8 +226,12 @@ } | ||
*/ | ||
function prepareLocal(services, prefix) { | ||
function prepareLocal(services, prefix, visited) { | ||
if (prefix === void 0) { prefix = ""; } | ||
if (visited === void 0) { visited = new Set(); } | ||
if (visited.has(services)) | ||
return; | ||
visited.add(services); | ||
var keys = getObjectProps(services); | ||
keys.forEach(function (key) { | ||
var item = services[key]; | ||
if (typeof item == "object") { | ||
if (item && typeof item == "object") { | ||
var name = prefix + key; | ||
@@ -238,3 +242,3 @@ if ("setTopicName" in item) { | ||
} | ||
return prepareLocal(item, name + "/"); | ||
return prepareLocal(item, name + "/", visited); | ||
} | ||
@@ -241,0 +245,0 @@ }); |
{ | ||
"name": "@push-rpc/core", | ||
"version": "1.6.3", | ||
"version": "1.6.5", | ||
"main": "dist/index.js", | ||
@@ -21,3 +21,3 @@ "types": "dist/index.d.ts", | ||
}, | ||
"gitHead": "2fedd40f524d4802b070aa879e05cb9b43222890" | ||
"gitHead": "d8d55880b77e3dd4fbb89342a1174cf74a527eb2" | ||
} |
@@ -127,12 +127,12 @@ import {DataConsumer, DataSupplier, MessageType, Topic, TopicImpl} from "./rpc" | ||
function filterContains(container, filter): boolean { | ||
if (filter == null) return true // subscribe to all data | ||
if (container == null) return true // all data modified | ||
function filterContains(triggerFilter, subscriptionFilter): boolean { | ||
if (subscriptionFilter == null) return true // subscribe to all data | ||
if (triggerFilter == null) return true // all data modified | ||
for (const key of Object.keys(filter)) { | ||
if (container[key] == undefined) continue | ||
if (filter[key] == container[key]) continue | ||
for (const key of Object.keys(subscriptionFilter)) { | ||
if (triggerFilter[key] == undefined) continue | ||
if (subscriptionFilter[key] == triggerFilter[key]) continue | ||
if (Array.isArray(container[key]) && Array.isArray(filter[key])) { | ||
if (JSON.stringify(container[key]) == JSON.stringify(filter[key])) { | ||
if (Array.isArray(triggerFilter[key]) && Array.isArray(subscriptionFilter[key])) { | ||
if (JSON.stringify(triggerFilter[key]) == JSON.stringify(subscriptionFilter[key])) { | ||
continue | ||
@@ -158,3 +158,6 @@ } | ||
*/ | ||
export function prepareLocal(services, prefix = "") { | ||
export function prepareLocal(services, prefix = "", visited: Set<unknown> = new Set()) { | ||
if (visited.has(services)) return | ||
visited.add(services) | ||
const keys = getObjectProps(services) | ||
@@ -165,3 +168,3 @@ | ||
if (typeof item == "object") { | ||
if (item && typeof item == "object") { | ||
const name = prefix + key | ||
@@ -174,3 +177,3 @@ | ||
return prepareLocal(item, name + "/") | ||
return prepareLocal(item, name + "/", visited) | ||
} | ||
@@ -177,0 +180,0 @@ }) |
import {assert} from "chai" | ||
import {createTestClient, startTestServer} from "./testUtils" | ||
import {RpcConnectionContext} from "../src" | ||
import {prepareLocal} from "../src/local" | ||
@@ -123,2 +124,20 @@ describe("Misc", () => { | ||
}) | ||
it("null member in local", async () => { | ||
const local = { | ||
nested: null, | ||
} | ||
prepareLocal(local) | ||
}) | ||
it("recursive member in local", async () => { | ||
const local = { | ||
nested: null, | ||
} | ||
local.nested = local | ||
prepareLocal(local) | ||
}) | ||
}) |
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
184898
4893