Skip to content

Commit

Permalink
resolve merge
Browse files Browse the repository at this point in the history
  • Loading branch information
evanshortiss committed Dec 15, 2016
2 parents 81ce845 + 21d2ecc commit 4c20ac0
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 18 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,14 @@ describe('concat.js', function () {

```

## TypeScript
To use with TypeScript, just import it like this:
```ts
import env from 'get-env';

const stringVar = env('STRING').required().asString();
```

## Contributors
* @MikeyBurkman
* @itavy
45 changes: 28 additions & 17 deletions env-var.d.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,33 @@

declare function E (varName: string, defaultValue?: string): E.IVariable;

declare namespace E {

interface IVariable {
required: () => IVariable,
asInt: () => number,
asFloat: () => number,
asPositiveInt: () => number,
asNegativeInt: () => number,
asString: () => string,
asJson: () => Object|Array<any>,
asBool: () => boolean,
asStrictBool: () => boolean,
}
export interface IPresentVariable {
asFloat: () => number;
asInt: () => number;
asPositiveInt: () => number;
asNegativeInt: () => number;
asString: () => string;
asJson: () => Object|Array<any>;
asBool: () => boolean;
asStrictBool: () => boolean;
}

function mock (mockValues: Object): (varName: string, defaultValue?: string) => E.IVariable;
export interface IOptionalVariable {
required: () => IPresentVariable;
asFloat: () => number|undefined;
asInt: () => number|undefined;
asPositiveInt: () => number|undefined;
asNegativeInt: () => number|undefined;
asString: () => string|undefined;
asJson: () => Object|Array<any>|undefined;
asBool: () => boolean|undefined;
asStrictBool: () => boolean|undefined;
}

export interface IEnv {
(): Object,
(varName: string): IOptionalVariable;
(varName: string, defaultValue: string): IPresentVariable;
mock(mockVars: Object): IEnv;
}

export = E;
export const env: IEnv;
export default env;
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@
],
"author": "Evan Shortiss",
"license": "MIT",
"files": ["lib/", "env-var.d.ts"],
"files": [
"lib/",
"env-var.d.ts"
],
"bugs": {
"url": "https://github.com/evanshortiss/env-var/issues"
},
Expand Down

0 comments on commit 4c20ac0

Please sign in to comment.