Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

null/undefined safe ways of working with properties & entries #182

Open
koraa opened this issue Apr 30, 2021 · 0 comments
Open

null/undefined safe ways of working with properties & entries #182

koraa opened this issue Apr 30, 2021 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed needs-api-design

Comments

@koraa
Copy link
Contributor

koraa commented Apr 30, 2021

Type safe way of iterating the properties of arbitrary types; this is a reflection feature and refers to arbitrary types.

const entries = (o) => isdef(o) ? Object.entries(o) : [];
const propertyDescriptors = (o) => isdef(o) ? Object.getOwnPropertyDescriptors(o) : [];
const propertyNames = (o) => isdef(o) ? Object.getOwnPropertyNames(o) : [];
const properties = (o) => map(propertyNames(o), (k) => [k, o[k]]);
const getProperty = (o, k) => isdef(o) ? o[k] : undefined;
@koraa koraa added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers needs-api-design labels Apr 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed needs-api-design
Projects
None yet
Development

No branches or pull requests

1 participant