Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vasturiano/accessor-fn
A wrapper function for object accessor properties
https://github.com/vasturiano/accessor-fn
accessor webcomponents wrapper
Last synced: about 1 month ago
JSON representation
A wrapper function for object accessor properties
- Host: GitHub
- URL: https://github.com/vasturiano/accessor-fn
- Owner: vasturiano
- License: mit
- Created: 2017-10-14T06:12:10.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2023-06-17T19:40:10.000Z (over 1 year ago)
- Last Synced: 2024-03-14T19:53:57.902Z (8 months ago)
- Topics: accessor, webcomponents, wrapper
- Language: JavaScript
- Size: 113 KB
- Stars: 5
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Accessor function
==============[![NPM package][npm-img]][npm-url]
[![Build Size][build-size-img]][build-size-url]
[![NPM Downloads][npm-downloads-img]][npm-downloads-url]A wrapper for property accessors supporting functions, property strings or constant values.
## Quick start
```js
import accessorFn from 'accessor-fn';
```
or using a *script* tag
```html```
## Usage example
Given an object
```js
const obj = {
a: 1,
b: 2
}
```Use `accessorFn` to access object values via property strings or transformation functions:
```js
const aFn = accessorFn('a');
aFn(obj); // 1const sumFn = accessorFn(d => d.a + d.b);
sumFn(obj); // 3const constantFn = accessorFn(7);
constantFn(obj); // 7
```[npm-img]: https://img.shields.io/npm/v/accessor-fn
[npm-url]: https://npmjs.org/package/accessor-fn
[build-size-img]: https://img.shields.io/bundlephobia/minzip/accessor-fn
[build-size-url]: https://bundlephobia.com/result?p=accessor-fn
[npm-downloads-img]: https://img.shields.io/npm/dt/accessor-fn
[npm-downloads-url]: https://www.npmtrends.com/accessor-fn