Support
This is a Collection of Helpers for the Platform SDK. The implementation adheres to the contracts laid out in the specification.
Repository
Installation
1yarn add @ardenthq/sdk-helpers
Usage
Arr
Arr
class
Importing the 1import { Arr } from "@ardenthq/sdk-helpers";
Get a random element from the given array
1Arr.randomElement(items: any[]);
Bignumber
BigNumber
class
Importing the 1import { BigNumber } from "@ardenthq/sdk-helpers";
BigNumber
instance from the given value
Create a new 1BigNumber.make(value: NumberLike, decimals?: number): BigNumber;
Set the amount of decimals to the given limit
1bigNumber.decimalPlaces(decimals?: number): BigNumber;
Add the given value to the existing value
1bigNumber.plus(value: NumberLike): BigNumber;
Subtract the given value from the existing value
1bigNumber.minus(value: NumberLike): BigNumber;
Divide the existing value by the given value
1bigNumber.divide(value: NumberLike): BigNumber;
Multiply the existing value by the given value
1bigNumber.times(value: NumberLike): BigNumber;
NaN
Determine if the value is 1bigNumber.isNaN(): boolean;
Determine if the value is positive
1bigNumber.isPositive(): boolean;
Determine if the value is finite
1bigNumber.isFinite(): boolean;
Get the difference between the given and actual value
1bigNumber.comparedTo(value: NumberLike): number;
Determine if the actual value is equal to the expected value
1bigNumber.isEqualTo(value: NumberLike): boolean;
Determine if the actual value is greater than the expected value
1bigNumber.isGreaterThan(value: NumberLike): boolean;
Determine if the actual value is greater than or equal to the expected value
1bigNumber.isGreaterThanOrEqualTo(value: NumberLike): boolean;
Determine if the actual value is less than the expected value
1bigNumber.isLessThan(value: NumberLike): boolean;
Determine if the actual value is less than or equal to the expected value
1bigNumber.isLessThanOrEqualTo(value: NumberLike): boolean;
Return the value as satoshis
1bigNumber.toSatoshi(): BigNumber;
Return the value as human-readable number
1bigNumber.toHuman(decimals = 8): string;
Return the value as a string with a limited amount of decimals
1bigNumber.toFixed(decimals?: number): string;
Return the value as an integer
1bigNumber.toNumber(): number;
Return the value as a string
1bigNumber.toString(): string;
Return the value as a string, including the minus symbol if applicable
1bigNumber.valueOf(): string;
Censor
Censor
class
Importing the 1import { Censor } from "@ardenthq/sdk-helpers";2 3const censor = new Censor();
Determine if the value contains bad terms
1censor.isBad(value: string): boolean;
Remove all bad terms from the value
1censor.process(value: string): string;
Markdown
Markdown
class
Importing the 1import { Markdown } from "@ardenthq/sdk-helpers";
Parse the given content into HTML
1Markdown.parse(content: string): { meta: MarkdownMeta; content: String };
QRCode
QRCode
class
Importing the 1import { QRCode } from "@ardenthq/sdk-helpers";
Create a new QRCode from a string
1QRCode.fromString(value: string): QRCode;
Create a new QRCode from an object of keys and values
1QRCode.fromObject(value: object): QRCode;
Get the Base64 Data URL representation of the QRCode
1await qrcode.toDataURL(options: QRCodeToDataURLOptions = {}): Promise<string>;
Get the string representation of the QRCode
1await qrcode.toString(type: StringType = "utf8"): Promise<string>;
Validator
Validator
class
Importing the 1import { Validator } from "@ardenthq/sdk-helpers";2 3const validator = new Validator();
Validate the given data against the schema
1validator.validate(data: object, schema: { validateSync: Function }): void;
Check if the validation passed
1validator.passes(): boolean;
Check if the validation failed
1validator.fails(): boolean;
Get a list of all error messages
1validator.errors(): string[] | undefined;
yup
Get the error object from 1validator.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.
Last updated 2 years ago
Edit Page