Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add .jsconfig to validate js code #315

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
node-version: 18.x
- run: npm install
- run: npx eslint .
- run: npx tsc -p jsconfig.json

test:
runs-on: ubuntu-latest
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/.idea
/node_modules
/test.js
/.nyc_output/
/coverage/
.tap/
Expand Down
13 changes: 13 additions & 0 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"compilerOptions": {
"checkJs": true,
"target": "ES2022",
"moduleResolution":"node",
"types": ["node"],
"maxNodeModuleJsDepth": 0,
},
"exclude": [
"node_modules",
"coverage"
]
}
2 changes: 1 addition & 1 deletion lib/BufferStream.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const Stream = require('stream');
module.exports = function(entry) {
return new Promise(function(resolve, reject) {
const chunks = [];
const bufferStream = Stream.Transform()
const bufferStream = new Stream.Transform()
.on('finish', function() {
resolve(Buffer.concat(chunks));
})
Expand Down
7 changes: 5 additions & 2 deletions lib/Decrypt.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function crc(ch, crc) {

if (ch.charCodeAt)
ch = ch.charCodeAt(0);

//@ts-ignore
return (bigInt(crc).shiftRight(8).and(0xffffff)).xor(table[bigInt(crc).xor(ch).and(0xff)]).value;
}

Expand All @@ -36,21 +36,24 @@ function Decrypt() {

Decrypt.prototype.update = function(h) {
this.key0 = crc(h, this.key0);
//@ts-ignore
this.key1 = bigInt(this.key0).and(255).and(4294967295).add(this.key1);
//@ts-ignore
this.key1 = bigInt(this.key1).multiply(134775813).add(1).and(4294967295).value;
this.key2 = crc(bigInt(this.key1).shiftRight(24).and(255), this.key2);
};


Decrypt.prototype.decryptByte = function(c) {
const k = bigInt(this.key2).or(2);
//@ts-ignore
c = c ^ bigInt(k).multiply(bigInt(k^1)).shiftRight(8).and(255);
this.update(c);
return c;
};

Decrypt.prototype.stream = function() {
const stream = Stream.Transform(),
const stream = new Stream.Transform(),
self = this;

stream._transform = function(d, e, cb) {
Expand Down
18 changes: 8 additions & 10 deletions lib/NoopStream.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
const Stream = require('stream');
const util = require('util');
function NoopStream() {
if (!(this instanceof NoopStream)) {
return new NoopStream();
}
Stream.Transform.call(this);
class NoopStream extends Stream.Transform {
_transform(d, e, cb) { cb() ;};
promise() {
return new Promise((resolve, reject) => {
this.on('finish', resolve);
this.on('error', reject);
});
};
}

util.inherits(NoopStream, Stream.Transform);

NoopStream.prototype._transform = function(d, e, cb) { cb() ;};

module.exports = NoopStream;
Loading
Loading