Merge pull request #15761 from CaselIT/master

Added types for rwlock
This commit is contained in:
Ryan Cavanaugh
2017-04-17 12:48:12 -07:00
committed by GitHub
4 changed files with 60 additions and 0 deletions
+30
View File
@@ -0,0 +1,30 @@
// Type definitions for RWLock v5.0.0
// Project: https://github.com/71104/rwlock
// Definitions by: Federico Caselli <https://github.com/CaselIT/typings-rwlock>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare class ReadWriteGeneric<T> {
readLock(callback: T, options?: ReadWriteLock.Options): void;
readLock(key: string, callback: T, options?: ReadWriteLock.Options): void;
writeLock(callback: T, options?: ReadWriteLock.Options): void;
writeLock(key: string, callback: T, options?: ReadWriteLock.Options): void;
}
declare namespace ReadWriteLock {
type Release = () => void;
type Callback = (release: Release) => void;
type AsyncCallback = (err: Error, release: Release) => void;
interface Options {
scope?: any;
timeout?: number;
timeoutCallback(): void;
}
}
declare class ReadWriteLock extends ReadWriteGeneric<ReadWriteLock.Callback> {
constructor();
async: ReadWriteGeneric<ReadWriteLock.AsyncCallback>;
}
export = ReadWriteLock;
+7
View File
@@ -0,0 +1,7 @@
// Original test file https://github.com/71104/rwlock/blob/master/test/all.js
import * as ReadWriteLock from 'rwlock';
const lock = new ReadWriteLock();
lock.readLock((release) => {
release();
});
+22
View File
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"rwlock-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "../tslint.json" }