diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..25fa621 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "typescript.tsdk": "node_modules/typescript/lib" +} diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..ac4b359 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,85 @@ +type ValueOf = T[keyof T]; + +export type Dtypes = { + "; + shape: number[]; + fortranOrder: boolean; + }; +}>; + +declare class npyjs { + + constructor(opts?: never); + + dtypes: Dtypes; + + parse(arrayBufferContents: ArrayBuffer): Parsed; + + load( + filename: RequestInfo | URL | ArrayBuffer, + callback?: (result?: Parsed) => any, + fetchArgs?: RequestInit + ): Promise; +} + +export default npyjs; diff --git a/package-lock.json b/package-lock.json index 023a845..d02c32f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,18 +1,19 @@ { "name": "npyjs", - "version": "0.4.0", + "version": "0.5.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "npyjs", - "version": "0.4.0", + "version": "0.5.0", "license": "Apache-2.0", "dependencies": { "cross-fetch": "^3.1.5" }, "devDependencies": { - "mocha": "^10.2.0" + "mocha": "^10.2.0", + "typescript": "4.1.x" }, "engines": { "node": "^12.20.0 || >=14.13.1" @@ -891,6 +892,19 @@ "integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o=", "license": "MIT" }, + "node_modules/typescript": { + "version": "4.1.6", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.1.6.tgz", + "integrity": "sha512-pxnwLxeb/Z5SP80JDRzVjh58KsM6jZHRAOtTpS7sXLS4ogXNKC9ANxHHZqLLeVHZN35jCtI4JdmLLbLiC1kBow==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, "node_modules/webidl-conversions": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", @@ -1609,6 +1623,12 @@ "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", "integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o=" }, + "typescript": { + "version": "4.1.6", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.1.6.tgz", + "integrity": "sha512-pxnwLxeb/Z5SP80JDRzVjh58KsM6jZHRAOtTpS7sXLS4ogXNKC9ANxHHZqLLeVHZN35jCtI4JdmLLbLiC1kBow==", + "dev": true + }, "webidl-conversions": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", diff --git a/package.json b/package.json index dbc600a..a147b41 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,8 @@ "node": "^12.20.0 || >=14.13.1" }, "devDependencies": { - "mocha": "^10.2.0" + "mocha": "^10.2.0", + "typescript": "4.1.x" }, "scripts": { "test": "mocha" diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..1de11ca --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,15 @@ +{ + // Change this to match your project + "include": ["index.js"], + "compilerOptions": { + // Tells TypeScript to read JS files, as + // normally they are ignored as source files + "allowJs": true, + // Generate d.ts files + "declaration": true, + // This compiler run should + // only output d.ts files + "emitDeclarationOnly": true, + "target": "ES6" + } +} \ No newline at end of file