“Seq” Methods
_(value)
创建一个lodash
对象,包装value
后的对象启用隐式方法链。返回的数组、集合、方法相互之间能够链式调用。检索唯一值或返回原始值会自动解除链条并返回计算后的值,否则需要调用 _#value
方法解除链(即获得计算结果)。
显式链式调用,在任何情况下需要先用 _#value
解除链后,才能使用 _.chain
开启。
链式方法是惰性计算的,直到隐式或者显式调用了 _#value
才会执行计算。
惰性计算接受几种支持 shortcut fusion 的方法, shortcut fusion 是一种通过合并链式 iteratee 调用从而大大降低迭代的次数以提高执行性能的方式。 部分链有资格 shortcut fusion,如果它至少有超过200
个元素的数组和任何只接受一个参数的 iteratees。 触发的方式是任何一个 shortcut fusion 有了变化。
链式方法支持定制版本,只要 _#value
包含或者间接包含在版本中。
除了 lodash 的自身方法,包装后的对象还支持 Array
和 String
的方法。
支持 Array
的方法:
concat
, join
, pop
, push
, shift
, sort
, splice
, 和 unshift
支持 String
的方法:
replace
和 split
支持 shortcut fusion 的方法:
at
, compact
, drop
, dropRight
, dropWhile
, filter
, find
,
findLast
, head
, initial
, last
, map
, reject
, reverse
, slice
,
tail
, take
, takeRight
, takeRightWhile
, takeWhile
, 和 toArray
支持 链式调用 的方法:
after
, ary
, assign
, assignIn
, assignInWith
, assignWith
, at
,
before
, bind
, bindAll
, bindKey
, castArray
, chain
, chunk
,
commit
, compact
, concat
, conforms
, constant
, countBy
, create
,
curry
, debounce
, defaults
, defaultsDeep
, defer
, delay
,
difference
, differenceBy
, differenceWith
, drop
, dropRight
,
dropRightWhile
, dropWhile
, extend
, extendWith
, fill
, filter
,
flatMap
, flatMapDeep
, flatMapDepth
, flatten
, flattenDeep
,
flattenDepth
, flip
, flow
, flowRight
, fromPairs
, functions
,
functionsIn
, groupBy
, initial
, intersection
, intersectionBy
,
intersectionWith
, invert
, invertBy
, invokeMap
, iteratee
, keyBy
,
keys
, keysIn
, map
, mapKeys
, mapValues
, matches
, matchesProperty
,
memoize
, merge
, mergeWith
, method
, methodOf
, mixin
, negate
,
nthArg
, omit
, omitBy
, once
, orderBy
, over
, overArgs
,
overEvery
, overSome
, partial
, partialRight
, partition
, pick
,
pickBy
, plant
, property
, propertyOf
, pull
, pullAll
, pullAllBy
,
pullAllWith
, pullAt
, push
, range
, rangeRight
, rearg
, reject
,
remove
, rest
, reverse
, sampleSize
, set
, setWith
, shuffle
,
slice
, sort
, sortBy
, splice
, spread
, tail
, take
, takeRight
,
takeRightWhile
, takeWhile
, tap
, throttle
, thru
, toArray
,
toPairs
, toPairsIn
, toPath
, toPlainObject
, transform
, unary
,
union
, unionBy
, unionWith
, uniq
, uniqBy
, uniqWith
, unset
,
unshift
, unzip
, unzipWith
, update
, updateWith
, values
,
valuesIn
, without
, wrap
, xor
, xorBy
, xorWith
, zip
,
zipObject
, zipObjectDeep
, and zipWith
默认 不 支持 链式调用 的方法:
add
, attempt
, camelCase
, capitalize
, ceil
, clamp
, clone
,
cloneDeep
, cloneDeepWith
, cloneWith
, conformsTo
, deburr
,
defaultTo
, divide
, each
, eachRight
, endsWith
, eq
, escape
,
escapeRegExp
, every
, find
, findIndex
, findKey
, findLast
,
findLastIndex
, findLastKey
, first
, floor
, forEach
, forEachRight
,
forIn
, forInRight
, forOwn
, forOwnRight
, get
, gt
, gte
, has
,
hasIn
, head
, identity
, includes
, indexOf
, inRange
, invoke
,
isArguments
, isArray
, isArrayBuffer
, isArrayLike
, isArrayLikeObject
,
isBoolean
, isBuffer
, isDate
, isElement
, isEmpty
, isEqual
,
isEqualWith
, isError
, isFinite
, isFunction
, isInteger
, isLength
,
isMap
, isMatch
, isMatchWith
, isNaN
, isNative
, isNil
, isNull
,
isNumber
, isObject
, isObjectLike
, isPlainObject
, isRegExp
,
isSafeInteger
, isSet
, isString
, isUndefined
, isTypedArray
,
isWeakMap
, isWeakSet
, join
, kebabCase
, last
, lastIndexOf
,
lowerCase
, lowerFirst
, lt
, lte
, max
, maxBy
, mean
, meanBy
,
min
, minBy
, multiply
, noConflict
, noop
, now
, nth
, pad
,
padEnd
, padStart
, parseInt
, pop
, random
, reduce
, reduceRight
,
repeat
, result
, round
, runInContext
, sample
, shift
, size
,
snakeCase
, some
, sortedIndex
, sortedIndexBy
, sortedLastIndex
,
sortedLastIndexBy
, startCase
, startsWith
, stubArray
, stubFalse
,
stubObject
, stubString
, stubTrue
, subtract
, sum
, sumBy
,
template
, times
, toFinite
, toInteger
, toJSON
, toLength
,
toLower
, toNumber
, toSafeInteger
, toString
, toUpper
, trim
,
trimEnd
, trimStart
, truncate
, unescape
, uniqueId
, upperCase
,
upperFirst
, value
, and words
value
(*): 需要被包装为 lodash
实例的值。(Object): 返回 lodash
包装后的实例。
function square(n) { return n * n;} var wrapped = _([1, 2, 3]); // 返回未包装的值wrapped.reduce(_.add);// => 6 // 返回链式包装的值var squares = wrapped.map(square); _.isArray(squares);// => false _.isArray(squares.value());// => true
数组 Array
_.chunk
_.compact
_.concat
_.difference
_.differenceBy
_.differenceWith
_.drop
_.dropRight
_.dropRightWhile
_.dropWhile
_.fill
_.findIndex
_.findLastIndex
_.first
-> head
_.flatten
_.flattenDeep
_.flattenDepth
_.fromPairs
_.head
_.indexOf
_.initial
_.intersection
_.intersectionBy
_.intersectionWith
_.join
_.last
_.lastIndexOf
_.nth
_.pull
_.pullAll
_.pullAllBy
_.pullAllWith
_.pullAt
_.remove
_.reverse
_.slice
_.sortedIndex
_.sortedIndexBy
_.sortedIndexOf
_.sortedLastIndex
_.sortedLastIndexBy
_.sortedLastIndexOf
_.sortedUniq
_.sortedUniqBy
_.tail
_.take
_.takeRight
_.takeRightWhile
_.takeWhile
_.union
_.unionBy
_.unionWith
_.uniq
_.uniqBy
_.uniqWith
_.unzip
_.unzipWith
_.without
_.xor
_.xorBy
_.xorWith
_.zip
_.zipObject
_.zipObjectDeep
_.zipWith
集合 Collection
_.countBy
_.each
-> forEach
_.eachRight
-> forEachRight
_.every
_.filter
_.find
_.findLast
_.flatMap
_.flatMapDeep
_.flatMapDepth
_.forEach
_.forEachRight
_.groupBy
_.includes
_.invokeMap
_.keyBy
_.map
_.orderBy
_.partition
_.reduce
_.reduceRight
_.reject
_.sample
_.sampleSize
_.shuffle
_.size
_.some
_.sortBy
日期 Date
函数 Function
Lang
_.castArray
_.clone
_.cloneDeep
_.cloneDeepWith
_.cloneWith
_.conformsTo
_.eq
_.gt
_.gte
_.isArguments
_.isArray
_.isArrayBuffer
_.isArrayLike
_.isArrayLikeObject
_.isBoolean
_.isBuffer
_.isDate
_.isElement
_.isEmpty
_.isEqual
_.isEqualWith
_.isError
_.isFinite
_.isFunction
_.isInteger
_.isLength
_.isMap
_.isMatch
_.isMatchWith
_.isNaN
_.isNative
_.isNil
_.isNull
_.isNumber
_.isObject
_.isObjectLike
_.isPlainObject
_.isRegExp
_.isSafeInteger
_.isSet
_.isString
_.isSymbol
_.isTypedArray
_.isUndefined
_.isWeakMap
_.isWeakSet
_.lt
_.lte
_.toArray
_.toFinite
_.toInteger
_.toLength
_.toNumber
_.toPlainObject
_.toSafeInteger
_.toString
数学 Math
对象 Object
_.assign
_.assignIn
_.assignInWith
_.assignWith
_.at
_.create
_.defaults
_.defaultsDeep
_.entries
-> toPairs
_.entriesIn
-> toPairsIn
_.extend
-> assignIn
_.extendWith
-> assignInWith
_.findKey
_.findLastKey
_.forIn
_.forInRight
_.forOwn
_.forOwnRight
_.functions
_.functionsIn
_.get
_.has
_.hasIn
_.invert
_.invertBy
_.invoke
_.keys
_.keysIn
_.mapKeys
_.mapValues
_.merge
_.mergeWith
_.omit
_.omitBy
_.pick
_.pickBy
_.result
_.set
_.setWith
_.toPairs
_.toPairsIn
_.transform
_.unset
_.update
_.updateWith
_.values
_.valuesIn
Seq
字符串 String
_.camelCase
_.capitalize
_.deburr
_.endsWith
_.escape
_.escapeRegExp
_.kebabCase
_.lowerCase
_.lowerFirst
_.pad
_.padEnd
_.padStart
_.parseInt
_.repeat
_.replace
_.snakeCase
_.split
_.startCase
_.startsWith
_.template
_.toLower
_.toUpper
_.trim
_.trimEnd
_.trimStart
_.truncate
_.unescape
_.upperCase
_.upperFirst
_.words
实用函数 Util
_.attempt
_.bindAll
_.cond
_.conforms
_.constant
_.defaultTo
_.flow
_.flowRight
_.identity
_.iteratee
_.matches
_.matchesProperty
_.method
_.methodOf
_.mixin
_.noConflict
_.noop
_.nthArg
_.over
_.overEvery
_.overSome
_.property
_.propertyOf
_.range
_.rangeRight
_.runInContext
_.stubArray
_.stubFalse
_.stubObject
_.stubString
_.stubTrue
_.times
_.toPath
_.uniqueId
Properties
Methods