{"ScriptPreparationCode":"var BitFlags = {\r\n None: 0,\r\n One: 1 \u003C\u003C 0,\r\n Two: 1 \u003C\u003C 1,\r\n Three: 1 \u003C\u003C 2,\r\n Four: 1 \u003C\u003C 3,\r\n Five: 1 \u003C\u003C 4,\r\n Six: 1 \u003C\u003C 5,\r\n Seven: 1 \u003C\u003C 6,\r\n Eight: 1 \u003C\u003C 7,\r\n};\r\n\r\nfunction parseFlags(f) {\r\n return {\r\n one: !!(f \u0026 BitFlags.One),\r\n two: !!(f \u0026 BitFlags.Two),\r\n three: !!(f \u0026 BitFlags.Three),\r\n four: !!(f \u0026 BitFlags.Four),\r\n five: !!(f \u0026 BitFlags.Five),\r\n six: !!(f \u0026 BitFlags.Six),\r\n seven: !!(f \u0026 BitFlags.Seven),\r\n eight: !!(f \u0026 BitFlags.Eight),\r\n };\r\n}\r\n\r\nfunction toFlags(o) {\r\n var result = 0;\r\n if (o.one) result |= BitFlags.One;\r\n if (o.two) result |= BitFlags.Two;\r\n if (o.three) result |= BitFlags.Three;\r\n if (o.four) result |= BitFlags.Four;\r\n if (o.five) result |= BitFlags.Five;\r\n if (o.six) result |= BitFlags.Six;\r\n if (o.seven) result |= BitFlags.Seven;\r\n if (o.eight) result |= BitFlags.Eight;\r\n\r\n return result;\r\n}","TestCases":[{"Name":"BitFlags","Code":"// Create\r\nvar flags =\r\n BitFlags.One\r\n | BitFlags.Four\r\n | BitFlags.Six\r\n | BitFlags.Seven\r\n | BitFlags.Eight;\r\n\r\n// Read/Update\r\nif (flags \u0026 BitFlags.One) {\r\n flags |= BitFlags.Two;\r\n}\r\n\r\n// Deserialize\r\nvar o = parseFlags(flags);\r\n\r\n// Serialize\r\nvar f = toFlags(o);","IsDeferred":false},{"Name":"Plain object","Code":"// Create\r\nvar obj = {\r\n one: true,\r\n two: false,\r\n three: false,\r\n four: true,\r\n five: false,\r\n six: true,\r\n seven: true,\r\n eight: true,\r\n};\r\n\r\n// Read/Update\r\nif (obj.one) {\r\n obj.two = true;\r\n}\r\n\r\n// Serialize\r\nvar s = JSON.stringify(obj);\r\n\r\n// Deserialize\r\nvar o = JSON.parse(s);","IsDeferred":false}]}