NodeJS 0.10.13을 사용하고 있습니다. 배열은 문자열이있는 경우 2 층과 3 map
호출이 오류를 반환하는 것이Path.resolve와 함께 사용하면 Array.forEach/.map 반환 오류가 발생합니다.
> var a = ['1','2','3']
undefined
> a.map(function(){return path.resolve(arguments[0])})
[ '/Users/user/1',
'/Users/user/2',
'/Users/user/3' ]
> a.map(path.resolve)
TypeError: Arguments to path.resolve must be strings
at exports.resolve (path.js:313:15)
> a.map(path.resolve.bind(path)))
TypeError: Arguments to path.resolve must be strings
at exports.resolve (path.js:313:15)
이유는 : 나는 다음과 같은 코드의 행동에 대해 그냥 궁금 해요? NodeJS의 소스 코드의 해당 라인에가는 것은이 산출 :
인수가 문자열이 아닌 이유에 대한 이해되지 않는다if (typeof path !== 'string') {
throw new TypeError('Arguments to path.resolve must be strings');
} else if (!path) {
continue;
}
. 아무도 단서가 있습니까?