💉 To inject data into a class method
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
test
.babelrc
.gitignore
.npmignore
LISENCE.md
README.md
gulpfile.babel.js
package.json
yarn.lock

README.md

Poipoi

XO code style

💉 To inject data into a class method.

Install

yarn add poipoi
npm i -S poipoi

Usage

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 nju33.ki@gmail.com