How to use the alcalzone-shared/objects.entries function in alcalzone-shared

To help you get started, we’ve selected a few alcalzone-shared examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github AlCalzone / node-tradfri-client / src / lib / ipsoObject.ts View on Github external
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;
	}
github AlCalzone / node-tradfri-client / build / lib / ipsoObject.js View on Github external
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 */
github AlCalzone / node-tradfri-client / src / lib / ipsoObject.ts View on Github external
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;
			}
github AlCalzone / node-tradfri-client / build / lib / ipsoObject.js View on Github external
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;
github AlCalzone / node-tradfri-client / src / lib / utils.ts View on Github external
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;
}