mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-23 12:56:46 +08:00
[r-script] Added typings. (#19027)
This commit is contained in:
committed by
Mohamed Hegazy
parent
b7b8a3650b
commit
05c8f3c833
32
types/r-script/index.d.ts
vendored
Normal file
32
types/r-script/index.d.ts
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
// Type definitions for r-script 0.0
|
||||
// Project: https://github.com/joshkatz/r-script
|
||||
// Definitions by: Adrian Leonhard <https://github.com/NaridaL/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
interface R {
|
||||
data(...args: any[]): this;
|
||||
call(callback: (err: any, d: any) => void): void;
|
||||
call(options: R.Options, callback: (err: any, d: any) => void): void;
|
||||
callSync(options?: R.Options): any;
|
||||
}
|
||||
declare namespace R {
|
||||
interface Options {
|
||||
dataframe?: "rows" | "colums" | "values";
|
||||
matrix?: "rowmajor" | "columnmajor";
|
||||
Date?: "ISO8601" | "epoch";
|
||||
POSIXt?: "string" | "ISO8601" | "epoch" | "mongo";
|
||||
factor?: "string" | "integer";
|
||||
complex?: "string" | "list";
|
||||
raw?: "base64" | "hex" | "mongo";
|
||||
null?: "list" | "null";
|
||||
na?: "null" | "string";
|
||||
auto_unbox?: boolean;
|
||||
digits?: number;
|
||||
pretty?: boolean;
|
||||
force?: boolean;
|
||||
[key: string]: any;
|
||||
}
|
||||
}
|
||||
declare function R(scriptPath: string): R;
|
||||
export = R;
|
||||
22
types/r-script/r-script-tests.ts
Normal file
22
types/r-script/r-script-tests.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import R = require('r-script');
|
||||
|
||||
function RPromise(r: R): Promise<any> {
|
||||
return new Promise((resolve, reject) => {
|
||||
r.call((err, d) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
} else {
|
||||
resolve(d);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
const options: R.Options = {
|
||||
dataframe: "rows",
|
||||
anotherRandomOption: true
|
||||
};
|
||||
const result1 = R("foo.R").data("string data param", "another one").callSync();
|
||||
const result2 = R("foo.R").data("string data param", "another one").callSync(options);
|
||||
R("foo.R").data("string data param", "another one").call(options, (err, d) => d);
|
||||
R("foo.R").data("string data param", "another one").call((err, d) => d);
|
||||
22
types/r-script/tsconfig.json
Normal file
22
types/r-script/tsconfig.json
Normal 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",
|
||||
"r-script-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/r-script/tslint.json
Normal file
1
types/r-script/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user