19 function onUpdate(id: number, newName: string, newContents: string) {
20 setData((v) => {
21 if (!v) return v;
22 const x = [...v]; 23 x[v.findIndex((instance) => instance.id == id)].contents = newContents;
24 x[v.findIndex((instance) => instance.id == id)].friendly_name = newName;
25
19 function onUpdate(id: number, newName: string, newContents: string) {
20 setData((v) => {
21 if (!v) return v;
22 const x = [...v]; 23 x[v.findIndex((instance) => instance.id == id)].contents = newContents;
24 x[v.findIndex((instance) => instance.id == id)].friendly_name = newName;
25
1export type SuccessResponse = { success: boolean };
2
3export function guuid() {
4 let d = new Date().getTime(), 5 d2 = (performance && performance.now && performance.now() * 1000) || 0;
6 return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
7 let r = Math.random() * 16;
4 let d = new Date().getTime(),
5 d2 = (performance && performance.now && performance.now() * 1000) || 0;
6 return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
7 let r = Math.random() * 16; 8 if (d > 0) {
9 r = (d + r) % 16 | 0;
10 d = Math.floor(d / 16);
74 callback?: (x: T, code: number) => void,
75 headers: Record<string, string> = {}
76) {
77 const r = new Request(url, { 78 method: "GET", 79 headers: { 80 "X-Requested-With": "XMLHttpRequest", 81 ...headers, 82 }, 83 }); 84 http<T>(r, callback);
85}
86
Single character variable names affect code readability and complicate code refactoring, because of the difficulty in searching and replacing single characters.
This issue will not be raised for certain special identifiers, such as i
, j
or n
. It will also not be reported for the parameters used in for
and while
loops.
var a;
const l = 90
var age;
const limit = 90;
for(let o = 2; o < 10; o++){
sum += o
}