package paginate

// Slice returns a page of items and the total count before paging.
func Slice[T any](items []T, offset, limit int) ([]T, int64) {
	total := int64(len(items))
	if offset >= len(items) {
		return []T{}, total
	}
	end := offset + limit
	if end > len(items) {
		end = len(items)
	}
	return items[offset:end], total
}
