Skip to content

Instantly share code, notes, and snippets.

@arihantdaga
arihantdaga / avoid_branching.js
Last active January 2, 2023 10:37
Avoiding branching
// Implementation 1
async function makeRequest({
method = RequestMethod.GET,
path,
body = {},
tokenStore,
isLoginRequest = false,
}) {
// We can avoid this branching by using implementation 2
import boto3
from PIL import Image
import io
rekognition_client = boto3.client("rekognition")
def get_face_details(image_bytes):
response = rekognition_client.detect_faces(Image={"Bytes": image_bytes}, Attributes=["ALL"])
# Assuming the first face is the one we need
face_details = response["FaceDetails"][0] if response["FaceDetails"] else None