Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public merge(obj: Partial, allProperties: boolean = false): this {
for (const [key, value] of entries(obj as Record)) {
if (allProperties || this.hasOwnProperty(key)) {
// we can't be sure that this has a property `key`
(this as any)[key] = value;
}
}
return this;
}
merge(obj, allProperties = false) {
for (const [key, value] of objects_1.entries(obj)) {
if (allProperties || this.hasOwnProperty(key)) {
// we can't be sure that this has a property `key`
this[key] = value;
}
}
return this;
}
/** serializes this object in order to transfer it via COAP */
public parse(obj: Record): this {
for (const [key, value] of entries(obj)) {
let deserializer: PropertyTransform | undefined = getDeserializer(this, key);
// key might be ipso key or property name
let propName: string | undefined; // keyof this | string;
if (deserializer == null) {
// deserializers are defined by property name, so key is actually the key
propName = lookupKeyOrProperty(this, key);
if (!propName) {
log(`found unknown property with key ${key}`, "warn");
log(`object was: ${JSON.stringify(obj)}`, "warn");
continue;
}
deserializer = getDeserializer(this, propName);
} else {
// the deserializer was found, so key is actually the property name
propName = key;
}
parse(obj) {
for (const [key, value] of objects_1.entries(obj)) {
let deserializer = getDeserializer(this, key);
// key might be ipso key or property name
let propName; // keyof this | string;
if (deserializer == null) {
// deserializers are defined by property name, so key is actually the key
propName = lookupKeyOrProperty(this, key);
if (!propName) {
logger_1.log(`found unknown property with key ${key}`, "warn");
logger_1.log(`object was: ${JSON.stringify(obj)}`, "warn");
continue;
}
deserializer = getDeserializer(this, propName);
}
else {
// the deserializer was found, so key is actually the property name
propName = key;
export function invertOperation>(
operation: T,
): T {
return composeObject(
entries(operation).map(([key, value]) => {
switch (typeof value) {
case "number":
return [key, Number.NaN] as [string, number];
case "boolean":
return [key, !value] as [string, boolean];
default:
return [key, null] as [string, any];
}
}),
) as T;
}