Skip to content

Instantly share code, notes, and snippets.

@yjb94
Created January 18, 2019 09:59
Show Gist options
  • Save yjb94/bdea776f487b57094710fa375959e329 to your computer and use it in GitHub Desktop.
Save yjb94/bdea776f487b57094710fa375959e329 to your computer and use it in GitHub Desktop.
이/가 을/를 은/는 과/와 이여/여 으로/로 조사 포함 문자열 반환 코드
/**
* @crated JongBae Yun <jbyun94@naver.com>
* @license MIT
*/
import * as hangul from 'hangul-js';
export const josa = (function() {
return {
iGa: (input) => {
return hangul.endsWithConsonant(input) ? `${input}이` : `${input}가`;
},
eulReul: (input) => {
return hangul.endsWithConsonant(input) ? `${input}을` : `${input}를`;
},
eunNeun: (input) => {
return hangul.endsWithConsonant(input) ? `${input}은` : `${input}는`;
},
gwaWa: (input) => {
return hangul.endsWithConsonant(input) ? `${input}과` : `${input}와`;
},
iyeoYeo: (input) => {
return hangul.endsWithConsonant(input) ? `${input}이여` : `${input}여`;
},
roEuro: (input) => {
const j = hangul.endsWithConsonant(input);
const r = hangul.disassemble(input).pop() !== 'ㄹ'
return j && r ? `${input}으로` : `${input}로`;
},
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment