bs-querystringify
Advanced tools
Comparing version 0.1.0 to 0.1.1
{ | ||
"name": "bs-querystringify", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "BuckleScript bindings to querystringify", | ||
@@ -5,0 +5,0 @@ "main": "src/QueryStringify.bs.js", |
@@ -1,7 +0,6 @@ | ||
# inversify-token | ||
# bs-querystringify | ||
[![npm](https://img.shields.io/npm/v/inversify-token.svg)](https://www.npmjs.com/package/inversify-token) | ||
[![CircleCI](https://img.shields.io/circleci/project/github/mscharley/inversify-token.svg)](https://circleci.com/gh/mscharley/inversify-token) [![Greenkeeper badge](https://badges.greenkeeper.io/mscharley/inversify-token.svg)](https://greenkeeper.io/) | ||
[![npm](https://img.shields.io/npm/v/bs-querystringify.svg)](https://www.npmjs.com/package/bs-querystringify) | ||
**Source:** [https://github.com/mscharley/inversify-token](https://github.com/mscharley/inversify-token) | ||
**Source:** [https://github.com/mscharley/bs-querystringify](https://github.com/mscharley/bs-querystringify) | ||
**Author:** Matthew Scharley | ||
@@ -16,76 +15,6 @@ **Contributors:** [See contributors on GitHub][gh-contrib] | ||
This library provides simpler, more type-safe options for injecting values using Inversify. | ||
This package provide access to the querystringify node package. | ||
## Installation | ||
$ npm i inversify-token | ||
## Usage | ||
Modified from the [InversifyJS readme](inversify-readme). | ||
```ts | ||
// Declare your interfaces as normal. | ||
// file types.ts | ||
import { Token, TokenType } from "inversify-token"; | ||
import { Warrior, Weapon, ThrowableWeapon } from "./interfaces" | ||
const WarriorToken = new Token<Warrior>(Symbol.for("Warrior")); | ||
type WarriorToken = TokenType<typeof WarriorToken>; | ||
const WeaponToken = new Token<Weapon>(Symbol.for("Weapon")); | ||
type WeaponToken = TokenType<typeof WeaponToken>; | ||
const ThrowableWeaponToken = new Token<ThrowableWeapon>(Symbol.for("ThrowableWeapon")); | ||
type ThrowableWeaponToken = TokenType<typeof ThrowableWeaponToken>; | ||
export { | ||
WarriorToken as Warrior, | ||
WeaponToken as Weapon, | ||
ThrowableWeaponToken as ThrowableWeapon, | ||
} | ||
// file entities.ts | ||
import { injectable } from "inversify"; | ||
import { injectToken } from "inversify-token"; | ||
import * as TYPES from "./types"; | ||
@injectable() | ||
class Ninja implements Warrior { | ||
public constructor( | ||
@injectToken(TYPES.Weapon) private _katana: TYPES.Weapon, | ||
@injectToken(TYPES.ThrowableWeapon) private _shuriken: TYPES.ThrowableWeapon, | ||
) { } | ||
public fight() { return this._katana.hit(); } | ||
public sneak() { return this._shuriken.throw(); } | ||
} | ||
// file inversify.config.ts | ||
import { getToken, tokenBinder } from "inversify-token"; | ||
const myContainer = new Container(); | ||
const bindToken = tokenBinder(myContainer.bind.bind(myContainer)); | ||
bindToken(TYPES.Warrior).to(Ninja); | ||
bindToken(TYPES.Weapon).to(Katana); | ||
bindToken(TYPES.ThrowableWeapon).to(Shuriken); | ||
const warrior = getToken(container, TYPES.Warrior); | ||
// file inversify.module.ts | ||
import { getToken, TokenContainerModule } from "inversify-token"; | ||
const myContainer = new Container(); | ||
const module = new TokenContainerModule((bindToken) => { | ||
bindToken(TYPES.Warrior).to(Ninja); | ||
bindToken(TYPES.Weapon).to(Katana); | ||
bindToken(TYPES.ThrowableWeapon).to(Shuriken); | ||
}); | ||
myContainer.load(module); | ||
const warrior = getToken(container, TYPES.Warrior); | ||
``` | ||
[gh-contrib]: https://github.com/mscharley/inversify-token/graphs/contributors | ||
[gh-issues]: https://github.com/mscharley/inversify-token/issues | ||
[license]: https://github.com/mscharley/inversify-token/blob/master/LICENSE | ||
[inversify-readme]: https://github.com/inversify/InversifyJS#the-basics | ||
[gh-contrib]: https://github.com/mscharley/bs-querystringify/graphs/contributors | ||
[gh-issues]: https://github.com/mscharley/bs-querystringify/issues | ||
[license]: https://github.com/mscharley/bs-querystringify/blob/master/LICENSE |
2263
20