售 价:¥
温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印
为你推荐
Lo-Dash Essentials
Table of Contents
Lo-Dash Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Working with Arrays and Collections
The difference between arrays and collections
Iterating over collections
Sorting data
Using sortBy()
Maintaining the sort order
Searching for data
Filtering collections
Finding items in collections
Slicing collections into smaller pieces
First and last collection portions
Splitting collections into chunks
Building unique arrays
Transforming collections
Grouping collection items
Counting collection items
Flattening and compacting
Validating some or all items
Unions, intersections, and differences
Summary
2. Working with Objects
Determining an object type
Type coercion
Managing function arguments
Arithmetic
Callable objects
Assigning and accessing properties
Extending objects
Defaults for new objects
Finding keys and values
Iterating over objects
Basic For Each
Including inherited properties
Keys and values
Calling methods
Getting results
Finding methods
Transforming objects
Using pairs
Picking and omitting properties
Inverting keys and values
Creating and cloning objects
Creating objects
Cloning objects
Summary
3. Working with Functions
Binding function contexts
Changing the this keyword
Binding methods
Dynamic methods
Decorating functions
Partials
Function decorators
Function constraints
Limiting call counts
Caching values
Timed execution
Delaying function calls
Deferring function calls
Throttling function calls
Debouncing function calls
Composing and currying functions
Composing functions
Currying functions
Summary
4. Transformations Using Map/Reduce
Plucking values
Mapping collections
Including and excluding properties
Performing calculations
Calling functions
Filtering and mapping
Mapping objects
Working with keys
Calling methods
Mapping key-value pairs
Reducing collections
Summing values
Filtering and reducing
Min, max, and average operations
Reducing objects
Reducing keys
Object accumulators
Binding contexts
Map/reduce patterns
Generic callback functions
Map/reduce chains
Summary
5. Assembling Chains
Creating Lo-Dash wrappers
Chained calls
Wrapping values
Explicit and implicit chaining
Building filters
Multiple filter() calls
Combining filter() with where()
Dropping and taking collection items
Rejecting items
Using initial() and rest()
Testing truth conditions
Testing if a collection contains an item
Everything or anything is true
Counting items
Using length and size()
Grouping using countBy()
Reducing collections
Transformations
Building groups, unions, and unique values
Plucking values
Creating arrays using without()
Finding the min and max values
Finding the index
Using difference() and xor()
Intermediary results
Tapping into chains
Injecting values
Keys and values
Filtered keys and values
Omitting and picking properties
Returning wrappers
Summary
6. Application Building Blocks
Generic functions
Specific functions
Generic function arguments
Using partials
Generic callbacks
Generic wrappers and chains
Generic filters
Returning chains
Composing functions
Composing generic functions
Composing callbacks
Composing chains
Method composition
Creating mixins
Creating an average() function
Creating a distance() function
Summary
7. Using Lo-Dash with Other Libraries
Modules
Organizing your code with modules
Requiring Lo-Dash
Working with Lo-Dash AMD modules
jQuery
Challenges faced by Lo-Dash
Challenges faced by jQuery
Using jQuery instances as collections
Binding functions
Working with jQuery deferred instances
Backbone
Replacing Underscore.js
Full-featured Lo-Dash and Backbone
Enhancing collections and models
Node.js
Installing the Lo-Dash package
Creating a simple command
Custom Lo-Dash builds
Summary
8. Internal Design and Performance
Design principles
Function compilation to base functions
Optimizing for the common case
Loops are simple
Callbacks and function binding
Improving performance
Changing the operation order
Sorting and indexing collections
Bound and unbound callbacks
Lazy evaluation
Caching things
Summary
Index
买过这本书的人还买过
读了这本书的人还在读
同类图书排行榜