-
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathgetSlideByIndex.ts
More file actions
26 lines (22 loc) · 741 Bytes
/
getSlideByIndex.ts
File metadata and controls
26 lines (22 loc) · 741 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { isPresentation } from "./isPresentation";
/**
* Gets a slide by its index in the presentation.
*
* @param {GoogleAppsScript.Slides.Presentation} presentation The presentation object.
* @param {number} index The zero-based index of the slide.
* @returns {GoogleAppsScript.Slides.Slide | null} The slide at the given index, or `null` if the index is out of bounds.
* @since 1.5.0
*/
export function getSlideByIndex(
presentation: GoogleAppsScript.Slides.Presentation,
index: number
): GoogleAppsScript.Slides.Slide | null {
if (!isPresentation(presentation)) {
return null;
}
const slides = presentation.getSlides();
if (index < 0 || index >= slides.length) {
return null;
}
return slides[index];
}