mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 18:36:30 +01:00 
			
		
		
		
	refactor(server/utils): get rid of isString
let's use typeof x === "string" → works exactly the same and at the same speed as this custom isString fn
This commit is contained in:
		| @@ -6,7 +6,7 @@ import eventService from "./events.js"; | |||||||
| import cls from "../services/cls.js"; | import cls from "../services/cls.js"; | ||||||
| import protectedSessionService from "../services/protected_session.js"; | import protectedSessionService from "../services/protected_session.js"; | ||||||
| import log from "../services/log.js"; | import log from "../services/log.js"; | ||||||
| import { newEntityId, isString, unescapeHtml, quoteRegex, toMap } from "../services/utils.js"; | import { newEntityId, unescapeHtml, quoteRegex, toMap } from "../services/utils.js"; | ||||||
| import revisionService from "./revisions.js"; | import revisionService from "./revisions.js"; | ||||||
| import request from "./request.js"; | import request from "./request.js"; | ||||||
| import path from "path"; | import path from "path"; | ||||||
| @@ -884,7 +884,7 @@ async function asyncPostProcessContent(note: BNote, content: string | Buffer) { | |||||||
|         return; |         return; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     if (note.hasStringContent() && !isString(content)) { |     if (note.hasStringContent() && typeof content !== "string") { | ||||||
|         content = content.toString(); |         content = content.toString(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -143,8 +143,6 @@ describe.todo("#normalize", () => {}); | |||||||
|  |  | ||||||
| describe.todo("#toMap", () => {}); | describe.todo("#toMap", () => {}); | ||||||
|  |  | ||||||
| describe.todo("#isString", () => {}); |  | ||||||
|  |  | ||||||
| describe("#envToBoolean", () => { | describe("#envToBoolean", () => { | ||||||
|     const testCases: TestCase<typeof utils.envToBoolean>[] = [ |     const testCases: TestCase<typeof utils.envToBoolean>[] = [ | ||||||
|         ["w/ 'true' it should return boolean 'true'", ["true"], true], |         ["w/ 'true' it should return boolean 'true'", ["true"], true], | ||||||
|   | |||||||
| @@ -295,10 +295,6 @@ export function toMap<T extends Record<string, any>>(list: T[], key: keyof T): R | |||||||
|     return map; |     return map; | ||||||
| } | } | ||||||
|  |  | ||||||
| export function isString(x: any) { |  | ||||||
|     return Object.prototype.toString.call(x) === "[object String]"; |  | ||||||
| } |  | ||||||
|  |  | ||||||
| // try to turn 'true' and 'false' strings from process.env variables into boolean values or undefined | // try to turn 'true' and 'false' strings from process.env variables into boolean values or undefined | ||||||
| export function envToBoolean(val: string | undefined) { | export function envToBoolean(val: string | undefined) { | ||||||
|     if (val === undefined || typeof val !== "string") return undefined; |     if (val === undefined || typeof val !== "string") return undefined; | ||||||
| @@ -357,7 +353,6 @@ export default { | |||||||
|     normalize, |     normalize, | ||||||
|     hashedBlobId, |     hashedBlobId, | ||||||
|     toMap, |     toMap, | ||||||
|     isString, |  | ||||||
|     getResourceDir, |     getResourceDir, | ||||||
|     isMac, |     isMac, | ||||||
|     isWindows, |     isWindows, | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user