iota-url-parser
TypeScript icon, indicating that this package has built-in type declarations

0.1.3 • Public • Published

iota-url-parser

iota-url-parser CI

A module that supports parsing and building of IOTA deep links.

Getting Started

# NPM
npm install iota-url-parser

# Yarn
yarn install iota-url-parser

Using the Library

The library contains two functions:

parse(uri)

Parses an IOTA deep link for its various properties, namely protocol, context, operation, and any specific arguments or parameters.

import { parse } from 'iota-url-parser'

const parseResult = parse('iota://wallet/send/atoi1qzallu8y7jhglsc6n93qx8u3lfv3nwagju7xh7al2y7rwwt7f4vsuda9rg5?amount=51&unit=Gi')
console.log(parseResult)
// {
//     protocol: 'iota',
//     context: 'wallet',
//     operation: 'send',
//     argument: 'atoi1qzallu8y7jhglsc6n93qx8u3lfv3nwagju7xh7al2y7rwwt7f4vsuda9rg5',
//     parameters: { amount: 51, unit: 'Gi' }
// }

build(protocol, context, operation, argument, parameters)

Assemble an IOTA deep link URL given a few parameters.

import { build } from 'iota-url-parser'

const buildResult = build(
    'iota',
    'wallet', 
    'send', 
    'atoi1qzallu8y7jhglsc6n93qx8u3lfv3nwagju7xh7al2y7rwwt7f4vsuda9rg5', 
    { amount: 51, unit: 'Gi' }
)
console.log(buildResult)
// iota://wallet/send/atoi1qzallu8y7jhglsc6n93qx8u3lfv3nwagju7xh7al2y7rwwt7f4vsuda9rg5?amount=51&unit=Gi

Package Sidebar

Install

npm i iota-url-parser

Weekly Downloads

0

Version

0.1.3

License

MIT

Unpacked Size

31.1 kB

Total Files

38

Last publish

Collaborators

  • maxwellmattryan