1.0.2 • Published 3 years ago

mh-populate v1.0.2

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

MH Populate

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

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')
AttributeTypeDescripton
originalArrayArraydata that include foreign key
populateArrayArraypopulate data
keyStringforeign key
populateKeyStringpopulate key
isNumberBooleanis 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