Lo-Dash Essentials
eBook - ePub

Lo-Dash Essentials

Adam Boduch

Compartir libro
  1. 232 páginas
  2. English
  3. ePUB (apto para móviles)
  4. Disponible en iOS y Android
eBook - ePub

Lo-Dash Essentials

Adam Boduch

Detalles del libro
Vista previa del libro
Índice
Citas

Preguntas frecuentes

¿Cómo cancelo mi suscripción?
Simplemente, dirígete a la sección ajustes de la cuenta y haz clic en «Cancelar suscripción». Así de sencillo. Después de cancelar tu suscripción, esta permanecerá activa el tiempo restante que hayas pagado. Obtén más información aquí.
¿Cómo descargo los libros?
Por el momento, todos nuestros libros ePub adaptables a dispositivos móviles se pueden descargar a través de la aplicación. La mayor parte de nuestros PDF también se puede descargar y ya estamos trabajando para que el resto también sea descargable. Obtén más información aquí.
¿En qué se diferencian los planes de precios?
Ambos planes te permiten acceder por completo a la biblioteca y a todas las funciones de Perlego. Las únicas diferencias son el precio y el período de suscripción: con el plan anual ahorrarás en torno a un 30 % en comparación con 12 meses de un plan mensual.
¿Qué es Perlego?
Somos un servicio de suscripción de libros de texto en línea que te permite acceder a toda una biblioteca en línea por menos de lo que cuesta un libro al mes. Con más de un millón de libros sobre más de 1000 categorías, ¡tenemos todo lo que necesitas! Obtén más información aquí.
¿Perlego ofrece la función de texto a voz?
Busca el símbolo de lectura en voz alta en tu próximo libro para ver si puedes escucharlo. La herramienta de lectura en voz alta lee el texto en voz alta por ti, resaltando el texto a medida que se lee. Puedes pausarla, acelerarla y ralentizarla. Obtén más información aquí.
¿Es Lo-Dash Essentials un PDF/ePUB en línea?
Sí, puedes acceder a Lo-Dash Essentials de Adam Boduch en formato PDF o ePUB, así como a otros libros populares de Computer Science y Programming in JavaScript. Tenemos más de un millón de libros disponibles en nuestro catálogo para que explores.

Información

Año
2015
ISBN
9781784398330

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

Lo-Dash Essentials

Copyright © 2015 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: January 2015
Production reference: 1210115
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78439-833-0
www.packtpub.com

Credits

Author
Adam Boduch
Reviewers
Joe Grund
Richard Hubers
Tyler Morgan
Francois-Guillaume Ribreau
Matt Traynham
Commissioning Editor
Dipika Gaonkar
Acquisition Editor
Meeta Rajani
Content Development Editor
Pooja Nair
Technical Editor
Mrunal M. Chavan
Copy Editors
Vikrant Phadkay
Rashmi Sawant
Project Coordinator
Suzanne Coutinho
Proofreaders
Kevin McGowan
Ameesha Green
Lucy Rowland
Indexers
Priya Sane
Tejal Soni
Production Coordinator
Komal Ramchandani
Cover Work
Komal Ramchandani

About the Author

Adam Boduch is a senior frontend engineer from Toronto. He currently works on delivering innovative products at Virtustream. Adam loves tinkering with the latest JavaScript libraries and is passionate about high-performance user interfaces.
Having focused on writing about jQuery in jQuery UI Themes Beginner's Guide and jQuery UI Cookbook, both by Packt Publishing, Adam has ventured into a new territory with this title, Lo-Dash Essentials. He is an avid proponent of Backbone and the ecosystem that surrounds it.

About the Reviewers

Joe Grund is a full-stack software engineer. He has written numerous rich applications utilizing the latest technologies and methodologies. Joe enjoys writing terse JavaScript code in a functional style and building real-time systems. He works at Intel, where he uses JavaScript to solve interesting problems. He lives in Orlando and can be found on Twitter (@joegrund), GitHub (jgrund), and his blog (joegrund.com), where he muses about building complex systems out of simple functional primitives.
Richard Hubers is an all-round web developer with more than 15 years of experience. He likes writing web apps and APIs in JavaScript and .NET, and learning the newest and latest technologies. He lives and works in Amsterdam.
Tyler Morgan is a renowned Ruby developer. He loves the JavaScript landscape, especially Node.js. He is an instructor of an intensive full-stack JavaScript development course at Code Fellows, located in Seattle, Washington.
Francois-Guillaume Ribreau is a full-stack developer and Frenc...

Índice