Array
_.chunk
_.compact
_.concat
_.difference
_.differenceBy
_.differenceWith
_.drop
_.dropRight
_.dropRightWhile
_.dropWhile
_.fill
_.findIndex
_.findLastIndex
_.flatten
_.flattenDeep
_.flattenDepth
_.fromPairs
_.head
_.indexOf
_.initial
_.intersection
_.intersectionBy
_.intersectionWith
_.join
_.last
_.lastIndexOf
_.nth
_.pull
_.pullAll
_.pullAllBy
_.pullAllWith
Collection
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
Math
Object
Seq
String
_.camelCase
_.capitalize
_.deburr
_.endsWith
_.escape
_.escapeRegExp
_.kebabCase
_.lowerCase
_.lowerFirst
_.pad
_.padEnd
_.padStart(string ='',length = 0,chars ='')
_.parseInt
_.repeat(string ='',n = 1)
_.replace(string ='',pattern,replacement)
_.snakeCase
_.split
_.startCase
_.startsWith
_.template
_.toLower
_.toUpper
_.trim
_.trimEnd(string ='',chars = whitespace)
_.trimStart
_.truncate
_.unescape
_.upperCase
_.upperFirst
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
Methods
创建一个lodash
包装value
以启用隐式方法链序列的对象。操作和返回数组,集合和函数的方法可以链接在一起。检索单个值或可能返回原始值的方法将自动结束链序列并返回展开的值。否则,该值必须用解包_#value
。
明确的链序列,其必须用包装除去 _#value
,可以使用被使能_.chain
。
链式方法的执行是懒惰的,也就是说,它被推迟到_#value
隐式或显式调用。
懒惰评估允许几种方法来支持快捷融合。快捷融合是优化合并迭代调用; 这可以避免创建中间数组,并且可以大大减少迭代执行次数。如果该节应用于数组并且迭代仅接受一个参数,则链序列的节可以用于快捷融合。是否有资格进行快捷方式融合的启发式可能会发生变化。
只要_#value
方法直接或间接包含在构建中,链接就支持在自定义构建中。
除了lodash方法,包装器Array
和String
方法。
包装Array
方法是:
concat
, join
, pop
, push
, shift
, sort
, splice
, and unshift
包装String
方法是:
replace
和split
支持快捷融合的封装方法是:
at
, compact
, drop
, dropRight
, dropWhile
, filter
, find
, findLast
, head
, initial
, last
, map
, reject
, reverse
, slice
, tail
, take
, takeRight
, takeRightWhile
, takeWhile
, and toArray
The chainable wrapper methods are:
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]); // Returns an unwrapped value. wrapped.reduce(_.add); // => 6 // Returns a wrapped value. var squares = wrapped.map(square); _.isArray(squares); // => false _.isArray(squares.value()); // => true