This commit is contained in:
Denis Sokolov
2016-01-28 11:02:31 +02:00
parent 86dbea8fc3
commit 67ea9ab52c
2 changed files with 36 additions and 0 deletions

13
once/once-tests.ts Normal file
View File

@@ -0,0 +1,13 @@
/// <reference path="once.d.ts" />
import once from "once";
once(() => 3);
once(() => 3)();
let s = once(() => ({foo: 1}))();
s.foo;
once.proto();
once(() => 3).called && true;
once(() => ({foo: 1})).value.foo;

23
once/once.d.ts vendored Normal file
View File

@@ -0,0 +1,23 @@
// Type definitions for once v1.3.3
// Project: https://github.com/isaacs/once
// Definitions by: Denis Sokolov <https://github.com/denis-sokolov>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
interface SimpleFunction<Result> {
(...args: any[]): Result;
}
interface OnceFunction<Result> extends SimpleFunction<Result> {
called: boolean;
value: Result;
}
interface Once {
<Result>(f: SimpleFunction<Result>): OnceFunction<Result>;
proto: Function;
}
declare module "once" {
var once: Once;
export default once;
}