mh-populate

populate between two array with out loop

Usage no npm install needed!

<script type="module">
  import mhPopulate from 'https://cdn.skypack.dev/mh-populate';
</script>

README

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