Skip to content

Commit adab35c

Browse files
feat(appsscript/sheets/nonSheet): Add nonSheet utility function
1 parent 528ecc1 commit adab35c

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

src/appsscript/sheets/isSheet.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { isObject } from "../../base";
77
*
88
* @param value - The value to check.
99
* @returns `true` if the value is a {@link GoogleAppsScript.Spreadsheet.Sheet|Sheet} object, `false` otherwise.
10+
* @see nonSheet
1011
* @see [Class Sheet](https://developers.google.com/apps-script/reference/spreadsheet/sheet)
1112
* @since 1.0.0
1213
* @version 1.0.0

src/appsscript/sheets/nonSheet.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1-
import { isObject } from "../../base";
1+
import { isSheet } from "./isSheet";
22

33
/**
4-
* ## isSheet
4+
* ## nonSheet
55
*
6-
* Checks if the given value is a Google Apps Script [`Sheet`](https://developers.google.com/apps-script/reference/spreadsheet/sheet) object.
6+
* Checks if the provided value is not a [`Google Sheet`](https://developers.google.com/apps-script/reference/spreadsheet/sheet) object.
77
*
8-
* @param value - The value to check.
9-
* @returns `true` if the value is a {@link GoogleAppsScript.Spreadsheet.Sheet|Sheet} object, `false` otherwise.
8+
* @param value - The value to check.
9+
* @returns `true` if the value is not a {@link GoogleAppsScript.Spreadsheet.Sheet|Sheet} object.
10+
* @see isSheet
1011
* @see [Class Sheet](https://developers.google.com/apps-script/reference/spreadsheet/sheet)
11-
* @since 1.0.0
12+
* @since 1.3.0
1213
* @version 1.0.0
13-
* @environment `Google Apps Script`, `Browser`
14+
* @environment Google Apps Script
1415
*/
15-
export function isSheet(
16-
value: unknown
17-
): value is GoogleAppsScript.Spreadsheet.Sheet {
18-
return isObject(value) && value?.toString() === "Sheet";
16+
export function nonSheet<T>(
17+
value: T | GoogleAppsScript.Spreadsheet.Sheet
18+
): value is T {
19+
return !isSheet(value);
1920
}

0 commit comments

Comments
 (0)