mh-populate

1.0.2 • Public • Published

MH Populate

mhPopulate A JavaScript Libary which will populate data between arrays with n looping and high performance

Buy Me A Coffee

Installation

npm install mh-populate

Usage

import * as mhPopulate from 'mh-populate';

let countryArray = [  
  {'name': 'Afghanistan', 'code': 'AF'},  
  {'name': 'land Islands', 'code': 'AX'},  
  {'name': 'Albania', 'code': 'AL'},  
  {'name': 'Algeria', 'code': 'DZ'},  
  {'name': 'American Samoa', 'code': 'AS'},  
  {'name': 'AndorrA', 'code': 'AD'},  
 .....
];

let codeArray = [  
  {'lat': '555.555','lng':'555.555','code': 'AF',...},  
  {'lat': '555.555','lng':'555.555','code': 'AX',...},  
  {'lat': '555.555','lng':'555.555','code': 'AL'},  
  {'lat': '555.555','lng':'555.555','code': 'DZ'},  
  {'lat': '555.555','lng':'555.555','code': 'AS'},  
  {'lat': '555.555','lng':'555.555','code': 'AD'},  
 .....
];


mhPopulate(countryArray, codeArray, 'code')
Attribute Type Descripton
originalArray Array data that include foreign key
populateArray Array populate data
key String foreign key
populateKey String populate key
isNumber Boolean is populate value number, by default false

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

Package Sidebar

Install

npm i mh-populate

Weekly Downloads

0

Version

1.0.2

License

MIT

Unpacked Size

3.49 kB

Total Files

3

Last publish

Collaborators

  • mohammadhmead