Variable: FlameGaslets¶
constFlameGaslets:object
Duck-type guards for Google Apps Script Spreadsheet objects.
Uses method existence checks instead of instanceof, which is unreliable
across GAS script boundaries and container-bound scripts.
Type Declaration¶
isSheet¶
readonlyisSheet: (value) =>value is Sheet
Check if a value is a GoogleAppsScript.Spreadsheet.Sheet object.
Parameters¶
value¶
unknown
Value to check
Returns¶
value is Sheet
true if value looks like a Sheet object, false otherwise
Remarks¶
Uses duck-typing to validate Sheet objects by checking for the minimum set
of methods: getName, getRange, getLastRow, getLastColumn, getParent.
This approach is more reliable than instanceof in Google Apps Script, where
objects may not share the same constructor reference across script boundaries.
Example¶
const sheet = SpreadsheetApp.getActiveSheet();
if (FlameGaslets.isSheet(sheet)) {
const data = sheet.getDataRange().getValues();
}
isSpreadsheet¶
readonlyisSpreadsheet: (value) =>value is Spreadsheet
Check if a value is a GoogleAppsScript.Spreadsheet.Spreadsheet object.
Parameters¶
value¶
unknown
Value to check
Returns¶
value is Spreadsheet
true if value looks like a Spreadsheet object, false otherwise
Remarks¶
Uses duck-typing to validate Spreadsheet objects by checking for the minimum
set of methods: getName, getSheets, getId, getSheetByName.
This approach is more reliable than instanceof in Google Apps Script, where
objects may not share the same constructor reference across script boundaries.
Note: getUrl is intentionally excluded to avoid false positives with Sheet objects.
Example¶
const book = SpreadsheetApp.getActiveSpreadsheet();
if (FlameGaslets.isSpreadsheet(book)) {
Logger.log(`${book.getName()} has ${book.getSheets().length} sheets`);
}
Example¶
function processSheet(value: unknown) {
if (!FlameGaslets.isSheet(value)) {
throw new Error("Expected a Sheet object");
}
const data = value.getDataRange().getValues();
}
See¶
FlameGuards - Guards for primitive and plain JS types
Since¶
0.37.0