Skip to content

xtetsuji/gas-xtutils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 

Repository files navigation

gas-xtutils

gas-xtutils is GAS (Google Apps Script) xtetsuji's utility .

It has some useful classes powered by ES2015 syntax. You can use it on V8 runtime.

libraries

PagesIterator

Advanced Google Services API (e.g. Tasks API) has paging system as following description.

  • call XXX.list() and get first page object first, first page contents include first.items array.
  • if first.nextPageToken property is exist, then call XXX.list({pageToken: first.nextPageToken}) and get second page object second, second page contents include second.items array.
  • if second.nextPageToken property ...(ditto)...

In this situation, you can write easy iteration by PagesIterator.

const pages = new PagesIterator(
    token => token ? XXX.list() : XXX.list({pageToken: token})
);
for ( const item of pages ) {
    console.log(`- ${item.title}`);
}

PagesIterator constructor has the iterable protocol. You can use PagesIterator on following contexts.

  • Array.from(iterable)
  • ...iterable
  • [a, b, c] = iterable

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published