package darwin

import (
	"context"
	"time"
)

func Sleep(ctx context.Context, d time.Duration) error {
	t := time.NewTicker(d)
	defer t.Stop()

	select {
	case <-t.C:
		return nil
	case <-ctx.Done():
		return ctx.Err()
	}
}