underscore
供应以下函数,非常轻易:
Underscore
供应了经常运用的函数。
Collections
- each
- map
- reduce
- reduceRight
- find
- filter
- where
- findWhere
- reject
- every
- some
- contains
- invoke
- pluck
- max
- min
- sortBy
- groupBy
- countBy
- shuffle
- toArray
- size
Arrays
- first
- initial
- last
- rest
- compact
- flatten
- without
- union
- intersection
- difference
- uniq
- zip
- unzip
- object
- indexOf
- lastIndexOf
- sortedIndex
- range
Functions
- bind
- bindAll
- partial
- memoize
- delay
- defer
- throttle
- debounce
- once
- after
- wrap
- compose
Objects
- keys
- values
- pairs
- invert
- functions
- extend
- pick
- omit
- defaults
- clone
- tap
- has
- isEqual
- isEmpty
- isElement
- isArray
- isObject
- isArguments
- isFunction
- isString
- isNumber
- isFinite
- isBoolean
- isDate
- isRegExp
- isNaN
- isNull
- isUnderfined
Utility
- noConflict
- identity
- times
- random
- mixin
- uniqueId
- escape
- unescape
- result
- template
Chaining
- chain
- value
Lo-Dash
建议运用Lo-Dash,机能优异许多的实现。
underscore.string
补充了underscore
缺乏的对字符串的操纵,不过有些其实JavaScript原生就带了。
- capitalize
- chop
- clean
- chars
- swapCase
- count
- escapeHTML
- unescapeHTML
- insert
- isBlank
- join
- lines
- reverse
- splice
- startsWith
- endsWith
- succ
- strip
- lstrip
- rstrip
- titleize
- camelize
- classify
- underscored
- dasherize
- humanize
- trim
- ltrim
- rtrim
- truncate
- prune
- words
- sprintf
- lpad
- rpad
- lrpad
- center
- ljust
- rjust
- toNumber
- strRight
- strRightBack
- strLeft
- strLeftBack
- stripTags
- toSentence
- toSentenceSerial
- repeat
- surround
- quote
- unquote
- slugify
- naturalCmp
- toBoolean
与Lo-Dash合营运用无压力。
其他语言
Underscore被移植到了其他语言,比方Underscore.lua和Underscore.php。