feat: 초기 프로젝트 설정 및 룰.md 파일 추가
This commit is contained in:
28
api.hyungi.net/node_modules/vizion/lib/helper.js
generated
vendored
Normal file
28
api.hyungi.net/node_modules/vizion/lib/helper.js
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
function trimNewLine(input) {
|
||||
return typeof(input) === 'string' ? input.replace(/\n/g, '') : input;
|
||||
}
|
||||
|
||||
function get(object, path) {
|
||||
const pathArray = path.split('.');
|
||||
let result = object;
|
||||
while (result != null && pathArray.length) {
|
||||
const pathItem = pathArray.shift();
|
||||
if (pathItem in result) {
|
||||
result = result[pathItem];
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function last(array) {
|
||||
var length = array == null ? 0 : array.length;
|
||||
return length ? array[length - 1] : undefined;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
get: get,
|
||||
last: last,
|
||||
trimNewLine: trimNewLine,
|
||||
};
|
||||
Reference in New Issue
Block a user