https://github.com/nju33/poipoi
💉 To inject data into a class method
https://github.com/nju33/poipoi
decorator injector javascript method
Last synced: about 1 year ago
JSON representation
💉 To inject data into a class method
- Host: GitHub
- URL: https://github.com/nju33/poipoi
- Owner: nju33
- Created: 2017-04-02T11:33:34.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-04-02T11:38:10.000Z (about 9 years ago)
- Last Synced: 2024-04-14T12:49:42.392Z (about 2 years ago)
- Topics: decorator, injector, javascript, method
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/poipoi
- Size: 43 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Poipoi
[](https://github.com/sindresorhus/xo)
💉 To inject data into a class method.
## Install
```bash
yarn add poipoi
npm i -S poipoi
```
## Usage
```js
import Poipoi from 'poipoi';
const a = new Poipoi({foo: 'foo'});
a.set({
bar: 'bar',
baz: 'baz'
});
const b = new Poipoi({hoge: 'hoge'});
class Foo {
// somethingMethod(b-obj, a-obj, ...args)
@a.inject('foo', 'baz')
@b.inject('hoge')
somethingMethod({hoge}, {foo, baz}, ...args) {}
}
```
## API
### `constructor(initialValue = {})`
- `initialValue`: `Object`
### `set(value)`
- `value`: `Object`
Overwriting data.
### `get(name = null)`
- `name`: `String`
Get data by `name`. If it is `null`, return it all.
### `clear()`
Delete all data
### `inject(...names)`
- `name`: `String`
Inject data written in `names` to the class method.
## Lisence
The MIT License (MIT)
Copyright (c) 2017 nju33