LucianoGanga / country-codes-list

List of codes per country (languages, calling codes, currency codes, etc)
MIT License
94 stars 48 forks source link

Change the return type of `customArray` #30

Closed scheidtdav closed 1 year ago

scheidtdav commented 1 year ago

Fix for #25 plus I added customArray to the README.md for good measure :)

Frank-vdm commented 1 year ago

Can this not be more dynamic, basically im thinking along the lines of

export function customArray(
    fields?: Record<string, string>
    settings?: CustomArraySettings
  ): Record<string, string>[];

basically the idea stems from the way the function currently works

i can call

  countryCodes.customArray({ name: '{countryNameEn}',
  value: `[{countryCode}] {${CountryProperty.officialLanguageCode}}`,})
  => [{name: United States of America, value: [US] en}]

but if i call the following the results are still as expected countryCodes.customArray({ label: '{countryNameEn}', value: [{countryCode}] {${CountryProperty.officialLanguageCode}}, callingCode: '{countryCallingCode}', })

=> [{label: United States of America, value: [US] en, callingCode: 1}]

scheidtdav commented 1 year ago

Hey @Frank-vdm,

you are right, its probably a lot better by using something like what you proposed. My PR was mostly for fixing the fact that it seems straight up wrong in the current release. Happy to close this one in favor of one thats more sophisticated, if you like to contribute (looks like you just did that in #31, should we close this?). It has been over a month though, since I opened this PR. I am not sure if @LucianoGanga is planning a release of this library?

Cheers

Frank-vdm commented 1 year ago

Yea I did do a quick pr, I'm hoping for some movement here

scheidtdav commented 1 year ago

Sweet. Closing this in favor of #31 then. That will fix #25 as well.