Package Exports
- @polkadot/util
- @polkadot/util/array/filter
- @polkadot/util/assert
- @polkadot/util/bn/toBn
- @polkadot/util/bn/toHex
- @polkadot/util/bn/toU8a
- @polkadot/util/buffer/toU8a
- @polkadot/util/compact/defaults
- @polkadot/util/ext/error
- @polkadot/util/hex
- @polkadot/util/hex/addPrefix
- @polkadot/util/hex/fixLength
- @polkadot/util/hex/hasPrefix
- @polkadot/util/hex/stripPrefix
- @polkadot/util/hex/toBn
- @polkadot/util/hex/toU8a
- @polkadot/util/index
- @polkadot/util/is
- @polkadot/util/is/bn
- @polkadot/util/is/boolean
- @polkadot/util/is/buffer
- @polkadot/util/is/error
- @polkadot/util/is/function
- @polkadot/util/is/hex
- @polkadot/util/is/instanceOf
- @polkadot/util/is/ip
- @polkadot/util/is/null
- @polkadot/util/is/number
- @polkadot/util/is/object
- @polkadot/util/is/observable
- @polkadot/util/is/string
- @polkadot/util/is/u8a
- @polkadot/util/is/undefined
- @polkadot/util/logger
- @polkadot/util/number/toHex
- @polkadot/util/number/toU8a
- @polkadot/util/polyfill
- @polkadot/util/promisify
- @polkadot/util/string
- @polkadot/util/string/shorten
- @polkadot/util/string/toU8a
- @polkadot/util/syncify
- @polkadot/util/u8a
- @polkadot/util/u8a/concat
- @polkadot/util/u8a/fixLength
- @polkadot/util/u8a/toBn
- @polkadot/util/u8a/toBuffer
- @polkadot/util/u8a/toHex
- @polkadot/util/u8a/toString
- @polkadot/util/u8a/toU8a
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@polkadot/util) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@polkadot/util
Various useful utility functions that are used across all projects in the @polkadot namespace. It provides utility functions with additional safety checks, allowing not only for consistent coding, but also reducing the general boilerplate.
Usage
Installation -
yarn add @polkadot/util
Functions can be imported directly from the package, e.g.
import { isHex } from '@polkadot/util';
Documentation and Available Utilities
Below is a list of currently exposed methods published at the Polkadot-JS Common Documentation Portal.
Utility methods for this package are split into groups, some of which are included in the list below:
Below is information about some of the available methods:
Assert
- Checks for a valid test, if not
ExtError
is thrown
Logger
- Creates a consistent log interface for messages that has
.log
,.error
,.warn
and.debug
(controlled with environmentDEBUG=typeA,typeB
) methods.
Promisify
- Wraps a supplied asynchronous callback function into a Promise, passing supplied parameters. When
error
is set, the Promise is rejected, else the Promise resolves with theresult
value.
Syncify
- This is currently for Node environments only.