Home | Platform SDK

Support

This is a Collection of Helpers for the Platform SDK. The implementation adheres to the contracts laid out in the specification.

Repository

Installation

yarn add @arkecosystem/platform-sdk-support

Usage

Arr

Importing the Arr class

import { Arr } from "@arkecosystem/platform-sdk-support";

Get a random element from the given array.

Arr.randomElement(items: any[]);

Bignumber

Importing the BigNumber class

import { BigNumber } from "@arkecosystem/platform-sdk-support";

Create a new BigNumber instance from the given value

BigNumber.make(value: NumberLike, decimals?: number): BigNumber;

Set the amount of decimals to the given limit.

bigNumber.decimalPlaces(decimals?: number): BigNumber;

Add the given value to the existing value.

bigNumber.plus(value: NumberLike): BigNumber;

Subtract the given value from the existing value.

bigNumber.minus(value: NumberLike): BigNumber;

Divide the existing value by the given value.

bigNumber.divide(value: NumberLike): BigNumber;

Multiply the existing value by the given value.

bigNumber.times(value: NumberLike): BigNumber;

Determine if the value is NaN

bigNumber.isNaN(): boolean;

Determine if the value is positive

bigNumber.isPositive(): boolean;

Determine if the value is finite

bigNumber.isFinite(): boolean;

Get the difference between the given and actual value

bigNumber.comparedTo(value: NumberLike): number;

Determine if the actual value is equal to the expected value

bigNumber.isEqualTo(value: NumberLike): boolean;

Determine if the actual value is greater than the expected value

bigNumber.isGreaterThan(value: NumberLike): boolean;

Determine if the actual value is greater than or equal to the expected value

bigNumber.isGreaterThanOrEqualTo(value: NumberLike): boolean;

Determine if the actual value is less than the expected value

bigNumber.isLessThan(value: NumberLike): boolean;

Determine if the actual value is less than or equal to the expected value

bigNumber.isLessThanOrEqualTo(value: NumberLike): boolean;

Return the value as satoshis

bigNumber.toSatoshi(): BigNumber;

Return the value as human-readable number

bigNumber.toHuman(decimals = 8): string;

Return the value as a string with a limited amount of decimals

bigNumber.toFixed(decimals?: number): string;

Return the value as an integer

bigNumber.toNumber(): number;

Return the value as a string

bigNumber.toString(): string;

Return the value as a string, including the minus symbol if applicable

bigNumber.valueOf(): string;

Censor

Importing the Censor class

import { Censor } from "@arkecosystem/platform-sdk-support";

const censor = new Censor();

Determine if the value contains bad terms.

censor.isBad(value: string): boolean;

Remove all bad terms from the value.

censor.process(value: string): string;

Markdown

Importing the Markdown class

import { Markdown } from "@arkecosystem/platform-sdk-support";

Parse the given content into HTML.

Markdown.parse(content: string): { meta: MarkdownMeta; content: String };

QRCode

Importing the QRCode class

import { QRCode } from "@arkecosystem/platform-sdk-support";

Create a new QRCode from a string.

QRCode.fromString(value: string): QRCode;

Create a new QRCode from an object of keys and values.

QRCode.fromObject(value: object): QRCode;

Get the Base64 Data URL representation of the QRCode.

await qrcode.toDataURL(options: QRCodeToDataURLOptions = {}): Promise;

Get the string representation of the QRCode

await qrcode.toString(type: StringType = "utf8"): Promise;

Validator

Importing the Validator class

import { Validator } from "@arkecosystem/platform-sdk-support";

const validator = new Validator();

Validate the given data against the schema.

validator.validate(data: object, schema: { validateSync: Function }): void;

Check if the validation passed.

validator.passes(): boolean;

Check if the validation failed.

validator.fails(): boolean;

Get a list of all error messages.

validator.errors(): string[] | undefined;

Get the error object from yup

validator.error(): ValidationError | undefined;

Security

If you discover a security vulnerability within this package, please send an e-mail to [email protected]. All security vulnerabilities will be promptly addressed.


2020 © ARK.io | All rights reserved | An ARK.io Product