@aegenet/belt-odiff
TypeScript icon, indicating that this package has built-in type declarations

1.5.0 • Public • Published

npm version

@aegenet/belt-odiff

Simple objects differences

💾 Installation

yarn add @aegenet/belt-odiff@^1.4.0
# or
npm i @aegenet/belt-odiff@^1.4.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'],
// ]

Readme

Keywords

Package Sidebar

Install

npm i @aegenet/belt-odiff

Weekly Downloads

0

Version

1.5.0

License

MIT

Unpacked Size

6.39 kB

Total Files

7

Last publish

Collaborators

  • agenet