_.countBy(collection, [iteratee=_.identity])
  • 주어진 조건으로 갯수를 셈.
_.each -> forEach
_.eachRight -> forEachRight
_.every(collection, [predicate=_.identity])
  • 모든 원소가 조건을 만족하면 true
_.filter(collection, [predicate=_.identity])
  • 주어진 조건을 만족하는 원소의 배열을 반환
_.find(collection, [predicate=_.identity], [fromIndex=0])
  • 주어진 조건을 만족하는 첫번째 원소를 찾음
_.findLast(collection, [predicate=_.identity], [fromIndex=collection.length-1])
  • 주어진 조건을 만족하는 마지막 원소를 찾음
_.flatMap(collection, [iteratee=_.identity])
  • 주어진 조건으로 변환 + 직렬화한 배열 반환
_.flatMapDeep(collection, [iteratee=_.identity])
  • _.flayMap + 재귀적 직렬화_.flatMapDepth
_.flatMapDepth(collection, [iteratee=_.identity], [depth=1])
  • _.flatMap + depth만큼 직렬화
_.forEach(collection, [iteratee=_.identity])
  • 집합의 각 원소에 대해 iteratee 실행
_.forEachRight(collection, [iteratee=_.identity])
  • _.forEach + 오른쪽 원소부터 실행
_.groupBy(collection, [iteratee=_.identity])
  • iteratee를 통한 그룹
_.includes(collection, value, [fromIndex=0])
  • index부터 시작해서 집합이 값을 포함하는지 확인 (문자열일 경우 문자열이 포함하는지 확인)
_.invokeMap(collection, path, [args])
_.keyBy(collection, [iteratee=_.identity])
  • iteratee로 생성된 key로 구성된 집합 반환
_.map(collection, [iteratee=_.identity])
  • iteratee로 각 원소 변환한 집합 반환
_.orderBy(collection, [iteratees=[_.identity]], [orders])
  • _.soryBy + 키 직접 지정 가능
_.partition(collection, [predicate=_.identity])
  • 조건으로 두그룹으로 분리
_.reduce(collection, [iteratee=_.identity], [accumulator])
_.reduceRight(collection, [iteratee=_.identity], [accumulator])

 

_.reject(collection, [predicate=_.identity])
  • _.filter의 반대

 

_.sample(collection)

  • 집합 내의 무작위 원소 추출

 

_.sampleSize(collection, [n=1])
  • n개의 유니크 원소 추출

 

_.shuffle(collection)
  •  

 

_.size(collection)
  • 집합의 사이즈 추출 (문자열이면 길이)

 

_.some(collection, [predicate=_.identity])
  • 배열에 조건을 만족하는 원소가 하나라도 있는지

 

_.sortBy(collection, [iteratees=[_.identity]])
  • iteratee로 집합 정렬

 

 

 

'공식메뉴얼 > lodash' 카테고리의 다른 글

Array  (0) 2020.06.27
Lodash란?  (1) 2020.06.27
_.chunk

사용법 :  _.chunk(array, [size=N]) is the 
용도 : 배열을 원하는 크기로 나눈다.

_.compact

사용법 : _.compact(array)
용도 : false, null, 0, "", undefined, NaN 등의 falsey값을 제거한 배열을 생성한다.

_.concat

사용법 : _.concat(array, [values])
용도 : 서로 다른 숫자나, 배열을 연결시켜 새로운 배열을 만든다.

_.difference

사용법 : _.difference(array, [values])
용도 : 두 배열에서 다른 원소를 찾아낸다.

_.differenceBy

사용법 : _.differenceBy(array, [values], [iteratee=_.identity])
용도 : _.difference + iteratee

_.differenceWith

사용법 :  _.differenceWith(array, [values], [comparator])
용도 : _.difference + comparator

_.drop

사용법 : _.drop(array, [n=1])
용도 : 앞에서부터 n개 원소를 제거함

_.dropRight

사용법 : _.dropRight(array, [n=1])
용도 : 뒤에서부터 n개 원소를 제거함

_.dropRightWhile

사용법 : _.dropRightWhile(array, [predicate=_.identity])
용도 : 조건이 falsey값을 반환할 때까지 뒤에서부터 제거

_.dropWhile

사용법 : _.dropWhile(array, [predicate=_.identity])
용도 : 조건이 falsey값을 반환할 때까지 앞에서부터 제거

_.fill

사용법 : _.fill(array, value, [start=0], [end=array.length])
용도 :  배열에 특정값을 채움

_.findIndex

사용법 : _.findIndex(array, [predicate=_.identity], [fromIndex=0])
용도 : 객체 배열에서 특정 조건에 해당하는 첫번째 객체의 인덱스를 찾음

_.findLastIndex

사용법 :_.findLastIndex(array, [predicate=_.identity], [fromIndex=array.length-1])
용도 :  객체 배열에서 특정 조건에 해당하는 마지막 객체의 인덱스를 찾음

_.first -> head

first -> head로 변경

_.flatten

사용법 : _.flatten(array)
용도 : 배열의 차원을 1차원 낮춤

_.flattenDeep

사용법 : _.flattenDeep(array)
용도 : 배열의 차원을 없앰

_.flattenDepth

사용법 : _.flattenDepth(array, [depth=1])
용도 :  depth만큼의 차원을 낮춤

_.fromPairs

사용법 : _.fromPairs(pairs)
용도 : key, value 배열을 객체로 바꿈 

_.head

사용법 : _.head(array)
용도 : 배열의 첫번째 원소를 반환함

_.indexOf

사용법 : _.indexOf(array, value, [fromIndex=0])
용도 : 배열에서 값의 인덱스 찾기

_.initial

사용법 : _.initial(array)
용도 : 배열의 마지막 원소를 제외한 모든 원소 추출

_.intersection

사용법 : _.intersection([arrays])
용도 : 배열 리스트 중 첫번째 배열과 나머지 배열들의 교집합 원소 추출

_.intersectionBy

사용법 : _.intersectionBy([arrays], [iteratee=_.identity])
용도 : _.intersection + iteratee

_.intersectionWith

사용법 : _.intersectionWith([arrays], [comparator])
용도 : _.intersection + comparator

_.join

사용법 : _.join(array, [separator=','])
용도 : 배열을 구분자를 사이에 두고 연결함

_.last

사용법 : _.last(array)
용도 : 배열의 마지막 원소를 찾음

_.lastIndexOf

사용법 : _.lastIndexOf(array, value, [fromIndex=array.length-1])
용도 :  _.indexOf + 오른쪽을 기준으로 왼쪽으로 검색

_.nth

사용법 : _.nth(array, [n=0])
용도 : 배열에서 n번째 요소 찾음

_.pull

사용법 : _.pull(array, values)
용도 : 배열에서 values에 포함된 값 제거

_.pullAll

사용법 : _.pullAll(array, [values])
용도 : _.pull + 제거할 값이 배열로 입력

_.pullAllBy

사용법 : _.pullAllBy(array, values, [iteratee=_.identity])
용도  : _.pullAll + iteratee

_.pullAllWith

사용법 : _.pullAllWith(array, values, [comparator])
용도 : _.pullAll + comparator

_.pullAt

사용법 : _.pullAt(array, [indexes])
용도 : index의 값을 제거하고, 제거한 index의 배열을 리턴함

_.remove

사용법 : _.remove(array, [predicate=_.identity])
용도 : predicate 조건으로 배열에서 원소를 제거

_.reverse

사용법 : _.reverse(array)
용도 : 배열을 원소 순서를 뒤집는다.

_.slice

사용법 : _.slice(array, [start=0], [end=array.length])
용도 : start ~ end-1 까지의 배열을 만든다.

_.sortedIndex

사용법 : _.sortedIndex(array, value)
용도 : 정렬을 유지한 상태로 삽입되기 위한 index를 찾는다. 

_.sortedIndexBy

사용법 : _.sortedIndexBy(array, value, [iteratee=_.identity])
용도 : _.sortedIndex + iteratee

_.sortedIndexOf

사용법 : _.sortedIndexOf(array, value)
용도 : _.indexOf + 정렬된 배열에서의 value index찾기

_.sortedLastIndex

사용법 : _.sortedLastIndex(array, value)
용도 : _.indexOf + 배열의 정렬 상태 유지하면서 삽입하기 위한 마지막 index

_.sortedLastIndexBy

사용법 : _.sortedLastIndexBy(array, value, [iteratee=_.identity])
용도 : .sortedLastIndex + iteratee

_.sortedLastIndexOf

사용법 : _.sortedLastIndexOf(array, value)
용도 : _.lastIndexOf + 배열의 정렬 상태 유지하면서 삽입하기 위한 마지막 index

_.sortedUniq

사용법 : _.sortedUniq(array)
용도 : _.uniq + 정렬

_.sortedUniqBy

사용법 : _.sortedUniqBy(array, [iteratee])
용도 : _.uniqBy + iteratee

_.tail

사용법 : _.tail(array)
용도 : 배열에서 첫번째 원소 제외한 나머지

_.take

사용법 : _.take(array, [n=1])
용도 : n크기 만큼의 배열만 선택

_.takeRight

사용법 : _.takeRight(array, [n=1])
용도 : 오른쪽에서 n크기 만큼의 배열만 선택

_.takeRightWhile

사용법 : _.takeRightWhile(array, [predicate=_.identity])
용도 : 오른쪽에서 predicate가 false를 반환할 때 까지의 배열 선택

_.takeWhile

사용법 : _.takeWhile(array, [predicate=_.identity])
용도 : 왼쪽에서 predicate가 false를 반환할 때 까지의 배열 선택

_.union

사용법 : _.union([arrays])
용도 : 중복 제외 배열 합치기

_.unionBy

사용법 : _.unionBy([arrays], [iteratee=_.identity])
용도 : _.union + iteratee

_.unionWith

사용법 : _.unionWith([arrays], [comparator])
용도 : _.unio + comparator

_.uniq

사용법 : _.uniq(array)
용도 : 중복제거

_.uniqBy

사용법 : _.uniqBy(array, [iteratee=_.identity])
용도 : _.uniq + iteratee

_.uniqWith

사용법 : _.uniqWith(array, [comparator])
용도 : _.uniq + comparator

_.unzip

사용법 : _.unzip(array)
용도 : 그룹화된 배열을 개별화

_.unzipWith

사용법 : _.unzipWith(array, [iteratee=_.identity])
용도 : _unzip + iteratee

_.without

사용법 : _.without(array, [values])
용도 : 배열에서 값 제거

_.xor

사용법 : _.xor([arrays])
용도 : 서로 다른 값으로 배열 제거

_.xorBy

사용법 : _.xorBy([arrays], [iteratee=_.identity])
용도 :  _.xor + iteratee

_.xorWith

사용법 : _.xorWith([arrays], [comparator])
용도 : _.xor + comparator

_.zip

사용법 : _.zip([arrays])
용도 : 배열을 그룹핑

_.zipObject

사용법 : _.zipObject([props=[]], [values=[]])
용도 : 배열을 key + value 객체로 그룹핑

_.zipObjectDeep

사용법 : _.zipObjectDeep([props=[]], [values=[]])
용도 : _.zipObject + 문자열에 속성 path를 허용

_.zipWith

사용법 : _.zipWith([arrays], [iteratee=_.identity])
용도 : _.zip + iteratee

'공식메뉴얼 > lodash' 카테고리의 다른 글

Collection  (0) 2020.07.12
Lodash란?  (1) 2020.06.27

Lodash란 js 라이브러리 공식 메뉴얼을 학습해보고자 한다.

"A modern JavaScript utility library delivering modularity, performance & extras" 

라고 공식 홈페이지에서 소개하고 있다.
jquery처럼 전역으로 선언해놓고 사용하면 유용하다. 특히 json으로 이루어진 배열을 다룰 때 또는 중첩 구조로 인해 객체 구조가 복잡해졌을 때 사용하면 유용하다.
유사한 라이브러리로는 underscore(https://underscorejs.org/)가 있으나, lodash가 브라우저 변화에 더 안정적이고, 더 많은 API와 성능 향상을 제공한다고 한다.
(참조 : https://benmccormick.org/2014/11/12/underscore-vs-lodash)

아래에 링크에 들어가면 메뉴얼이 잘 정리되어있으나, 학습을 위해 하나하나 뜯어보면서 기록해보기로 한다.

https://lodash.com/

 

Lodash

_.defaults({ 'a': 1 }, { 'a': 3, 'b': 2 });_.partition([1, 2, 3, 4], n => n % 2);DownloadLodash is released under the MIT license & supports modern environments. Review the build differences & pick one that’s right for you.InstallationIn

lodash.com

제공하는 카테고리 ? 

  • Array
  • Collection
  • Date
  • Function
  • Lang
  • Math
  • Number
  • Object
  • Seq
  • String
  • Util
  • Properties
  • methods

'공식메뉴얼 > lodash' 카테고리의 다른 글

Collection  (0) 2020.07.12
Array  (0) 2020.06.27

+ Recent posts