{"pageProps":{"code":{"catch.test.ts":{"name":"catch.test.ts","content":"import { sqrt } from './sqrt';\n\ndescribe('sqrt correctness', () => {\n  test('deals with valid bases', () => {\n    expect(sqrt(4)).toEqual(2);\n    expect(sqrt(2)).toBeCloseTo(1.414213, 5);\n  });\n  test('throws error on negatives', () => {\n    // Note that these require a function, not result\n    expect(() => sqrt(-2)).toThrow('Error: Input < 0');\n    expect(() => sqrt(-5)).toThrowError('Error: Input < 0');\n  });\n});\n","path":"code/1531/24T1/5.3/catch.test.ts","fileext":"ts"},"exception1.ts":{"name":"exception1.ts","content":"import prompt from 'prompt-sync';\nconst promptFn = prompt();\n\nfunction sqrt(x: number) {\n  if (x < 0) {\n    throw new Error('Error Input < 0');\n  }\n  return Math.pow(x, 0.5);\n}\n\nconst input = promptFn('Please enter a number: ');\nconsole.log(sqrt(parseInt(input)));\n","path":"code/1531/24T1/5.3/exception1.ts","fileext":"ts"},"exception2.ts":{"name":"exception2.ts","content":"import prompt from 'prompt-sync';\nconst promptFn = prompt();\n\nfunction sqrt(x: number) {\n  if (x < 0) {\n    throw new Error('Error Input < 0');\n  }\n  return Math.pow(x, 0.5);\n}\n\ntry {\n  const input = promptFn('Please enter a number: ');\n  console.log(sqrt(parseInt(input)));\n} catch (err) {\n  console.error(`Error when inputting! ${err}`);\n  const input = promptFn('Please enter a number: ');\n  console.log(sqrt(parseInt(input)));\n}\n","path":"code/1531/24T1/5.3/exception2.ts","fileext":"ts"},"exception3.ts":{"name":"exception3.ts","content":"import prompt from 'prompt-sync';\nconst promptFn = prompt();\n\nfunction sqrt(x: number) {\n  if (x < 0) {\n    throw new Error('Error Input < 0');\n  }\n  return Math.pow(x, 0.5);\n}\n\nlet success = false;\nwhile (!success) {\n  try {\n    const input = promptFn('Please enter a number: ');\n    console.log(sqrt(parseInt(input)));\n    success = true;\n  } catch (err) {\n    console.error(`Error when inputting! ${err}`);\n  }\n}\n","path":"code/1531/24T1/5.3/exception3.ts","fileext":"ts"},"jest.config.js":{"name":"jest.config.js","content":"module.exports = {\n  preset: 'ts-jest',\n  testEnvironment: 'node',\n  maxWorkers: 1,\n};\n","path":"code/1531/24T1/5.3/jest.config.js","fileext":"js"},"just_crash.ts":{"name":"just_crash.ts","content":"import prompt from 'prompt-sync';\nconst promptFn = prompt();\n\nfunction sqrt(x: number) {\n  if (x < 0) {\n    console.error('Error Input < 0');\n    process.exit(1);\n  }\n  return Math.pow(x, 0.5);\n}\n\nconst input = promptFn('Please enter a number: ');\nconsole.log(sqrt(parseInt(input)));\n","path":"code/1531/24T1/5.3/just_crash.ts","fileext":"ts"},"package.json":{"name":"package.json","content":"{\n  \"name\": \"env2\",\n  \"version\": \"1.0.0\",\n  \"description\": \"\",\n  \"main\": \"index.js\",\n  \"scripts\": {\n    \"test\": \"jest src\",\n    \"tsc\": \"tsc --noImplicitAny\",\n    \"lint\": \"eslint src/**.ts\",\n    \"lint-fix\": \"eslint --fix src/**.ts\",\n    \"ts-node\": \"ts-node\",\n    \"jest\": \"jest\",\n    \"nodemon\": \"nodemon\",\n    \"ts-node-coverage\": \"nyc --reporter=text --reporter=lcov ts-node\"\n  },\n  \"author\": \"\",\n  \"license\": \"ISC\",\n  \"devDependencies\": {\n    \"@types/express\": \"^4.17.13\",\n    \"@types/http-errors\": \"^1.8.2\",\n    \"@types/jest\": \"^27.5.0\",\n    \"@types/node\": \"^17.0.27\",\n    \"@types/prompt-sync\": \"^4.1.1\",\n    \"@typescript-eslint/eslint-plugin\": \"^5.21.0\",\n    \"@typescript-eslint/parser\": \"^5.21.0\",\n    \"eslint\": \"^8.14.0\",\n    \"eslint-plugin-jest\": \"^26.1.5\",\n    \"jest\": \"^28.1.0\",\n    \"middleware-http-errors\": \"^0.1.0\",\n    \"nodemon\": \"^2.0.16\",\n    \"nyc\": \"^15.1.0\",\n    \"ts-jest\": \"^28.0.2\",\n    \"typescript\": \"^4.6.3\"\n  },\n  \"dependencies\": {\n    \"express\": \"^4.18.0\",\n    \"http-errors\": \"^2.0.0\",\n    \"sync-request\": \"^6.1.0\",\n    \"ts-node\": \"^10.7.0\"\n  }\n}\n","path":"code/1531/24T1/5.3/package.json","fileext":"json"},"sqrt.ts":{"name":"sqrt.ts","content":"function sqrt(x: number) {\n  if (x < 0) {\n    throw new Error('Error Input < 0');\n  }\n  return Math.pow(x, 0.5);\n}\n\nexport { sqrt };\n","path":"code/1531/24T1/5.3/sqrt.ts","fileext":"ts"},"throw_catch.ts":{"name":"throw_catch.ts","content":"function sqrt(x: number) {\n  if (x < 0) {\n    throw new Error('Error Input < 0');\n  }\n  return Math.pow(x, 0.5);\n}\n\nif (process.argv.length === 3) {\n  try {\n    console.log(sqrt(parseInt(process.argv[2])));\n    console.log('Never called if error!');\n  } catch (err) {\n    console.error(`Error when inputting! ${err}`);\n  }\n}\n","path":"code/1531/24T1/5.3/throw_catch.ts","fileext":"ts"},"tsconfig.json":{"name":"tsconfig.json","content":"{\n    \"compilerOptions\": {\n        \"esModuleInterop\": true,\n        \"noImplicitAny\": false,\n        \"noEmit\": true,\n        \"resolveJsonModule\": true\n    },\n    \"exclude\": [\n      \"**/**_broken.ts\"\n    ]\n}\n\n","path":"code/1531/24T1/5.3/tsconfig.json","fileext":"json"}}},"__N_SSG":true}