Last active
August 3, 2022 00:00
-
-
Save soyalumno/1fb31e97aabd3f49a609524493b8ec81 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const SCRIPT_PROP = PropertiesService.getScriptProperties(); | |
// プロパティアクセス用ラッパー | |
const SETTING = { | |
// 設定の初期化 | |
init: () => { | |
SETTING.permanent_token = ''; | |
SETTING.permanent_id = 0; | |
}, | |
// 文字列パラメータのGetter / Setter | |
get permanent_token() { | |
return SCRIPT_PROP.getProperty('token') || ''; | |
}, | |
set permanent_token(token: string) { | |
SCRIPT_PROP.setProperty('token', token); | |
}, | |
// 数字パラメータのGetter / Setter | |
get permanent_id() { | |
return parseInt(SCRIPT_PROP.getProperty('id') || '0'); | |
}, | |
set permanent_id(id: number) { | |
SCRIPT_PROP.setProperty('id', id.toString()); | |
}, | |
} | |
function propertyReadWrite() { | |
// プロパティにWrite | |
SETTING.permanent_token = 'new_token'; | |
SETTING.permanent_id = 100; | |
// プロパティからRead | |
console.log(SETTING.permanent_token); | |
console.log(SETTING.permanent_id); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment