diff --git a/precise/precise-tests.ts b/precise/precise-tests.ts new file mode 100644 index 000000000..029a69a3e --- /dev/null +++ b/precise/precise-tests.ts @@ -0,0 +1,9 @@ +/// + +import precise = require("precise"); + +var timer = precise().start(); + +setTimeout(function () { + console.log(timer.stop().diff()); +}, 1000); \ No newline at end of file diff --git a/precise/precise.d.ts b/precise/precise.d.ts new file mode 100644 index 000000000..3caba0297 --- /dev/null +++ b/precise/precise.d.ts @@ -0,0 +1,34 @@ +// Type definitions for precise +// Project: https://github.com/avoidwork/precise +// Definitions by: Peter Harris +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module "precise" { + /** + * Precise factory + */ + function _precise(): _precise.Precise; + + module _precise { + class Precise { + constructor(); + + /** + * Starts a timer + */ + start(): Precise; + + /** + * Stops a timer + */ + stop(): Precise; + + /** + * Returns the nanoseconds from `start()` to `stop()` + */ + diff(): number; + } + } + + export = _precise; +} \ No newline at end of file