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

Bump prettier from 2.0.5 to 3.2.5 #182

Merged
merged 2 commits into from Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .prettierrc.yml
@@ -1 +1,2 @@
printWidth: 100
trailingComma: "es5"
10 changes: 10 additions & 0 deletions .restyled.yaml
@@ -0,0 +1,10 @@
---
restylers:
- prettier:
image: "restyled/restyler-prettier:v3.2.5-2"
arguments: ["--print-width=100", "--trailing-comma=es5"]
- clang-format:
include:
- "**/*.c*"
- "**/*.h*"
- "*"
2 changes: 1 addition & 1 deletion Dockerfile
Expand Up @@ -41,4 +41,4 @@ RUN rm -rf \
/work/js-toxcore-c*/node_modules \
/work/js-toxcore-c*/coverage.lcov \
/work/js-toxcore-c*/package-lock.json
RUN diff -ru /work/js-toxcore-c /work/js-toxcore-c.orig
RUN diff -ru /work/js-toxcore-c.orig /work/js-toxcore-c
25 changes: 13 additions & 12 deletions examples/bin/promises-example.js
Expand Up @@ -126,18 +126,19 @@ var initCallbacks = function (callback) {
getStatus = tox.getFriendStatusAsync(e.friend()),
getConnectionStatus = tox.getFriendConnectionStatusAsync(e.friend());

Promise.join(getName, getStatusMessage, getStatus, getConnectionStatus, function (
name,
statusMessage,
status,
connectionStatus
) {
console.log("Friend " + e.friend() + " profile:");
console.log(" Name: " + name);
console.log(" Status message: " + statusMessage);
console.log(" Status: " + status);
console.log(" Connection status: " + connectionStatus);
});
Promise.join(
getName,
getStatusMessage,
getStatus,
getConnectionStatus,
function (name, statusMessage, status, connectionStatus) {
console.log("Friend " + e.friend() + " profile:");
console.log(" Name: " + name);
console.log(" Status message: " + statusMessage);
console.log(" Status: " + status);
console.log(" Connection status: " + connectionStatus);
}
);
}

if (e.message() === "lastonline") {
Expand Down
109 changes: 60 additions & 49 deletions lib/tox.js
Expand Up @@ -1032,16 +1032,18 @@
if (!this._checkHandle(callback)) return;
publicKey = fromHex(publicKey);
var eptr = ref.alloc(TOX_ERR_FRIEND_ADD);
this.getLibrary().tox_friend_add_norequest.async(this.getHandle(), publicKey, eptr, function (
err,
friend
) {
var terr = errors.friendAdd(eptr.deref());
if (!err && terr) err = terr;
if (callback) {
callback(err, friend);
this.getLibrary().tox_friend_add_norequest.async(
this.getHandle(),
publicKey,
eptr,
function (err, friend) {
var terr = errors.friendAdd(eptr.deref());
if (!err && terr) err = terr;
if (callback) {
callback(err, friend);
}
}
});
);
};

/**
Expand All @@ -1067,17 +1069,19 @@
Tox.prototype.deleteFriend = function (friend, callback) {
if (!this._checkHandle(callback)) return;
var eptr = ref.alloc(TOX_ERR_FRIEND_DELETE);
this.getLibrary().tox_friend_delete.async(this.getHandle(), friend, eptr, function (
err,
success
) {
var terr = errors.friendDelete(eptr.deref());
if (!err && terr) err = terr;
if (!err && !success) err = errors.unsuccessful();
if (callback) {
callback(err);
this.getLibrary().tox_friend_delete.async(
this.getHandle(),
friend,
eptr,
function (err, success) {
var terr = errors.friendDelete(eptr.deref());
if (!err && terr) err = terr;
if (!err && !success) err = errors.unsuccessful();
if (callback) {
callback(err);
}
}
});
);
};

/**
Expand All @@ -1102,16 +1106,18 @@
if (!this._checkHandle(callback)) return;
publicKey = fromHex(publicKey);
var eptr = ref.alloc(TOX_ERR_FRIEND_BY_PUBLIC_KEY);
this.getLibrary().tox_friend_by_public_key.async(this.getHandle(), publicKey, eptr, function (
err,
friend
) {
var terr = errors.friendByPublicKey(eptr.deref());
if (!err && terr) err = terr;
if (callback) {
callback(err, friend);
this.getLibrary().tox_friend_by_public_key.async(
this.getHandle(),
publicKey,
eptr,
function (err, friend) {
var terr = errors.friendByPublicKey(eptr.deref());
if (!err && terr) err = terr;
if (callback) {
callback(err, friend);
}
}
});
);
};

/**
Expand Down Expand Up @@ -1205,20 +1211,22 @@
Tox.prototype.getFriendLastOnline = function (friend, callback) {
if (!this._checkHandle(callback)) return;
var eptr = ref.alloc(TOX_ERR_FRIEND_GET_LAST_ONLINE);
this.getLibrary().tox_friend_get_last_online.async(this.getHandle(), friend, eptr, function (
err,
timeval
) {
var terr = errors.friendGetLastOnline(eptr.deref());
if (!err && terr) err = terr;
this.getLibrary().tox_friend_get_last_online.async(

Check warning on line 1214 in lib/tox.js

View check run for this annotation

Codecov / codecov/patch

lib/tox.js#L1214

Added line #L1214 was not covered by tests
this.getHandle(),
friend,
eptr,
function (err, timeval) {
var terr = errors.friendGetLastOnline(eptr.deref());
if (!err && terr) err = terr;

Check warning on line 1220 in lib/tox.js

View check run for this annotation

Codecov / codecov/patch

lib/tox.js#L1219-L1220

Added lines #L1219 - L1220 were not covered by tests

var date;
if (!err) date = getDateFromUInt64(timeval);
var date;
if (!err) date = getDateFromUInt64(timeval);

Check warning on line 1223 in lib/tox.js

View check run for this annotation

Codecov / codecov/patch

lib/tox.js#L1223

Added line #L1223 was not covered by tests

if (callback) {
callback(err, date);
if (callback) {
callback(err, date);

Check warning on line 1226 in lib/tox.js

View check run for this annotation

Codecov / codecov/patch

lib/tox.js#L1225-L1226

Added lines #L1225 - L1226 were not covered by tests
}
}
});
);
};

/**
Expand Down Expand Up @@ -1530,17 +1538,20 @@
Tox.prototype.setTyping = function (friend, typing, callback) {
if (!this._checkHandle(callback)) return;
var eptr = ref.alloc(TOX_ERR_SET_TYPING);
this.getLibrary().tox_self_set_typing.async(this.getHandle(), friend, typing, eptr, function (
err,
success
) {
var terr = errors.setTyping(eptr.deref());
if (!err && terr) err = terr;
if (!err && !success) err = errors.unsuccessful();
if (callback) {
callback(err);
this.getLibrary().tox_self_set_typing.async(

Check warning on line 1541 in lib/tox.js

View check run for this annotation

Codecov / codecov/patch

lib/tox.js#L1541

Added line #L1541 was not covered by tests
this.getHandle(),
friend,
typing,
eptr,
function (err, success) {
var terr = errors.setTyping(eptr.deref());
if (!err && terr) err = terr;
if (!err && !success) err = errors.unsuccessful();
if (callback) {
callback(err);

Check warning on line 1551 in lib/tox.js

View check run for this annotation

Codecov / codecov/patch

lib/tox.js#L1547-L1551

Added lines #L1547 - L1551 were not covered by tests
}
}
});
);
};

/**
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -53,7 +53,7 @@
"mktemp": "^1.0.0",
"mocha": "^10.2.0",
"nyc": "^15.0.1",
"prettier": "^2.0.5",
"prettier": "^3.2.5",
"should": "^13.2.3"
}
}
18 changes: 9 additions & 9 deletions test/tox.js
Expand Up @@ -98,7 +98,7 @@ describe("Tox", function () {
it("should throw an exception", function () {
(function () {
tox.getFriendByPublicKeySync(fakePublicKeys[0]);
}.should.throw());
}).should.throw();
});

it("should return an exception (async)", function (done) {
Expand All @@ -113,7 +113,7 @@ describe("Tox", function () {
it("should throw an exception", function () {
(function () {
tox.getFriendPublicKeySync(0);
}.should.throw());
}).should.throw();
});

it("should return an exception (async)", function (done) {
Expand All @@ -128,7 +128,7 @@ describe("Tox", function () {
it('should throw an exception if friend doesn"t exist', function () {
(function () {
tox.deleteFriendSync(0);
}.should.throw());
}).should.throw();
});

it('should return an exception if friend doesn"t exist', function (done) {
Expand Down Expand Up @@ -158,7 +158,7 @@ describe("Tox", function () {
var publicKey = fakePublicKeys[2];
(function () {
tox.getFriendByPublicKeySync(publicKey);
}.should.throw());
}).should.throw();
// Add and try again
var added = tox.addFriendNoRequestSync(publicKey);
var retrieved = tox.getFriendByPublicKeySync(publicKey);
Expand Down Expand Up @@ -363,7 +363,7 @@ describe("Tox", function () {
it("should throw a not-bound error if not listening on udp", function () {
(function () {
toxNoUdp.getUdpPortSync();
}.should.throw());
}).should.throw();
});

it("should return a not-bound error if not listening on udp (async)", function (done) {
Expand All @@ -376,7 +376,7 @@ describe("Tox", function () {
it("should throw an error if no handle", function () {
(function () {
toxDead.getUdpPortSync();
}.should.throw());
}).should.throw();
});

it("should return an error if no handle (async)", function (done) {
Expand All @@ -391,7 +391,7 @@ describe("Tox", function () {
it("should throw a not-bound error if not a tcp relay", function () {
(function () {
tox.getTcpPortSync();
}.should.throw());
}).should.throw();
});

it("should return a not-bound error if not a tcp relay (async)", function (done) {
Expand Down Expand Up @@ -502,7 +502,7 @@ describe("Tox", function () {
// Should throw TOX_ERR_DECRYPTION_FAILED
(function () {
new Tox({ data: edata, pass: "notThePass" });
}.should.throw());
}).should.throw();
});

it("should not try to decrypt if no passphrase is given", function () {
Expand All @@ -512,7 +512,7 @@ describe("Tox", function () {
// Should throw TOX_ERR_NEW_LOAD_ENCRYPTED
(function () {
new Tox({ data: edata });
}.should.throw());
}).should.throw();
});
});

Expand Down