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 e903f5c20d
commit 5f0da9deb8
11 changed files with 26 additions and 26 deletions

View file

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

View file

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

View file

@ -93,7 +93,7 @@ function initBasicServer(delay) {
function initPagingServer(dataLength, { delay, eventType = 'select' } = {}) {
let data = [];
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({

View file

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

View file

@ -6,9 +6,9 @@ export function generateAccount(name, isConnected, type, offbudget) {
return {
id: uuid.v4Sync(),
name,
balance_current: isConnected ? (Math.random() * 100000) | 0 : null,
bank: isConnected ? (Math.random() * 10000) | 0 : null,
bankId: isConnected ? (Math.random() * 10000) | 0 : null,
balance_current: isConnected ? Math.floor(Math.random() * 100000): null,
bank: isConnected ? Math.floor(Math.random() * 10000): null,
bankId: isConnected ? Math.floor(Math.random() * 10000): null,
bankName: isConnected ? 'boa' : null,
type: type || 'checking',
offbudget: offbudget ? 1 : 0,
@ -54,7 +54,7 @@ function _generateTransaction(data) {
const id = data.id || uuid.v4Sync();
return {
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'),
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) {
let pageCount = Math.max((numTransactions / 3) | 0, 3);
let pageCount = Math.max(Math.floor(numTransactions / 3), 3);
let pagedData = [];
let done = false;

View file

@ -22,7 +22,7 @@ export function keyToTimestamp(key) {
export function insert(trie, timestamp) {
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 });
return insertKey(trie, key, hash);

View file

@ -34,7 +34,7 @@ export function shoveSortOrders(items, targetId) {
} else {
if (target.sort_order - (before ? before.sort_order : 0) <= 2) {
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) {
// No need to update it if it's already greater than the current
// 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 item;
while ((item = src.pop())) {
let idx = (Math.random() * shuffled.length) | 0;
let idx = Math.floor(Math.random() * shuffled.length);
if (shuffled[idx]) {
src.push(item);
} else {

View file

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

View file

@ -24,11 +24,11 @@ global.Date.now = () => 123456789;
let seqId = 1;
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() {
return 'testing-uuid-' + ((Math.random() * 1000000) | 0);
return 'testing-uuid-' + Math.floor(Math.random() * 1000000);
};
global.__resetWorld = () => {