Click here for v1.x documentation.
Dinero.js
Dinero.js version

toSnapshot

DineroSnapshot<TAmount>

Get a snapshot of a Dinero object.

Snapshots are plain JavaScript objects, suited for transport and storage. They're also useful when you need to retrieve raw data from a Dinero object.

Copy linkParameters

NameTypeDescriptionRequired
dineroObjectDinero<TAmount>

The Dinero object to snapshot.

Yes

Copy linkCode examples

Copy linkGet a snapshot of an object

import { dinero, toSnapshot } from 'dinero.js';
import { USD } from '@dinero.js/currencies';

const d = dinero({ amount: 500, currency: USD });

toSnapshot(d);

// {
//   amount: 500,
//   currency: {
//     code: 'USD',
//     base: 10,
//     exponent: 2,
//   },
//   scale: 2,
// }