Home Manual Reference Source

Function

Static Public Summary
public

base64Encode(buffer: Buffer | ArrayBuffer): string

Base64 encode data

public

Get all the pages from a PaginatedResourceListing or a range

Static Public

public base64Encode(buffer: Buffer | ArrayBuffer): string source

import {base64Encode} from '@mapcreator/maps4news/src/utils/base64.js'

Base64 encode data

Params:

NameTypeAttributeDescription
buffer Buffer | ArrayBuffer

input buffer

Return:

string

base 64 encoded data

See:

public async getPaginatedRange(page: Promise<PaginatedResourceListing> | PaginatedResourceListing, start: Number, stop: Number): Promise<Array<ResourceBase>> source

import {getPaginatedRange} from '@mapcreator/maps4news/src/utils/helpers.js'

Get all the pages from a PaginatedResourceListing or a range

Params:

NameTypeAttributeDescription
page Promise<PaginatedResourceListing> | PaginatedResourceListing

Promise that returns a PaginatedResourceWrapper

start Number
  • optional
  • default: 1
  • nullable: true

Start page

stop Number
  • optional
  • nullable: true

Stop page, defaults to the page count if not filled in.

Return:

Promise<Array<ResourceBase>>

multiple pages

Throw:

ApiError

Example:

import { helpers } from "@mapcreator/maps4news";

const promise = api.users.list(1, 50); // 50 per page is more efficient

helpers.getPaginatedRange(promise).then(data => {
   data.map(row => `[${row.id}] ${row.name}`) // We just want the names
       .forEach(console.log) // Log the names and ids of every user
})