1.5.0 • Published 3 months ago

@aegenet/belt-odiff v1.5.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

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'],
// ]
1.5.0

3 months ago

1.4.2

4 months ago

1.4.1

4 months ago

1.4.0

4 months ago

1.3.2

5 months ago

1.3.1

5 months ago

1.3.0

5 months ago

1.2.0

5 months ago