Skip to content

Commit 6ec0667

Browse files
committed
chore: Format with new prettier version.
1 parent 673ec31 commit 6ec0667

File tree

6 files changed

+94
-71
lines changed

6 files changed

+94
-71
lines changed

.prettierrc.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
printWidth: 100
2+
trailingComma: "es5"

.restyled.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
restylers:
3+
- prettier:
4+
image: "restyled/restyler-prettier:v3.2.5-2"
5+
arguments: ["--print-width=100", "--trailing-comma=es5"]
6+
- clang-format:
7+
include:
8+
- "**/*.c*"
9+
- "**/*.h*"
10+
- "*"

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ RUN rm -rf \
4141
/work/js-toxcore-c*/node_modules \
4242
/work/js-toxcore-c*/coverage.lcov \
4343
/work/js-toxcore-c*/package-lock.json
44-
RUN diff -ru /work/js-toxcore-c /work/js-toxcore-c.orig
44+
RUN diff -ru /work/js-toxcore-c.orig /work/js-toxcore-c

examples/bin/promises-example.js

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -126,18 +126,19 @@ var initCallbacks = function (callback) {
126126
getStatus = tox.getFriendStatusAsync(e.friend()),
127127
getConnectionStatus = tox.getFriendConnectionStatusAsync(e.friend());
128128

129-
Promise.join(getName, getStatusMessage, getStatus, getConnectionStatus, function (
130-
name,
131-
statusMessage,
132-
status,
133-
connectionStatus
134-
) {
135-
console.log("Friend " + e.friend() + " profile:");
136-
console.log(" Name: " + name);
137-
console.log(" Status message: " + statusMessage);
138-
console.log(" Status: " + status);
139-
console.log(" Connection status: " + connectionStatus);
140-
});
129+
Promise.join(
130+
getName,
131+
getStatusMessage,
132+
getStatus,
133+
getConnectionStatus,
134+
function (name, statusMessage, status, connectionStatus) {
135+
console.log("Friend " + e.friend() + " profile:");
136+
console.log(" Name: " + name);
137+
console.log(" Status message: " + statusMessage);
138+
console.log(" Status: " + status);
139+
console.log(" Connection status: " + connectionStatus);
140+
}
141+
);
141142
}
142143

143144
if (e.message() === "lastonline") {

lib/tox.js

Lines changed: 60 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,16 +1032,18 @@ Tox.prototype.addFriendNoRequest = function (publicKey, callback) {
10321032
if (!this._checkHandle(callback)) return;
10331033
publicKey = fromHex(publicKey);
10341034
var eptr = ref.alloc(TOX_ERR_FRIEND_ADD);
1035-
this.getLibrary().tox_friend_add_norequest.async(this.getHandle(), publicKey, eptr, function (
1036-
err,
1037-
friend
1038-
) {
1039-
var terr = errors.friendAdd(eptr.deref());
1040-
if (!err && terr) err = terr;
1041-
if (callback) {
1042-
callback(err, friend);
1035+
this.getLibrary().tox_friend_add_norequest.async(
1036+
this.getHandle(),
1037+
publicKey,
1038+
eptr,
1039+
function (err, friend) {
1040+
var terr = errors.friendAdd(eptr.deref());
1041+
if (!err && terr) err = terr;
1042+
if (callback) {
1043+
callback(err, friend);
1044+
}
10431045
}
1044-
});
1046+
);
10451047
};
10461048

10471049
/**
@@ -1067,17 +1069,19 @@ Tox.prototype.addFriendNoRequestSync = function (publicKey) {
10671069
Tox.prototype.deleteFriend = function (friend, callback) {
10681070
if (!this._checkHandle(callback)) return;
10691071
var eptr = ref.alloc(TOX_ERR_FRIEND_DELETE);
1070-
this.getLibrary().tox_friend_delete.async(this.getHandle(), friend, eptr, function (
1071-
err,
1072-
success
1073-
) {
1074-
var terr = errors.friendDelete(eptr.deref());
1075-
if (!err && terr) err = terr;
1076-
if (!err && !success) err = errors.unsuccessful();
1077-
if (callback) {
1078-
callback(err);
1072+
this.getLibrary().tox_friend_delete.async(
1073+
this.getHandle(),
1074+
friend,
1075+
eptr,
1076+
function (err, success) {
1077+
var terr = errors.friendDelete(eptr.deref());
1078+
if (!err && terr) err = terr;
1079+
if (!err && !success) err = errors.unsuccessful();
1080+
if (callback) {
1081+
callback(err);
1082+
}
10791083
}
1080-
});
1084+
);
10811085
};
10821086

10831087
/**
@@ -1102,16 +1106,18 @@ Tox.prototype.getFriendByPublicKey = function (publicKey, callback) {
11021106
if (!this._checkHandle(callback)) return;
11031107
publicKey = fromHex(publicKey);
11041108
var eptr = ref.alloc(TOX_ERR_FRIEND_BY_PUBLIC_KEY);
1105-
this.getLibrary().tox_friend_by_public_key.async(this.getHandle(), publicKey, eptr, function (
1106-
err,
1107-
friend
1108-
) {
1109-
var terr = errors.friendByPublicKey(eptr.deref());
1110-
if (!err && terr) err = terr;
1111-
if (callback) {
1112-
callback(err, friend);
1109+
this.getLibrary().tox_friend_by_public_key.async(
1110+
this.getHandle(),
1111+
publicKey,
1112+
eptr,
1113+
function (err, friend) {
1114+
var terr = errors.friendByPublicKey(eptr.deref());
1115+
if (!err && terr) err = terr;
1116+
if (callback) {
1117+
callback(err, friend);
1118+
}
11131119
}
1114-
});
1120+
);
11151121
};
11161122

11171123
/**
@@ -1205,20 +1211,22 @@ Tox.prototype.hasFriendSync = function (friend) {
12051211
Tox.prototype.getFriendLastOnline = function (friend, callback) {
12061212
if (!this._checkHandle(callback)) return;
12071213
var eptr = ref.alloc(TOX_ERR_FRIEND_GET_LAST_ONLINE);
1208-
this.getLibrary().tox_friend_get_last_online.async(this.getHandle(), friend, eptr, function (
1209-
err,
1210-
timeval
1211-
) {
1212-
var terr = errors.friendGetLastOnline(eptr.deref());
1213-
if (!err && terr) err = terr;
1214+
this.getLibrary().tox_friend_get_last_online.async(
1215+
this.getHandle(),
1216+
friend,
1217+
eptr,
1218+
function (err, timeval) {
1219+
var terr = errors.friendGetLastOnline(eptr.deref());
1220+
if (!err && terr) err = terr;
12141221

1215-
var date;
1216-
if (!err) date = getDateFromUInt64(timeval);
1222+
var date;
1223+
if (!err) date = getDateFromUInt64(timeval);
12171224

1218-
if (callback) {
1219-
callback(err, date);
1225+
if (callback) {
1226+
callback(err, date);
1227+
}
12201228
}
1221-
});
1229+
);
12221230
};
12231231

12241232
/**
@@ -1530,17 +1538,20 @@ Tox.prototype.getTcpPortSync = function () {
15301538
Tox.prototype.setTyping = function (friend, typing, callback) {
15311539
if (!this._checkHandle(callback)) return;
15321540
var eptr = ref.alloc(TOX_ERR_SET_TYPING);
1533-
this.getLibrary().tox_self_set_typing.async(this.getHandle(), friend, typing, eptr, function (
1534-
err,
1535-
success
1536-
) {
1537-
var terr = errors.setTyping(eptr.deref());
1538-
if (!err && terr) err = terr;
1539-
if (!err && !success) err = errors.unsuccessful();
1540-
if (callback) {
1541-
callback(err);
1541+
this.getLibrary().tox_self_set_typing.async(
1542+
this.getHandle(),
1543+
friend,
1544+
typing,
1545+
eptr,
1546+
function (err, success) {
1547+
var terr = errors.setTyping(eptr.deref());
1548+
if (!err && terr) err = terr;
1549+
if (!err && !success) err = errors.unsuccessful();
1550+
if (callback) {
1551+
callback(err);
1552+
}
15421553
}
1543-
});
1554+
);
15441555
};
15451556

15461557
/**

test/tox.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ describe("Tox", function () {
9898
it("should throw an exception", function () {
9999
(function () {
100100
tox.getFriendByPublicKeySync(fakePublicKeys[0]);
101-
}.should.throw());
101+
}).should.throw();
102102
});
103103

104104
it("should return an exception (async)", function (done) {
@@ -113,7 +113,7 @@ describe("Tox", function () {
113113
it("should throw an exception", function () {
114114
(function () {
115115
tox.getFriendPublicKeySync(0);
116-
}.should.throw());
116+
}).should.throw();
117117
});
118118

119119
it("should return an exception (async)", function (done) {
@@ -128,7 +128,7 @@ describe("Tox", function () {
128128
it('should throw an exception if friend doesn"t exist', function () {
129129
(function () {
130130
tox.deleteFriendSync(0);
131-
}.should.throw());
131+
}).should.throw();
132132
});
133133

134134
it('should return an exception if friend doesn"t exist', function (done) {
@@ -158,7 +158,7 @@ describe("Tox", function () {
158158
var publicKey = fakePublicKeys[2];
159159
(function () {
160160
tox.getFriendByPublicKeySync(publicKey);
161-
}.should.throw());
161+
}).should.throw();
162162
// Add and try again
163163
var added = tox.addFriendNoRequestSync(publicKey);
164164
var retrieved = tox.getFriendByPublicKeySync(publicKey);
@@ -363,7 +363,7 @@ describe("Tox", function () {
363363
it("should throw a not-bound error if not listening on udp", function () {
364364
(function () {
365365
toxNoUdp.getUdpPortSync();
366-
}.should.throw());
366+
}).should.throw();
367367
});
368368

369369
it("should return a not-bound error if not listening on udp (async)", function (done) {
@@ -376,7 +376,7 @@ describe("Tox", function () {
376376
it("should throw an error if no handle", function () {
377377
(function () {
378378
toxDead.getUdpPortSync();
379-
}.should.throw());
379+
}).should.throw();
380380
});
381381

382382
it("should return an error if no handle (async)", function (done) {
@@ -391,7 +391,7 @@ describe("Tox", function () {
391391
it("should throw a not-bound error if not a tcp relay", function () {
392392
(function () {
393393
tox.getTcpPortSync();
394-
}.should.throw());
394+
}).should.throw();
395395
});
396396

397397
it("should return a not-bound error if not a tcp relay (async)", function (done) {
@@ -502,7 +502,7 @@ describe("Tox", function () {
502502
// Should throw TOX_ERR_DECRYPTION_FAILED
503503
(function () {
504504
new Tox({ data: edata, pass: "notThePass" });
505-
}.should.throw());
505+
}).should.throw();
506506
});
507507

508508
it("should not try to decrypt if no passphrase is given", function () {
@@ -512,7 +512,7 @@ describe("Tox", function () {
512512
// Should throw TOX_ERR_NEW_LOAD_ENCRYPTED
513513
(function () {
514514
new Tox({ data: edata });
515-
}.should.throw());
515+
}).should.throw();
516516
});
517517
});
518518

0 commit comments

Comments
 (0)