๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๐Ÿง  ์•Œ๊ณ ๋ฆฌ์ฆ˜

๋ฐฑ์ค€ JS ์ž…๋ ฅ๊ฐ’ ํ…œํ”Œ๋ฆฟ(VSCode ์Šค๋‹ˆํŽซ์œผ๋กœ ์‰ฝ๊ฒŒ ์‚ฌ์šฉํ•˜๊ธฐ)

by megan07 2023. 12. 27.

๋ฐฑ์ค€์„ ์‚ฌ์šฉํ•˜๋‹ค๋ณด๋ฉด ์ž…๋ ฅ๊ฐ’์„ ๋ฐ›๋Š” ๊ฒŒ ๋„ˆ๋ฌด ๊ท€์ฐฎ์•˜๋Š”๋ฐ   
vscode์—์„œ ์Šค๋‹ˆํŽซ์„ ๋งŒ๋“ค์–ด์„œ ์‚ฌ์šฉํ•˜๋‹ˆ๊นŒ ๋„ˆ๋ฌด ํŽธํ•˜๋”๋ผ๊ตฌ์š”

์งœ์ž” bjt๋งŒ ์ž…๋ ฅํ•˜๋ฉด ์ž๋™์œผ๋กœ ์ž…๋ ฅ๊ฐ’ ํ…œํ”Œ๋ฆฟ์ด ์™„์„ฑ๋ฉ๋‹ˆ๋‹ค!

 


๋ฐฉ๋ฒ•

1. ํ•˜๋‹จ ํ†ฑ๋‹ˆ๋ฐ”ํ€ด๋ฅผ ๋ˆ„๋ฅด๋ฉด user snippets๋ž€ ๋ฉ”๋‰ด๊ฐ€ ๋‚˜์˜ต๋‹ˆ๋‹ค




2. ํด๋ฆญํ•ด์ฃผ์‹œ๋ฉด ์›ํ•˜๋Š” ์–ธ์–ด๋ฅผ ์„ ํƒํ•˜์‹ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ € ๊ฐ™์€ ๊ฒฝ์šฐ๋Š” js๋ฅผ ์„ ํƒํ–ˆ์–ด์š”


3. json ํ˜•์‹์œผ๋กœ ์Šค๋‹ˆํŽซ์„ ๋„ฃ๊ณ  ์ €์žฅํ•ด์ค๋‹ˆ๋‹ค




4. ์ด์ œ bjt๋งŒ ์ž…๋ ฅํ•˜๋ฉด ์ž๋™์™„์„ฑ๋ฉ๋‹ˆ๋‹ค!
์ฝ”๋“œ๋Š” ์ฃผ์„์ฒ˜๋ฆฌ๋˜์–ด ์žˆ์œผ๋‹ˆ ํ•„์š”ํ•œ ๊ฑธ๋กœ ์‚ฌ์šฉํ•˜์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค



json์— ๋“ค์–ด๊ฐˆ ๊ฐ’

 "Baekjoon JS Template": {
    "prefix": "bjt",
    "body": [
      "const filePath = process.platform === 'linux' ? '/dev/stdin' : './ํŒŒ์ผ๊ฒฝ๋กœ';",
      "//์ž…๋ ฅ๊ฐ’ 1๊ฐœ(1์ค„)",
      "// const input = require('fs').readFileSync(filePath).toString().trim();\n",
      "//์ž…๋ ฅ๊ฐ’ ์—ฌ๋Ÿฌ๊ฐœ (1์ค„)",
      "// let input = require('fs').readFileSync(filePath).toString().trim().split(' ');\n",

      "//์ž…๋ ฅ๊ฐ’ ์—ฌ๋Ÿฌ ์ค„",
      "// let input = require('fs').readFileSync(filePath).toString().trim().split('\\n');\n",

      "// ์ž…๋ ฅ๊ฐ’์ด ์ฒซ ๋ฒˆ์งธ ์ค„์—๋Š” ์ž…๋ ฅ ๊ฐ’์˜ ๊ธธ์ด(n), n๊ฐœ์˜ ์ค„์— ๊ฑธ์ณ์„œ ํ•œ ์ค„์— ํ•˜๋‚˜์˜ ์ž…๋ ฅ๊ฐ’์ด ์ฃผ์–ด์งˆ ๋•Œ",
      "// const [n, ...input] = require('fs').readFileSync(filePath).toString().trim().split('\\n');\n"
    ],
    "description": "๋ฐฑ์ค€ js ์ž…๋ ฅ๊ฐ’ ํ…œํ”Œ๋ฆฟ"
  }


js ์ž…๋ ฅ๊ฐ’ ํ…œํ”Œ๋ฆฟ ์ฝ”๋“œ

const filePath = process.platform === 'linux' ? '/dev/stdin' : './ํŒŒ์ผ๊ฒฝ๋กœ';
//์ž…๋ ฅ๊ฐ’ 1๊ฐœ(1์ค„)
// const input = require('fs').readFileSync(filePath).toString().trim();

//์ž…๋ ฅ๊ฐ’ ์—ฌ๋Ÿฌ๊ฐœ (1์ค„)
// let input = require('fs').readFileSync(filePath).toString().trim().split(' ');

//์ž…๋ ฅ๊ฐ’ ์—ฌ๋Ÿฌ ์ค„
// let input = require('fs').readFileSync(filePath).toString().trim().split('\n');

// ์ž…๋ ฅ๊ฐ’์ด ์ฒซ ๋ฒˆ์งธ ์ค„์—๋Š” ์ž…๋ ฅ ๊ฐ’์˜ ๊ธธ์ด(n), n๊ฐœ์˜ ์ค„์— ๊ฑธ์ณ์„œ ํ•œ ์ค„์— ํ•˜๋‚˜์˜ ์ž…๋ ฅ๊ฐ’์ด ์ฃผ์–ด์งˆ ๋•Œ
// const [n, ...input] = require('fs').readFileSync(filePath).toString().trim().split('\n');