@aegenet/belt-odiff
v2.3.0
Published
Objects differences
Downloads
95
Readme
@aegenet/belt-odiff
Simple objects differences
💾 Installation
yarn add @aegenet/belt-odiff@^2.0.0
# or
npm i @aegenet/belt-odiff@^2.0.0
📝 Usage
Note: the field type
must be either number
, string
, date
, object
, or array
import { odiff } from '@aegenet/belt-odiff';
// const result = odiff({ id: 5 }, { id: 5 }, { fields: ['id'] });
const result = odiff({ id: 5 }, { id: 5 }, { fields: [{ name: 'id', type: 'number' }] });
// result = []
// const result = odiff({ id: 5 }, { id: 3 }, { fields: ['id'] });
const result = odiff({ id: 5 }, { id: 3 }, { fields: [{ name: 'id', type: 'number' }] });
// result = [['id', 5, 3]]
const result = odiff({
id: 5,
code: 'Trotro',
another: 1,
}, {
id: 3,
code: 'Lyoko',
another: 2,,
}, { fields: [{ name: 'id', type: 'number' }, { name: 'code', type: 'string' }] });
// result = [
// ['id', 5, 3],
// ['code', 'Trotro', 'Lyoko'],
// ]