currencyStringToObject

Type:Function
Status:stable
Since:1.0.0
Platform:jsnode
@blackbyte.sugar.shared.currency

This function take a currency string like “120 USD” and convert it to an object containing these properties:

  • amount: 120,
  • code: USD,
  • symbol: $

Params

  1. currency*-String

    The currency string to convert

Return

  1. -TCurrencyToObject

    The currency object

Example

import { currencyStringToObject } from '@blackbyte/sugar/currency';
currencyStringToObject('120 $');
{
  amount: 120,
  code: 'USD',
  symbol: '$'
}