Arkisto-Platform / describo-data-packs

https://arkisto-platform.github.io/describo-data-packs/
GNU General Public License v3.0
0 stars 0 forks source link

Lookup function signature #5

Closed marcolarosa closed 2 years ago

marcolarosa commented 2 years ago

Don't use positional arguments as in:

function lookupA(packname, find) {}

lookupA('glottolog', 'noongar')
packName = glottolog, find = noongar

lookupA('noongar', 'glottolog')
packName = noongar, find = glottolog

Do you a destructured object

unction lookupB({ packName, find, fields=['@id', 'name'] }) { }

lookupB({packName: 'glott0', find: 'noongar'})
lookupB({
    find: "noongar", packName: "glotto"
});

// by default - lookup @id and name fields

lookupB({
    find: "noongar",
    packName: "glotto",
    fields: ['alternateName']
});

So the main find method will need to be a for (lookup forEach) loop inside the main body that iterates over the properties in the field array.

Supertyp commented 2 years ago

the function in lookup.js has now a destructured object as argument

marcolarosa commented 2 years ago

Closing - replaced by #8