Skip to content

Commit

Permalink
changes for type-checking and some JSDoc comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kungfooman committed Mar 18, 2023
1 parent ffa71f1 commit 8e6f1d5
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 4 deletions.
5 changes: 5 additions & 0 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"compilerOptions": {
"checkJs": true
}
}
24 changes: 21 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
},
"scripts": {
"build": "webpack",
"typegen": "tsc src/*.js --outDir dist/types --allowJs --declaration --emitDeclarationOnly",
"dev": "webpack serve --no-client-overlay",
"test": "node tests/index.js"
},
Expand All @@ -29,7 +30,8 @@
"homepage": "https://github.com/xenova/transformers.js#readme",
"dependencies": {
"jimp": "^0.22.7",
"onnxruntime-web": "^1.14.0"
"onnxruntime-web": "^1.14.0",
"typescript": "^5.0.2"
},
"devDependencies": {
"copy-webpack-plugin": "^11.0.0",
Expand Down
11 changes: 11 additions & 0 deletions src/tensor_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ class Tensor extends ONNX.Tensor {

}

/**
*
* @param {number} index
* @returns
*/
get(index) {
const iterDims = this.dims.slice(1);
if (iterDims.length > 0) {
Expand All @@ -46,6 +51,12 @@ class Tensor extends ONNX.Tensor {
return -1;
}

/**
* @param {number} index
* @param {number} iterSize
* @param {number} iterDims
* @returns {this}
*/
_subarray(index, iterSize, iterDims) {
let data = this.data.subarray(index * iterSize, (index + 1) * iterSize);
return new Tensor(this.type, data, iterDims);
Expand Down
3 changes: 3 additions & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ const fs = require('fs');
const { env } = require('./env.js');

class FileResponse {
/**
* @param {string} filePath
*/
constructor(filePath) {
this.filePath = filePath;
this.headers = {};
Expand Down

0 comments on commit 8e6f1d5

Please sign in to comment.