MCPcopy Index your code
hub / github.com/easydiffusion/easydiffusion / parseBoolean

Function parseBoolean

ui/media/js/dnd.js:7–38  ·  view source on GitHub ↗
(stringValue)

Source from the content-addressed store, hash-verified

5const IMAGE_EXTENSIONS = ["jpg", "jpeg", "png", "bmp", "tiff", "tif", "tga", "webp"]
6
7function parseBoolean(stringValue) {
8 if (typeof stringValue === "boolean") {
9 return stringValue
10 }
11 if (typeof stringValue === "number") {
12 return stringValue !== 0
13 }
14 if (typeof stringValue !== "string") {
15 return false
16 }
17 switch (stringValue?.toLowerCase()?.trim()) {
18 case "true":
19 case "yes":
20 case "on":
21 case "1":
22 return true
23
24 case "false":
25 case "no":
26 case "off":
27 case "0":
28 case "none":
29 case null:
30 case undefined:
31 return false
32 }
33 try {
34 return Boolean(JSON.parse(stringValue))
35 } catch {
36 return Boolean(stringValue)
37 }
38}
39
40// keep in sync with `ui/easydiffusion/utils/save_utils.py`
41const TASK_MAPPING = {

Callers 1

dnd.jsFile · 0.85

Calls 1

parseMethod · 0.80

Tested by

no test coverage detected