fix: replace last usages of | 0

This commit is contained in:
Tom French 2022-07-29 00:13:07 +01:00 committed by James Long
parent 6e15b985cb
commit 3a925948e2
11 changed files with 26 additions and 26 deletions

View file

@ -362,8 +362,8 @@ ipcMain.on('screenshot', () => {
let width = 1100; let width = 1100;
// This is for the main screenshot inside the frame // This is for the main screenshot inside the frame
clientWin.setSize(width, (width * (427 / 623)) | 0); clientWin.setSize(width, Math.floor(width * (427 / 623)));
// clientWin.setSize(width, (width * (495 / 700)) | 0); // clientWin.setSize(width, Math.floor(width * (495 / 700)));
} }
}); });

View file

@ -35,31 +35,31 @@ async function init() {
for (let i = 0; i < 100; i++) { for (let i = 0; i < 100; i++) {
if (Math.random() < 0.02) { if (Math.random() < 0.02) {
let parent = { let parent = {
date: '2020-01-' + pad((Math.random() * 30) | 0), date: '2020-01-' + pad(Math.floor(Math.random() * 30)),
amount: (Math.random() * 10000) | 0, amount: Math.floor(Math.random() * 10000),
account: accounts[0].id, account: accounts[0].id,
notes: 'foo' notes: 'foo'
}; };
db.insertTransaction(parent); db.insertTransaction(parent);
db.insertTransaction( db.insertTransaction(
makeChild(parent, { makeChild(parent, {
amount: (Math.random() * 1000) | 0 amount: Math.floor(Math.random() * 1000)
}) })
); );
db.insertTransaction( db.insertTransaction(
makeChild(parent, { makeChild(parent, {
amount: (Math.random() * 1000) | 0 amount: Math.floor(Math.random() * 1000)
}) })
); );
db.insertTransaction( db.insertTransaction(
makeChild(parent, { makeChild(parent, {
amount: (Math.random() * 1000) | 0 amount: Math.floor(Math.random() * 1000)
}) })
); );
} else { } else {
db.insertTransaction({ db.insertTransaction({
date: '2020-01-' + pad((Math.random() * 30) | 0), date: '2020-01-' + pad(Math.floor(Math.random() * 30)),
amount: (Math.random() * 10000) | 0, amount: Math.floor(Math.random() * 10000),
account: accounts[0].id account: accounts[0].id
}); });
} }

View file

@ -93,7 +93,7 @@ function initBasicServer(delay) {
function initPagingServer(dataLength, { delay, eventType = 'select' } = {}) { function initPagingServer(dataLength, { delay, eventType = 'select' } = {}) {
let data = []; let data = [];
for (let i = 0; i < dataLength; i++) { for (let i = 0; i < dataLength; i++) {
data.push({ id: i, date: subDays('2020-05-01', (i / 5) | 0) }); data.push({ id: i, date: subDays('2020-05-01', Math.floor(i / 5)) });
} }
initServer({ initServer({

View file

@ -11,7 +11,7 @@ import * as monthUtils from '../shared/months';
import q from '../shared/query'; import q from '../shared/query';
function pickRandom(list) { function pickRandom(list) {
return list[((Math.random() * list.length) | 0) % list.length]; return list[Math.floor(Math.random() * list.length) % list.length];
} }
function number(start, end) { function number(start, end) {
@ -19,7 +19,7 @@ function number(start, end) {
} }
function integer(start, end) { function integer(start, end) {
return number(start, end) | 0; return Math.round(number(start, end));
} }
function findMin(items, field) { function findMin(items, field) {
@ -104,7 +104,7 @@ async function fillPrimaryChecking(handlers, account, payees, groups) {
amount, amount,
payee: payee.id, payee: payee.id,
account: account.id, account: account.id,
date: monthUtils.subDays(monthUtils.currentDay(), (i / 3) | 0), date: monthUtils.subDays(monthUtils.currentDay(), Math.floor(i / 3)),
category: category.id category: category.id
}; };
transactions.push(transaction); transactions.push(transaction);
@ -244,7 +244,7 @@ async function fillChecking(handlers, account, payees, groups) {
amount, amount,
payee: payee.id, payee: payee.id,
account: account.id, account: account.id,
date: monthUtils.subDays(monthUtils.currentDay(), (i * 2) | 0), date: monthUtils.subDays(monthUtils.currentDay(), i * 2),
category: category.id category: category.id
}); });
} }
@ -334,7 +334,7 @@ async function fillSavings(handlers, account, payees, groups) {
amount, amount,
payee: payee.id, payee: payee.id,
account: account.id, account: account.id,
date: monthUtils.subDays(monthUtils.currentDay(), (i * 5) | 0), date: monthUtils.subDays(monthUtils.currentDay(), i * 5),
category: category.id category: category.id
}); });
} }

View file

@ -6,9 +6,9 @@ export function generateAccount(name, isConnected, type, offbudget) {
return { return {
id: uuid.v4Sync(), id: uuid.v4Sync(),
name, name,
balance_current: isConnected ? (Math.random() * 100000) | 0 : null, balance_current: isConnected ? Math.floor(Math.random() * 100000): null,
bank: isConnected ? (Math.random() * 10000) | 0 : null, bank: isConnected ? Math.floor(Math.random() * 10000): null,
bankId: isConnected ? (Math.random() * 10000) | 0 : null, bankId: isConnected ? Math.floor(Math.random() * 10000): null,
bankName: isConnected ? 'boa' : null, bankName: isConnected ? 'boa' : null,
type: type || 'checking', type: type || 'checking',
offbudget: offbudget ? 1 : 0, offbudget: offbudget ? 1 : 0,
@ -54,7 +54,7 @@ function _generateTransaction(data) {
const id = data.id || uuid.v4Sync(); const id = data.id || uuid.v4Sync();
return { return {
id: id, id: id,
amount: data.amount || (Math.random() * 10000 - 7000) | 0, amount: data.amount || Math.floor(Math.random() * 10000 - 7000),
payee: data.payee || (Math.random() < 0.9 ? 'payed-to' : 'guy'), payee: data.payee || (Math.random() < 0.9 ? 'payed-to' : 'guy'),
notes: notes:
Math.random() < 0.1 ? 'A really long note that should overflow' : 'Notes', Math.random() < 0.1 ? 'A really long note that should overflow' : 'Notes',

View file

@ -91,7 +91,7 @@ function expectTransactionOrder(data, fields) {
} }
async function expectPagedData(query, numTransactions, allData) { async function expectPagedData(query, numTransactions, allData) {
let pageCount = Math.max((numTransactions / 3) | 0, 3); let pageCount = Math.max(Math.floor(numTransactions / 3), 3);
let pagedData = []; let pagedData = [];
let done = false; let done = false;

View file

@ -22,7 +22,7 @@ export function keyToTimestamp(key) {
export function insert(trie, timestamp) { export function insert(trie, timestamp) {
let hash = timestamp.hash(); let hash = timestamp.hash();
let key = Number((timestamp.millis() / 1000 / 60) | 0).toString(3); let key = Number(Math.floor(timestamp.millis() / 1000 / 60)).toString(3);
trie = Object.assign({}, trie, { hash: trie.hash ^ hash }); trie = Object.assign({}, trie, { hash: trie.hash ^ hash });
return insertKey(trie, key, hash); return insertKey(trie, key, hash);

View file

@ -34,7 +34,7 @@ export function shoveSortOrders(items, targetId) {
} else { } else {
if (target.sort_order - (before ? before.sort_order : 0) <= 2) { if (target.sort_order - (before ? before.sort_order : 0) <= 2) {
let next = to; let next = to;
let order = (items[next].sort_order | 0) + SORT_INCREMENT; let order = Math.floor(items[next].sort_order) + SORT_INCREMENT;
while (next < items.length) { while (next < items.length) {
// No need to update it if it's already greater than the current // No need to update it if it's already greater than the current
// order. This can happen because there may already be large // order. This can happen because there may already be large

View file

@ -171,7 +171,7 @@ function shuffle(arr) {
let shuffled = new Array(src.length); let shuffled = new Array(src.length);
let item; let item;
while ((item = src.pop())) { while ((item = src.pop())) {
let idx = (Math.random() * shuffled.length) | 0; let idx = Math.floor(Math.random() * shuffled.length);
if (shuffled[idx]) { if (shuffled[idx]) {
src.push(item); src.push(item);
} else { } else {

View file

@ -7,7 +7,7 @@ let groups = ['y', 'r', 'b', 'n', 'g', 'p'];
let colors = {}; let colors = {};
list.forEach((color, idx) => { list.forEach((color, idx) => {
const group = (idx / 11) | 0; const group = Math.floor(idx / 11);
const n = idx % 11; const n = idx % 11;
colors[groups[group] + (n + 1)] = color; colors[groups[group] + (n + 1)] = color;

View file

@ -24,11 +24,11 @@ global.Date.now = () => 123456789;
let seqId = 1; let seqId = 1;
uuid.v4 = function() { uuid.v4 = function() {
return Promise.resolve('testing-uuid-' + ((Math.random() * 1000000) | 0)); return Promise.resolve('testing-uuid-' + Math.floor(Math.random() * 1000000));
}; };
uuid.v4Sync = function() { uuid.v4Sync = function() {
return 'testing-uuid-' + ((Math.random() * 1000000) | 0); return 'testing-uuid-' + Math.floor(Math.random() * 1000000);
}; };
global.__resetWorld = () => { global.__resetWorld = () => {