Reference Source

Function

Static Public Summary
public

accountMeta(data: object, config: object): object

Returns meta data from Steem account data

public

Extract the first image or potentially featured image for a post

public

Formats a Steem post's payout, does not discriminate for pending or completed posts. Values are for SBD

public

formatRep(reputation: string): number

Formats a Steem account's reputation

public

Formats a Steem account's vests

public

formatVotes(raw: string[] | object, count: string, downvoted: string): object

Formats a Steem post's active votes Will sort out removed votes, and order by weight Will trim return array to specified or default count voterCount

public

Formats a Steem account's voting power using the manarbar data

public

meta(data: object, config: object): object

Returns meta data from Steem post or account data

public

parse(content: content, config: object): object

Parses a Steem post object or array of Steem post body strings or objects

public

parsePost(content: object | string, options: object): object | string

Parses a Steem post object or body string

public

async parsePosts(content: array, options: object): array

Parses multiple Steem post objects or body strings

public

postMeta(data: object, config: object): object

Returns meta data from Steem post data

public

sortVotes(votes: object | array): object

Returns an object of sorted Steem votes by upvotes, downvotes and removedvotes

public

Validates a Steem account username

public

voteStats(votes: object | array): object

Returns stats about a Steem votes object

Static Public

public accountMeta(data: object, config: object): object source

import {accountMeta} from 'steem-utils/lib/meta.js'

Returns meta data from Steem account data

Params:

NameTypeAttributeDescription
data object

Steem account data

config object

config for meta

Return:

object

Returns object which contains meta data about the input account data

Example:

 let accountMetaData = accountMeta(accountData)
 console.log(accountMetaData)
 `
   // profile
   name: "...",
   about: "...",
   avatar: "..."
   username: "...",
   location: "...",
   reputation: "...",

   // details
   id: "...",
   created: "...",
   proxy: "...",
   post_count: "...",
   voting_power: "...",
   can_vote: "...",
   mined: "...",
   recovery_account: "...",
   last_account_recovery: "...",
   reset_account: "...",
   comment_count: "...",
   lifetime_vote_count: "..."
   blockstack: "...",
   pending_claimed_accounts: "...",

   // wallet
   steem: "...",
   sbd: "...",
   savings: "..."
 `

public formatImage(data: string | object): string source

import {formatImage} from 'steem-utils/lib/format.js'

Extract the first image or potentially featured image for a post

Params:

NameTypeAttributeDescription
data string | object

Post data object or post body string

Return:

string

Returns the URL of first image for a post, meant to be used to extract featured images

Example:

 let post_featured_image_url = formatImage(postData.body || postData)

public formatPayout(post: object, fix: number): number source

import {formatPayout} from 'steem-utils/lib/format.js'

Formats a Steem post's payout, does not discriminate for pending or completed posts. Values are for SBD

Params:

NameTypeAttributeDescription
post object

object

fix number

Number of decimal places to fix it to

Return:

number

Post earned value in SBD

Example:

 let payout = formatPayout(postData)

public formatRep(reputation: string): number source

import {formatRep} from 'steem-utils/lib/format.js'

Formats a Steem account's reputation

Params:

NameTypeAttributeDescription
reputation string

Steem reputation value

Return:

number

Formatted reputation value

Example:

 let rep = formatRep(accountData.reputation)
 let rep = formatRep(post.author_reputation)
 console.log(accountData.reputation, rep)
 `"23049917997434", 64`

public formatVests(account: object): number source

import {formatVests} from 'steem-utils/lib/format.js'

Formats a Steem account's vests

Params:

NameTypeAttributeDescription
account object

Steem account's data, not username

Return:

number

Formatted account vests value

Example:

 let vests = formatVests(accountData)

public formatVotes(raw: string[] | object, count: string, downvoted: string): object source

import {formatVotes} from 'steem-utils/lib/format.js'

Formats a Steem post's active votes Will sort out removed votes, and order by weight Will trim return array to specified or default count voterCount

Params:

NameTypeAttributeDescription
raw string[] | object

Post's active_votes,

count string

The number of returned account names

downvoted string

?

Return:

object

{votes, len}: votes is the array of votes, length is length of the votes

Example:

 let votes = formatVotes(postData.active_votes || postData)
 console.log(votes.votes)
 `
 ["+ therising", "+ upmewhale", "+ appreciator", "+ smartsteem", "+ rocky1", "+ buildawhale",
 "+ promobot", "+ jerrybanfield", "+ upmyvote""+ postpromoter", "...and 1741 others"]
 `

public formatVotingPower(account: object): number source

import {formatVotingPower} from 'steem-utils/lib/format.js'

Formats a Steem account's voting power using the manarbar data

Params:

NameTypeAttributeDescription
account object

Steem account data, not account username

Return:

number

Formatted voting power in percentage

Example:

 let votingPower = formatVotingPower(accountData)

public meta(data: object, config: object): object source

Returns meta data from Steem post or account data

Params:

NameTypeAttributeDescription
data object

Steem account or post data

config object

config for meta

Return:

object

Returns object which contains meta data about the input account or post data. For meta(accountData) see accountMeta and for meta(postData) see postMeta

Example:

 let metaData = meta(accountData || postData)
 console.log(metaData)

public parse(content: content, config: object): object source

Parses a Steem post object or array of Steem post body strings or objects

Params:

NameTypeAttributeDescription
content content

Steem post data

config object

config for meta. The default is rendererDefaults

Return:

object

Returns object which contains meta data about the input post data See parsePost for how single items are handled See parsePosts for how items in array are handled

public parsePost(content: object | string, options: object): object | string source

import {parsePost} from 'steem-utils/lib/parse.js'

Parses a Steem post object or body string

Params:

NameTypeAttributeDescription
content object | string

Steem post data object or body string

options object

config for meta. The default is rendererDefaults

Return:

object | string

Returns object or string of parsed body based on config options

Example:

 let parsed = parse(postData, {meta: {all: true}})
 console.log(parsed)
 `
   image: "...",
   summary: "...",
   rep: "...",
   votes: "...",
   payout: "...",
   paid: "...",
   html: "...",
   ... // all other post object data variables remain untouched
 ` *
 let parsed = parse(postData)
 console.log(parsed)
 `
   html: "...",
   ... // all other post object data variables remain untouched

 `
 let parsed = parse(postData.body)
 console.log(parsed)
 `
   "...",
 `

public async parsePosts(content: array, options: object): array source

import {parsePosts} from 'steem-utils/lib/parse.js'

Parses multiple Steem post objects or body strings

Params:

NameTypeAttributeDescription
content array

Array of Steem post data objects or body strings

options object

config for meta. The default is rendererDefaults

Return:

array

Returns array of objects or strings of parsed body based on config options. See parsePost for how each single item in the array in handled

Example:

 let parsed = await parse(postsData)

public postMeta(data: object, config: object): object source

import {postMeta} from 'steem-utils/lib/meta.js'

Returns meta data from Steem post data

Params:

NameTypeAttributeDescription
data object

Steem post data

config object

config for meta

Return:

object

Returns object which contains meta data about the input post data

Example:

 let postMetaData = postMeta(postData)
 console.log(postMetaData)
 `
   title: "...",
   summary: "..."
   payout: "...",
   image: "...",
   created: "...",
   comments_count: "...",
   votes_count: "..."
 `

public sortVotes(votes: object | array): object source

import {sortVotes} from 'steem-utils/lib/sort.js'

Returns an object of sorted Steem votes by upvotes, downvotes and removedvotes

Params:

NameTypeAttributeDescription
votes object | array

Steem post data object or active_votes array

Return:

object

Return sorted arrays in object

Example:

 let sort = sortVotes(postData || postData.active_votes)
 console.log(sort)
 `
   {upVotes: [...], downVotes: [...], removedVotes: [...]}
 `

public validateAccount(username: string): string | boolean source

import {validateAccount} from 'steem-utils/lib/validate.js'

Validates a Steem account username

Params:

NameTypeAttributeDescription
username string

Steem account username

Return:

string | boolean

Returns error message if account is invalid or true if valid

Example:

 let valid = validateAccount('la$tkiller')
 console.log(valid)
 `
   Invalid account
 `
 let valid = validateAccount('lastkiller')
 console.log(valid)
 `
   true
 `

public voteStats(votes: object | array): object source

import {voteStats} from 'steem-utils/lib/stats.js'

Returns stats about a Steem votes object

Params:

NameTypeAttributeDescription
votes object | array

Steem post data object or active_votes array

Return:

object

Return stats object

Example:

 let stats = voteStats(postData || postData.active_votes)
 console.log(stats)
 `
   {total: "...", upVotes: "...", downVotes: "...", removedVotes: "..."}
 `