How to use the alcalzone-shared/objects.composeObject 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 / build / tradfri-client.js View on Github external
operateGroup(group, operation, force = false) {
        const newGroup = group.clone().merge(operation, true /* all props */);
        const reference = group.clone();
        if (force) {
            // to force the properties being sent, we need to reset them on the reference
            const inverseOperation = objects_1.composeObject(objects_1.entries(operation)
                .map(([key, value]) => {
                switch (typeof value) {
                    case "number": return [key, Number.NaN];
                    case "boolean": return [key, !value];
                    default: return [key, null];
                }
            }));
            reference.merge(inverseOperation, true);
        }
        return this.updateResource(`${endpoints_1.endpoints.groups}/${group.instanceId}`, newGroup, reference);
    }
    /**
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;
}

alcalzone-shared

A set of utilities shared between my projects

MIT
Latest version published 2 months ago

Package Health Score

72 / 100
Full package analysis

Similar packages