Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zswang/jsets
https://github.com/zswang/jsets
getter setter
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/zswang/jsets
- Owner: zswang
- License: mit
- Created: 2015-07-23T08:46:47.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-11-04T13:41:23.000Z (about 7 years ago)
- Last Synced: 2024-10-02T07:21:13.029Z (about 1 month ago)
- Topics: getter, setter
- Language: JavaScript
- Size: 21.5 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
jsets
-----------# [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Coverage Status][coverage-image]][coverage-url]
> Define Getter and Setter
## Install 安装
```sh
$ npm install --save jsets
```## Usage 使用
```js
const jsets = require('jsets')let data = {}
let instance = {}
instance.set = jsets.createSetter(instance, function (name, value) {
data[name] = value
}, true)
instance.get = jsets.createGetter(instance, function (name, value) {
return data[name]
}, true)instance.set('a', 1)
instance.set({
a: 1,
b: 2
})
instance.get(function (b, a) {
console.log(b, a) // 2, 1
})
```## License
MIT © [zswang](http://weibo.com/zswang)
[npm-url]: https://npmjs.org/package/jsets
[npm-image]: https://badge.fury.io/js/jsets.svg
[travis-url]: https://travis-ci.org/zswang/jsets
[travis-image]: https://travis-ci.org/zswang/jsets.svg?branch=master
[coverage-url]: https://coveralls.io/github/zswang/jsets?branch=master
[coverage-image]: https://coveralls.io/repos/zswang/jsets/badge.svg?branch=master&service=github