100% found this document useful (2 votes)
17 views

JavaScript Frameworks for Modern Web Dev 1st Edition Ambler Tim 2024 scribd download

Frameworks

Uploaded by

aneeqmajidtp
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
17 views

JavaScript Frameworks for Modern Web Dev 1st Edition Ambler Tim 2024 scribd download

Frameworks

Uploaded by

aneeqmajidtp
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 65

Download the Full Version of textbook for Fast Typing at textbookfull.

com

JavaScript Frameworks for Modern Web Dev 1st


Edition Ambler Tim

https://textbookfull.com/product/javascript-frameworks-for-
modern-web-dev-1st-edition-ambler-tim/

OR CLICK BUTTON

DOWNLOAD NOW

Download More textbook Instantly Today - Get Yours Now at textbookfull.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

Web Application Security Exploitation and Countermeasures


for Modern Web Applications 1st Edition Andrew Hoffman

https://textbookfull.com/product/web-application-security-
exploitation-and-countermeasures-for-modern-web-applications-1st-
edition-andrew-hoffman/
textboxfull.com

Web Application Security Exploitation and Countermeasures


for Modern Web Applications 1st Edition Andrew Hoffman

https://textbookfull.com/product/web-application-security-
exploitation-and-countermeasures-for-modern-web-applications-1st-
edition-andrew-hoffman-2/
textboxfull.com

JavaScript on Things: Hacking hardware for web developers


Lyza Danger Gardner

https://textbookfull.com/product/javascript-on-things-hacking-
hardware-for-web-developers-lyza-danger-gardner/

textboxfull.com

Modern Web Development on the JAMstack Modern techniques


for ultra fast sites and web applications 1st Edition
Mathias Biilmann
https://textbookfull.com/product/modern-web-development-on-the-
jamstack-modern-techniques-for-ultra-fast-sites-and-web-
applications-1st-edition-mathias-biilmann/
textboxfull.com
Learn Java for Web Development Modern Java Web Development
Layka Vishal

https://textbookfull.com/product/learn-java-for-web-development-
modern-java-web-development-layka-vishal/

textboxfull.com

JavaScript Cookbook: Programming the Web 3rd Edition Scott

https://textbookfull.com/product/javascript-cookbook-programming-the-
web-3rd-edition-scott/

textboxfull.com

PHP Web Services APIs for the Modern Web 2nd Edition Lorna
Jane Mitchell

https://textbookfull.com/product/php-web-services-apis-for-the-modern-
web-2nd-edition-lorna-jane-mitchell/

textboxfull.com

Full stack development with JHipster build full stack


applications and microservices with Spring Boot and modern
JavaScript frameworks Second Edition Sendil Kumar N.
https://textbookfull.com/product/full-stack-development-with-jhipster-
build-full-stack-applications-and-microservices-with-spring-boot-and-
modern-javascript-frameworks-second-edition-sendil-kumar-n/
textboxfull.com

Ultimate Modern jQuery for Web App Development 1st Edition


Laurence Svekis

https://textbookfull.com/product/ultimate-modern-jquery-for-web-app-
development-1st-edition-laurence-svekis/

textboxfull.com
I
Fa Ma Kn Re Grun nclu
ye ch oc q t, de
, Q , ko uir Ye s B
, A Mo ut eJ om o
sy ng , A S,B a we
nc o ng ro n, r,
.js ose ul w PM
, U , ar se 2
nd K n JS, rif ,
er ex, Kr y,
sco B ak
re, ook en
an she ,
d L lf,
od
as
h

www.it-ebooks.info
JavaScript Frameworks
for Modern Web Dev

Tim Ambler
Nicholas Cloud

www.it-ebooks.info
JavaScript Frameworks for Modern Web Dev
Copyright © 2015 by Tim Ambler and Nicholas Cloud
This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the
material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation,
broadcasting, reproduction on microfilms or in any other physical way, and transmission or information
storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now
known or hereafter developed. Exempted from this legal reservation are brief excerpts in connection with
reviews or scholarly analysis or material supplied specifically for the purpose of being entered and executed
on a computer system, for exclusive use by the purchaser of the work. Duplication of this publication or
parts thereof is permitted only under the provisions of the Copyright Law of the Publisher’s location, in its
current version, and permission for use must always be obtained from Springer. Permissions for use may be
obtained through RightsLink at the Copyright Clearance Center. Violations are liable to prosecution under
the respective Copyright Law.
ISBN-13 (pbk): 978-1-4842-0663-8
ISBN-13 (electronic): 978-1-4842-0662-1
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol
with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only
in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the
trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are
not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to
proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication,
neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or
omissions that may be made. The publisher makes no warranty, express or implied, with respect to the
material contained herein.
Managing Director: Welmoed Spahr
Lead Editor: Louise Corrigan
Technical Reviewer: Robin Hawkes
Editorial Board: Steve Anglin, Mark Beckner, Gary Cornell, Louise Corrigan, James DeWolf,
Jonathan Gennick, Robert Hutchinson, Michelle Lowman, James Markham, Matthew Moodie,
Jeffrey Pepper, Douglas Pundick, Ben Renow-Clarke, Gwenan Spearing, Matt Wade, Steve Weiss
Coordinating Editor: Kevin Walter
Copy Editor: Bill McManus
Compositor: SPi Global
Indexer: SPi Global
Artist: SPi Global
Cover Designer: Crest
Distributed to the book trade worldwide by Springer Science+Business Media New York,
233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail
orders-ny@springer-sbm.com, or visit www.springeronline.com. Apress Media, LLC is a California LLC
and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc).
SSBM Finance Inc is a Delaware corporation.
For information on translations, please e-mail rights@apress.com, or visit www.apress.com.
Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional use.
eBook versions and licenses are also available for most titles. For more information, reference our Special
Bulk Sales–eBook Licensing web page at www.apress.com/bulk-sales.
Any source code or other supplementary material referenced by the author in this text is available to
readers at www.apress.com/. For detailed information about how to locate your book’s source code, go to
www.apress.com/source-code/.

www.it-ebooks.info
There was a young lady named Laura,
Who was a beautiful señora.
Her love and assurance
Was a frequent occurrence
Which allowed me to write this book for yah.
—Tim

Dedicated to Brittany who supported me and gave me space


during the long hours that writing demands.
—Nicholas

www.it-ebooks.info
Contents at a Glance

About the Authors���������������������������������������������������������������������������������������������������xix


About the Technical Reviewer��������������������������������������������������������������������������������xxi
Acknowledgments������������������������������������������������������������������������������������������������xxiii
Introduction�����������������������������������������������������������������������������������������������������������xxv


■Chapter 1: Bower��������������������������������������������������������������������������������������������������� 1

■Chapter 2: Grunt�������������������������������������������������������������������������������������������������� 11

■Chapter 3: Yeoman���������������������������������������������������������������������������������������������� 37

■Chapter 4: PM2���������������������������������������������������������������������������������������������������� 53

■Chapter 5: RequireJS������������������������������������������������������������������������������������������� 73

■Chapter 6: Browserify���������������������������������������������������������������������������������������� 101

■Chapter 7: Knockout������������������������������������������������������������������������������������������ 121

■Chapter 8: AngularJS���������������������������������������������������������������������������������������� 155

■Chapter 9: Kraken���������������������������������������������������������������������������������������������� 191

■Chapter 10: Mach���������������������������������������������������������������������������������������������� 251

■Chapter 11: Mongoose��������������������������������������������������������������������������������������� 297

■Chapter 12: Knex and Bookshelf����������������������������������������������������������������������� 345

■Chapter 13: Faye������������������������������������������������������������������������������������������������ 381

www.it-ebooks.info
■ Contents at a Glance


■Chapter 14: Q����������������������������������������������������������������������������������������������������� 395

■Chapter 15: Async.js����������������������������������������������������������������������������������������� 425

■Chapter 16: Underscore and Lodash����������������������������������������������������������������� 447

Index��������������������������������������������������������������������������������������������������������������������� 477

vi

www.it-ebooks.info
Contents

About the Authors���������������������������������������������������������������������������������������������������xix


About the Technical Reviewer��������������������������������������������������������������������������������xxi
Acknowledgments������������������������������������������������������������������������������������������������xxiii
Introduction�����������������������������������������������������������������������������������������������������������xxv


■Chapter 1: Bower��������������������������������������������������������������������������������������������������� 1
Getting Started����������������������������������������������������������������������������������������������������������������� 2
Configuring Bower������������������������������������������������������������������������������������������������������������ 2
The Manifest�������������������������������������������������������������������������������������������������������������������� 2
Creating a New Manifest������������������������������������������������������������������������������������������������������������������������ 3

Finding, Adding, and Removing Bower Packages������������������������������������������������������������ 3


Finding Packages����������������������������������������������������������������������������������������������������������������������������������� 3
Adding Packages������������������������������������������������������������������������������������������������������������������������������������ 4
Removing Packages������������������������������������������������������������������������������������������������������������������������������� 5

Semantic Versioning��������������������������������������������������������������������������������������������������������� 6
Managing the Dependency Chain������������������������������������������������������������������������������������� 7
Creating Bower Packages������������������������������������������������������������������������������������������������ 8
Choose a Valid Name������������������������������������������������������������������������������������������������������������������������������ 8
Use Semver Git Tags������������������������������������������������������������������������������������������������������������������������������� 8
Publish Your Package to the Registry����������������������������������������������������������������������������������������������������� 9

Summary�������������������������������������������������������������������������������������������������������������������������� 9

vii

www.it-ebooks.info
■ Contents


■Chapter 2: Grunt�������������������������������������������������������������������������������������������������� 11
Installing Grunt��������������������������������������������������������������������������������������������������������������� 12
How Grunt Works������������������������������������������������������������������������������������������������������������ 12
Gruntfile.js�������������������������������������������������������������������������������������������������������������������������������������������� 12
Tasks���������������������������������������������������������������������������������������������������������������������������������������������������� 14
Plugins�������������������������������������������������������������������������������������������������������������������������������������������������� 14
Configuration���������������������������������������������������������������������������������������������������������������������������������������� 15

Adding Grunt to Your Project������������������������������������������������������������������������������������������ 15


Maintaining a Sane Grunt Structure����������������������������������������������������������������������������������������������������� 15

Working with Tasks�������������������������������������������������������������������������������������������������������� 18


Managing Configuration����������������������������������������������������������������������������������������������������������������������� 18
Task Descriptions��������������������������������������������������������������������������������������������������������������������������������� 18
Asynchronous Tasks����������������������������������������������������������������������������������������������������������������������������� 19
Task Dependencies������������������������������������������������������������������������������������������������������������������������������� 20
Multi-Tasks������������������������������������������������������������������������������������������������������������������������������������������� 20
Multi-Task Options�������������������������������������������������������������������������������������������������������������������������������� 22
Configuration Templates����������������������������������������������������������������������������������������������������������������������� 23
Command-Line Options������������������������������������������������������������������������������������������������������������������������ 24
Providing Feedback������������������������������������������������������������������������������������������������������������������������������ 24
Handling Errors������������������������������������������������������������������������������������������������������������������������������������� 25

Interacting with the File System������������������������������������������������������������������������������������ 25


Source-Destination Mappings�������������������������������������������������������������������������������������������������������������� 26
Watching for File Changes�������������������������������������������������������������������������������������������������������������������� 28

Creating Plugins������������������������������������������������������������������������������������������������������������� 32
Getting Started������������������������������������������������������������������������������������������������������������������������������������� 32
Creating the Task���������������������������������������������������������������������������������������������������������������������������������� 32
Publishing to npm��������������������������������������������������������������������������������������������������������������������������������� 35

Summary������������������������������������������������������������������������������������������������������������������������ 36
Related Resources��������������������������������������������������������������������������������������������������������� 36

viii

www.it-ebooks.info
■ Contents


■Chapter 3: Yeoman���������������������������������������������������������������������������������������������� 37
Installing Yeoman����������������������������������������������������������������������������������������������������������� 38
Creating Your First Project���������������������������������������������������������������������������������������������� 38
Subcommands�������������������������������������������������������������������������������������������������������������������������������������� 41

Creating Your First Generator����������������������������������������������������������������������������������������� 42


Yeoman Generators are Node Modules������������������������������������������������������������������������������������������������ 42
Sub-Generators������������������������������������������������������������������������������������������������������������������������������������ 43
Defining Secondary Commands����������������������������������������������������������������������������������������������������������� 49
Composability��������������������������������������������������������������������������������������������������������������������������������������� 51

Summary������������������������������������������������������������������������������������������������������������������������ 52
Related Resources��������������������������������������������������������������������������������������������������������� 52

■Chapter 4: PM2���������������������������������������������������������������������������������������������������� 53
Installation���������������������������������������������������������������������������������������������������������������������� 53
Working with Processes������������������������������������������������������������������������������������������������� 54
Recovering from Errors������������������������������������������������������������������������������������������������������������������������ 56
Responding to File Changes����������������������������������������������������������������������������������������������������������������� 58

Monitoring Logs������������������������������������������������������������������������������������������������������������� 58
Monitoring Resource Usage������������������������������������������������������������������������������������������� 60
Monitoring Local Resources����������������������������������������������������������������������������������������������������������������� 60
Monitoring Remote Resources������������������������������������������������������������������������������������������������������������� 61
Advanced Process Management������������������������������������������������������������������������������������ 63
JSON Application Declarations������������������������������������������������������������������������������������������������������������� 63

Load-Balancing Across Multiple Processors������������������������������������������������������������������ 68


Zero-Downtime Deployments��������������������������������������������������������������������������������������������������������������� 70

Summary������������������������������������������������������������������������������������������������������������������������ 72
Related Resources��������������������������������������������������������������������������������������������������������� 72

ix

www.it-ebooks.info
■ Contents


■Chapter 5: RequireJS������������������������������������������������������������������������������������������� 73
Running the Examples���������������������������������������������������������������������������������������������������� 74
Working with RequireJS������������������������������������������������������������������������������������������������� 74
Installation�������������������������������������������������������������������������������������������������������������������������������������������� 75
Configuration���������������������������������������������������������������������������������������������������������������������������������������� 75
Application Modules and Dependencies����������������������������������������������������������������������������������������������� 78
Paths and Aliases��������������������������������������������������������������������������������������������������������������������������������� 81
Shims���������������������������������������������������������������������������������������������������������������������������������������������������� 84
Loader Plugins�������������������������������������������������������������������������������������������������������������������������������������� 88
Cache Busting��������������������������������������������������������������������������������������������������������������������������������������� 94

RequireJS Optimizer������������������������������������������������������������������������������������������������������� 96
Configuring r.js������������������������������������������������������������������������������������������������������������������������������������� 96
Running the r.js Command������������������������������������������������������������������������������������������������������������������� 97

Summary������������������������������������������������������������������������������������������������������������������������ 99

■Chapter 6: Browserify���������������������������������������������������������������������������������������� 101
The AMD API vs. CommonJS���������������������������������������������������������������������������������������� 102
Installing Browserify���������������������������������������������������������������������������������������������������� 102
Creating Your First Bundle�������������������������������������������������������������������������������������������� 103
Visualizing the Dependency Tree���������������������������������������������������������������������������������� 104
Creating New Bundles As Changes Occur�������������������������������������������������������������������� 105
Watching for File Changes with Grunt������������������������������������������������������������������������������������������������ 106
Watching for File Changes with Watchify������������������������������������������������������������������������������������������� 106

Using Multiple Bundles������������������������������������������������������������������������������������������������ 108


The Node Way��������������������������������������������������������������������������������������������������������������� 111
Module Resolution and the NODE_PATH Environment Variable���������������������������������������������������������� 111
Dependency Management������������������������������������������������������������������������������������������������������������������ 114

Defining Browser-Specific Modules����������������������������������������������������������������������������� 115

www.it-ebooks.info
■ Contents

Extending Browserify with Transforms������������������������������������������������������������������������� 116


brfs����������������������������������������������������������������������������������������������������������������������������������������������������� 116
folderify���������������������������������������������������������������������������������������������������������������������������������������������� 117
bulkify������������������������������������������������������������������������������������������������������������������������������������������������� 118
Browserify-Shim��������������������������������������������������������������������������������������������������������������������������������� 119

Summary���������������������������������������������������������������������������������������������������������������������� 120
Related Resources������������������������������������������������������������������������������������������������������� 120

■Chapter 7: Knockout������������������������������������������������������������������������������������������ 121
Views, Models, and View Models��������������������������������������������������������������������������������� 122
The Recipe List����������������������������������������������������������������������������������������������������������������������������������� 124
Recipe Details������������������������������������������������������������������������������������������������������������������������������������� 127

Binding View Models to the DOM��������������������������������������������������������������������������������� 129


View Models and Forms����������������������������������������������������������������������������������������������� 131
Switching to “Edit” Mode������������������������������������������������������������������������������������������������������������������� 131
Changing the Recipe Title������������������������������������������������������������������������������������������������������������������� 134
Updating Recipe Servings and Cooking Time������������������������������������������������������������������������������������� 135
Adding and Removing Ingredients������������������������������������������������������������������������������������������������������ 138
Instructions����������������������������������������������������������������������������������������������������������������������������������������� 142
Citation����������������������������������������������������������������������������������������������������������������������������������������������� 144

Custom Components���������������������������������������������������������������������������������������������������� 144


The Input List View Model������������������������������������������������������������������������������������������������������������������ 145
The Input List Template���������������������������������������������������������������������������������������������������������������������� 146
Registering the Input List Tag������������������������������������������������������������������������������������������������������������� 148

Subscribables: Cheap Messaging�������������������������������������������������������������������������������� 150


Summary���������������������������������������������������������������������������������������������������������������������� 152
Related Resources������������������������������������������������������������������������������������������������������� 153

xi

www.it-ebooks.info
■ Contents


■Chapter 8: AngularJS���������������������������������������������������������������������������������������� 155
A Declarative Approach to Building Web Applications�������������������������������������������������� 155
The Imperative Approach�������������������������������������������������������������������������������������������������������������������� 155
The Declarative Approach������������������������������������������������������������������������������������������������������������������� 157

Modules: A Foundation for Building Loosely Coupled Applications������������������������������ 158


Specifying a Bootstrap Module����������������������������������������������������������������������������������������������������������� 159

Directives: An Abstraction Layer for the DOM��������������������������������������������������������������� 160


Taking Control�������������������������������������������������������������������������������������������������������������� 163
Scopes and Prototypal Inheritance����������������������������������������������������������������������������������������������������� 163
Manipulating Scope with Controllers������������������������������������������������������������������������������������������������� 165

Loose Coupling Through Services and Dependency Injection�������������������������������������� 168


Dependency Injection������������������������������������������������������������������������������������������������������������������������� 168
Thin Controllers and Fat Services������������������������������������������������������������������������������������������������������� 169

Creating Routes������������������������������������������������������������������������������������������������������������ 173


Route Parameters������������������������������������������������������������������������������������������������������������������������������� 175
Route Resolutions������������������������������������������������������������������������������������������������������������������������������� 176

Creating Complex Forms���������������������������������������������������������������������������������������������� 178


Validation�������������������������������������������������������������������������������������������������������������������������������������������� 178
Conditional Logic�������������������������������������������������������������������������������������������������������������������������������� 183
Repeatable Sections��������������������������������������������������������������������������������������������������������������������������� 185
Summary���������������������������������������������������������������������������������������������������������������������� 188
Related Resources������������������������������������������������������������������������������������������������������� 189

■Chapter 9: Kraken���������������������������������������������������������������������������������������������� 191
Environment-Aware Configuration������������������������������������������������������������������������������� 192
Shortstop Handlers����������������������������������������������������������������������������������������������������������������������������� 196

Configuration-Based Middleware Registration������������������������������������������������������������ 200


Event Notifications������������������������������������������������������������������������������������������������������������������������������ 203

xii

www.it-ebooks.info
■ Contents

Structured Route Registration�������������������������������������������������������������������������������������� 203


Index Configuration���������������������������������������������������������������������������������������������������������������������������� 204
Directory Configuration����������������������������������������������������������������������������������������������������������������������� 205
Routes Configuration�������������������������������������������������������������������������������������������������������������������������� 207

Dust Templates������������������������������������������������������������������������������������������������������������� 208


Context and References��������������������������������������������������������������������������������������������������������������������� 209
Sections���������������������������������������������������������������������������������������������������������������������������������������������� 212
Iteration���������������������������������������������������������������������������������������������������������������������������������������������� 212
Conditionality�������������������������������������������������������������������������������������������������������������������������������������� 213
Partials����������������������������������������������������������������������������������������������������������������������������������������������� 214
Blocks������������������������������������������������������������������������������������������������������������������������������������������������� 215
Filters�������������������������������������������������������������������������������������������������������������������������������������������������� 216
Context Helpers���������������������������������������������������������������������������������������������������������������������������������� 218
Dust Helpers��������������������������������������������������������������������������������������������������������������������������������������� 225
Let’s Get Kraken��������������������������������������������������������������������������������������������������������������������������������� 230

Summary���������������������������������������������������������������������������������������������������������������������� 250
Related Resources������������������������������������������������������������������������������������������������������� 250

■Chapter 10: Mach���������������������������������������������������������������������������������������������� 251
Chapter Examples�������������������������������������������������������������������������������������������������������� 251
Installation�������������������������������������������������������������������������������������������������������������������� 252
Mach, the Web Server�������������������������������������������������������������������������������������������������� 252
HTTP Routes��������������������������������������������������������������������������������������������������������������������������������������� 254
Making Connections��������������������������������������������������������������������������������������������������������������������������� 260
Common Middleware�������������������������������������������������������������������������������������������������������������������������� 262
These Are Not the Routes You’re Looking for������������������������������������������������������������������������������������� 280
The Hosts with the Most��������������������������������������������������������������������������������������������������������������������� 282
Custom Middleware���������������������������������������������������������������������������������������������������������������������������� 287

Mach, the HTTP Client�������������������������������������������������������������������������������������������������� 289


Mach, the HTTP Proxy�������������������������������������������������������������������������������������������������� 291
Summary���������������������������������������������������������������������������������������������������������������������� 295

xiii

www.it-ebooks.info
■ Contents


■Chapter 11: Mongoose��������������������������������������������������������������������������������������� 297
Basic MongoDB Concepts�������������������������������������������������������������������������������������������� 297
A Simple Mongoose Example��������������������������������������������������������������������������������������� 300
Creating a Mongoose Schema for JSON Data������������������������������������������������������������������������������������ 301
Importing Data with Mongoose���������������������������������������������������������������������������������������������������������� 302
Querying Data with Mongoose����������������������������������������������������������������������������������������������������������� 305

Working with Schemas������������������������������������������������������������������������������������������������ 307


Data Types������������������������������������������������������������������������������������������������������������������������������������������ 307
Nested Schemas��������������������������������������������������������������������������������������������������������������������������������� 308
Default Property Values���������������������������������������������������������������������������������������������������������������������� 309
Required Properties���������������������������������������������������������������������������������������������������������������������������� 310
Secondary Indexes����������������������������������������������������������������������������������������������������������������������������� 310
Schema Validation������������������������������������������������������������������������������������������������������������������������������ 311
Schema References���������������������������������������������������������������������������������������������������������������������������� 314
Schema Middleware��������������������������������������������������������������������������������������������������������������������������� 318

Working with Models and Documents�������������������������������������������������������������������������� 321


Document Instance Methods�������������������������������������������������������������������������������������������������������������� 323
Document Virtuals������������������������������������������������������������������������������������������������������������������������������ 325
Static Model Methods������������������������������������������������������������������������������������������������������������������������� 327

Working with Queries��������������������������������������������������������������������������������������������������� 329


Model.find( )���������������������������������������������������������������������������������������������������������������������������������������� 329
Finding Documents with Query Operators������������������������������������������������������������������������������������������ 336
Summary���������������������������������������������������������������������������������������������������������������������� 343

■Chapter 12: Knex and Bookshelf����������������������������������������������������������������������� 345
Knex����������������������������������������������������������������������������������������������������������������������������� 346
Installing the Command-Line Utility��������������������������������������������������������������������������������������������������� 346
Adding Knex to Your Project��������������������������������������������������������������������������������������������������������������� 346
Configuring Knex�������������������������������������������������������������������������������������������������������������������������������� 347
The SQL Query Builder������������������������������������������������������������������������������������������������������������������������ 347
Migration Scripts�������������������������������������������������������������������������������������������������������������������������������� 355
Seed Scripts��������������������������������������������������������������������������������������������������������������������������������������� 360
xiv

www.it-ebooks.info
■ Contents

Bookshelf��������������������������������������������������������������������������������������������������������������������� 361
What Is an Object-Relational Mapper?����������������������������������������������������������������������������������������������� 361
Creating Your First Bookshelf Model��������������������������������������������������������������������������������������������������� 362
Relationships�������������������������������������������������������������������������������������������������������������������������������������� 370

Summary���������������������������������������������������������������������������������������������������������������������� 379
Related Resources������������������������������������������������������������������������������������������������������� 379

■Chapter 13: Faye������������������������������������������������������������������������������������������������ 381
HTTP, Bayeux, and WebSockets������������������������������������������������������������������������������������ 381
WebSockets���������������������������������������������������������������������������������������������������������������������������������������� 383
The Bayeux Protocol��������������������������������������������������������������������������������������������������������������������������� 384

Getting Started with Faye��������������������������������������������������������������������������������������������� 385


PubSub Messaging������������������������������������������������������������������������������������������������������� 387
Wildcard Channels������������������������������������������������������������������������������������������������������������������������������ 388

Summary���������������������������������������������������������������������������������������������������������������������� 393
Related Resources������������������������������������������������������������������������������������������������������� 394

■Chapter 14: Q����������������������������������������������������������������������������������������������������� 395
Timing Is Everything����������������������������������������������������������������������������������������������������� 395
Promises vs. Callbacks������������������������������������������������������������������������������������������������ 399
The Promise of Q���������������������������������������������������������������������������������������������������������� 401
Deferreds and Promises��������������������������������������������������������������������������������������������������������������������� 401
Values and Errors������������������������������������������������������������������������������������������������������������������������������� 406
Reporting Progress����������������������������������������������������������������������������������������������������������������������������� 412
Everything Ends���������������������������������������������������������������������������������������������������������������������������������� 415

Flow Control with Q������������������������������������������������������������������������������������������������������ 418


Sequential Flow���������������������������������������������������������������������������������������������������������������������������������� 418
Parallel Flow��������������������������������������������������������������������������������������������������������������������������������������� 420
Pipeline Flow�������������������������������������������������������������������������������������������������������������������������������������� 421

Summary���������������������������������������������������������������������������������������������������������������������� 423
Related Resources������������������������������������������������������������������������������������������������������� 423

xv

www.it-ebooks.info
■ Contents


■Chapter 15: Async.js����������������������������������������������������������������������������������������� 425
Sequential Flow������������������������������������������������������������������������������������������������������������ 426
Parallel Flow����������������������������������������������������������������������������������������������������������������� 428
Pipeline Flow���������������������������������������������������������������������������������������������������������������� 430
Reusing a Pipeline������������������������������������������������������������������������������������������������������������������������������ 433

Loop Flow��������������������������������������������������������������������������������������������������������������������� 435


Looping While Some Condition Remains True������������������������������������������������������������������������������������ 435
Looping Until Some Condition Becomes False����������������������������������������������������������������������������������� 437
Retry Loops����������������������������������������������������������������������������������������������������������������������������������������� 439
Infinite Loops�������������������������������������������������������������������������������������������������������������������������������������� 441

Batch Flow������������������������������������������������������������������������������������������������������������������� 442


Asynchronous Queue�������������������������������������������������������������������������������������������������������������������������� 442

Summary���������������������������������������������������������������������������������������������������������������������� 446

■Chapter 16: Underscore and Lodash����������������������������������������������������������������� 447
Installation and Usage�������������������������������������������������������������������������������������������������� 449
Aggregation and Indexing�������������������������������������������������������������������������������������������� 449
countBy( )�������������������������������������������������������������������������������������������������������������������������������������������� 449
groupBy( )�������������������������������������������������������������������������������������������������������������������������������������������� 451
indexBy( )�������������������������������������������������������������������������������������������������������������������������������������������� 452

Being Choosy���������������������������������������������������������������������������������������������������������������� 453


Selecting Data from Collections��������������������������������������������������������������������������������������������������������� 453
Selecting Data from Objects��������������������������������������������������������������������������������������������������������������� 456

Chaining����������������������������������������������������������������������������������������������������������������������� 460
Function Timing������������������������������������������������������������������������������������������������������������ 463
defer( )������������������������������������������������������������������������������������������������������������������������������������������������ 463
debounce( )����������������������������������������������������������������������������������������������������������������������������������������� 465
throttle( )��������������������������������������������������������������������������������������������������������������������������������������������� 466

xvi

www.it-ebooks.info
■ Contents

Templates��������������������������������������������������������������������������������������������������������������������� 468
Loops and Other Arbitrary JavaScript in Templates���������������������������������������������������������������������������� 470
Living Without Gator Tags������������������������������������������������������������������������������������������������������������������� 472
Accessing the Data Object Within a Template������������������������������������������������������������������������������������ 473
Default Template Data������������������������������������������������������������������������������������������������������������������������ 474

Summary���������������������������������������������������������������������������������������������������������������������� 475
Related Resources������������������������������������������������������������������������������������������������������� 476

Index��������������������������������������������������������������������������������������������������������������������� 477

xvii

www.it-ebooks.info
About the Authors

Tim Ambler is a software engineer from Nashville, Tennessee. His passion


for programming follows in the footsteps of his father, who introduced him
to computers at a young age with a Commodore 64. Tim is the author of
several popular open source projects, one of which (whenLive) has been
featured by GitHub’s staff. An occasional conference speaker and frequent
writer, Tim has been referenced multiple times in online publications such
as JavaScript Weekly and Node Weekly. He currently lives in the 12 South
area with his wife, Laura, and two cats. You can follow him on Twitter at
@tkambler.

Nicholas Cloud is a software developer who lives in the very humid city of
St. Louis. For over a decade he has forged his skills into a successful career.
He has developed web applications, web services, and desktop software on
diverse platforms with JavaScript, C#, and PHP. A strong proponent of open
source software, Nicholas contributes to userland projects and has written
several of his own open source libraries libraries. He speaks at a variety of
user groups and conferences and writes books, technical articles, and blog
posts in his spare time. He opines on Twitter at @nicholascloud.

xix

www.it-ebooks.info
About the Technical Reviewer

Robin Hawkes lives to learn and thrives on combining design and


code to solve problems. He’s the author of Foundation HTML5 Canvas
(Apress, 2011), which is all about making games with JavaScript. He’s
also the one-man band behind ViziCities, a WebGL-powered 3D city
visualization platform. In a previous life Robin worked in worldwide
developer relations at both Mozilla and Pusher.

xxi

www.it-ebooks.info
Acknowledgments

This book would not have been possible without the encouragement and support of a number of people:
Nicholas Cloud, my friend and co-author, without whom this book would be much more limited
in scope and depth. His knowledge, experience, and steadfast dedication to this project have been
immeasurably helpful. Thank you.
Louise Corrigan, Kevin Walter, Christine Ricketts, Melissa Maldonado, and the rest of the staff at Apress
who supported us throughout the course of this project. I am grateful for the invitation that was extended to
embark upon this journey and for the ongoing support that you have provided.
Robin Hawkes, our technical reviewer. The examples and source code included with this book have
greatly benefited from his keen insight and sharp eye.
James Coglan, the creator of Faye. Thank you for taking the time to share your technical expertise
and feedback.
My friends and colleagues Greg Jones, Jeff Crump, Seth Steele, Jon Zumbrun, and Brian Hiatt. I am
grateful for your feedback and encouragement.
—Tim
Acknowledgements are slippery things. I have so many debts, and so little space to repay.
First, the debt to my co-author Tim who reached out and invited me on this journey. We’ve never met
in person but worked remotely as co-workers for about half a year—enough time for each of us to leave an
impression on each other across the miles. For his trust, encouragement, and constant effort I am grateful.
Second, my debt to the staff at Apress who guided us through the publishing process: Kevin, Louise,
Christine, and Melissa. Their patience and careful guidance spared you, the reader, from no small amount of
cringes, and kept me on my toes during the entire writing process. They are all sharp professionals with whom
I hope to work again some day.
Third, I am indebted to Robin for his excellent technical reviews; for reading and executing more code
samples than a developer should ever be tasked with groking.
Finally, I cannot repay the subject-matter expertise I gleaned from Michael Jackson (@mjackson) while
researching Mach, and Ryan Niemeyer (@RPNiemeyer) while researching Knockout—I can only pay it forward
to you, the reader.
—Nicholas

xxiii

www.it-ebooks.info
Introduction

They tell me we’re living in an information age, but none of it seems to be the information
I need or brings me closer to what I want to know. In fact (I’m becoming more and more
convinced) all this electronic wizardry only adds to our confusion, delivering inside scoops
and verdicts about events that have hardly begun: a torrent of chatter moving at the speed
of light, making it nearly impossible for any of the important things to be heard.
—Matthew Flaming, The Kingdom of Ohio

The notion that “technology moves quickly” is a well-worn aphorism, and with good reason: technology
does move quickly. But at this moment, JavaScript in particular is moving very quickly indeed—much like
that “torrent of chatter moving at the speed of light” that Matthew Flaming refers to in The Kingdom of Ohio.
The language is in the midst of what many have called a renaissance, brought about by the rapidly increasing
sophistication of browser-based applications and the rising popularity of JavaScript on the server, thanks to
Node.js.
An almost feverish pace of innovation is occurring within the JavaScript community that, while
endlessly fascinating to follow, also presents some unique challenges of its own. JavaScript’s ecosystem of
libraries, frameworks, and utilities has grown dramatically. Where once a small number of solutions for any
given problem existed, many can now be found… and the options continue to grow by the day. As a result,
developers find themselves faced with the increasingly difficult task of choosing the appropriate tools from
among many seemingly good options.
If you’ve ever found yourself wondering why JavaScript seems to be attracting so much attention lately,
as we have, it’s worth stopping for a moment to consider the fact that JavaScript, a language that was created
by one person in ten days, now serves as the foundation upon which much of the Web as we know it sits.
A language that was originally created to solve relatively simple problems is now being applied in new
and innovative ways that were not originally foreseen. What’s more, JavaScript is a beautifully expressive
language, but it’s not without its share of rough edges and potential pitfalls. While flexible, efficient, and
ubiquitous, JavaScript concepts such as the event loop and prototypal inheritance can prove particularly
challenging for those coming to the language for the first time.
For these and many other reasons, the development community at large is still coming to terms with
how best to apply the unique features that JavaScript brings to the table. We’ve no doubt only scratched
the surface of what the language and the community behind it are capable of. For those with an insatiable
appetite for knowledge and a desire to create, now is the perfect time to be a JavaScript developer.
We have written Pro JavaScript Frameworks for Modern Web Dev to serve as your guide to a wide
range of popular JavaScript tools that solve difficult problems at both ends of the development stack: in
the browser and on the server. The tutorials and downloadable code examples contained within this book
illustrate the usage of tools that manage dependencies, structure code in a modular fashion, automate
repetitive build tasks, create specialized servers, structure client side applications, facilitate horizontal
scaling, perform event logging, and interacting with disparate data stores.
The libraries and frameworks covered include Bower, Grunt, Yeoman, PM2, RequireJS, Browserify,
Knockout, AngularJS, Kraken, Mach, Mongoose, Knex, Bookshelf, Faye, Q, Async.js, Underscore, and Lodash.

xxv

www.it-ebooks.info
■ Introduction

In writing Pro JavaScript Frameworks for Modern Web Dev, our goal was to create a filter for the
“torrent of chatter” that often seems to surround JavaScript, and in so doing, to allow what we believe are
some important things to be heard. We hope the information contained within these pages proves as useful
to you as it has to us.

Who This Book Is For


This book is intended for web developers who are already confident with JavaScript, but also frustrated with
the sheer number of solutions that exist for seemingly every problem. This book helps lift the fog, providing
the reader with an in-depth guide to specific libraries and frameworks that well-known organizations are
using right now with great success. Topics pertaining to both client-side and server-side development
are covered. As a result, readers will gain the most benefit from this book if they already have at least an
intermediate familiarity with both the web browser Document Object Model (DOM), common client-side
libraries like jQuery, and Node.js.

How This Book Is Structured


This book covers a wide selection of JavaScript tools that are applicable throughout the entire development
process, from a project’s first commit to its first release and beyond. To that end, the chapters have been
grouped into the following parts.

Part 1: Development Tools


Bower
Dependency management is hardly a new idea - well-known examples include Node’s npm, Python’s pip,
and PHP’s composer. A practice that has only recently begun to see widespread adoption, however, is the
application of this concept to the management of front-end web assets - the JavaScript libraries, stylesheets,
fonts, icons, and images that serve as the building blocks of modern web applications. In this chapter, we’ll
discover several ways in which Bower - a popular tool within this field - can improve your development
process by providing you with a mechanism for organizing these dependencies within your application.

Grunt
Larry Wall, the creator of Perl, describes the three virtues of a great programmer as: laziness, impatience,
and hubris. In this chapter, we’ll focus on a tool that will help you strengthen the virtue of laziness - Grunt.
This popular task runner provides developers with a framework for creating command-line utilities
that automative repetitive build tasks such as running tests, concatenating files, compiling SASS / LESS
stylesheets, checking for JavaScript errors, and more. After reading this chapter, you’ll know how to use several
popular Grunt plugins, as well as how to go about creating and sharing your own plugins with the community.

xxvi

www.it-ebooks.info
■ Introduction

Yeoman
Yeoman provides JavaScript developers with a mechanism for creating reusable templates (“generators”)
that describe the overall structure of a project (initially required dependencies, Grunt tasks, etc…) in a way
that can be easily re-used over and over. Broad community support also allows you to take advantage of a
wide variety of pre-existing templates. In this chapter, we’ll walk through the process of installing Yeoman
and using several popular pre-existing generators. Finally, we’ll take a look at how we can create and share
our own templates with the community.

PM2
In this chapter, we will close out our discussion of development tools by taking a look at PM2, a command-line
utility that simplifies many of the tasks associated with running Node applications, monitoring their status,
and efficiently scaling them to meet increasing demand.

Part 2: Module Loaders


RequireJS and Browserify
JavaScript’s lacks a native method for loading external dependencies in the browser—a frustrating oversight
for developers. Fortunately, the community has stepped in to fill this gap with two very different and
competing standards: the Asynchronous Module Definition (AMD) API and CommonJS. We’ll dive into the
details of both and take a look at widely-used implementations of each: RequireJS and Browserify. Each
have their merits, which we’ll discuss in detail, but both can have a profoundly positive impact on the way in
which you go about structuring your applications.

Part 3: Client-Side Frameworks


Knockout and AngularJS
In recent years, web developers have witnessed a sharp rise in popularity of so-called “single-page apps.”
Such applications exhibit behavior once available only on the desktop, but at the expense of increased code
complexity within the browser. In this section, we’ll dive into two widely-used front-end frameworks that
help minimize that complexity by providing proven patterns for solving frequently-encountered problems:
Knockout and AngularJS. Knockout focuses on the relationship between view and data, but otherwise leaves
the application architecture and plumbing to the developer’s discretion. AngularJS takes a more prescriptive
approach, covering the view, application routing, data transfer, and module design.

Part 4: Server-Side Frameworks


Kraken and Mach
Client-side applications aren’t very useful without a server with which to interact. In this section, we’ll take
a look at two popular frameworks that support developers in the creation of back-end applications: Kraken
and Mach.
Mach is more than just a simple web server: it is HTTP for the web. Mach can both serve and retrieve
content via an intuitive, extensible HTTP stack. The Mach interface remains the same whether servicing
web page requests in a Node.js application, fetching JSON data with a Mach AJAX request in the browser,
or rewriting and proxying requests to another web stack entirely. In many ways Mach is the Swiss army knife
of HTTP.

xxvii

www.it-ebooks.info
■ Introduction

Part 5: Managing Database Interaction


Mongoose, Knex, and Bookshelf
At the core of every application lies the most important component of any development stack - the data
that our users seek. In this section, we’ll become familiar with two libraries that help simplify some of the
complexity that’s often experienced when interacting with popular storage platforms such as MongoDB,
MySQL, PostgreSQL, and SQLite. After reading this section, you’ll be comfortable defining schemas,
associations, lifecycle “hooks”, and more.

Part 6: Communication
Faye
In this section, you’ll be introduced to Faye, a Node.js library that provides developers with a robust and
easy-to-use platform for building products that rely on real-time communication between servers and all
major browsers.Much of Faye’s popularity stems from the project’s goal of working everywhere the Web
works. Faye accomplishes this by providing seamless fallback support for a number of communication
protocols.

Part 7: Managing Control Flow


Q and Async.js
The asynchronous nature of JavaScript provides developers with a significant degree of flexibility - as
opposed to forcing developers to execute their code in a linear fashion, JavaScript allows developers to
orchestrate multiple actions simultaneously. Unfortunately, along with this flexibility comes a significant
degree of additional complexity - what many developers refer to as “callback hell” or the “pyramid of
doom.” In this section, we’ll examine two popular libraries that will aid you in taming the complexities of
asynchronous control flow: Q and Async.js.

Part 8: Further Useful Libraries


A number of wonderfully useful libraries exist that this book would be remiss not to cover, but for which
additional parts are not necessarily warranted. This part will cover such libraries.

Underscore and Lo-Dash


Underscore (and its successor, Lo-Dash) is an incredibly useful collection of functions that simplifies many
frequently used patterns that can be tedious to implement otherwise. This brief chapter will bring these
libraries to your attention, along with some of the more popular extensions that can also be included to
enhance their usefulness even further. Examples are included that that highlight some of the most frequently
used portions of these libraries.

xxviii

www.it-ebooks.info
■ Introduction

Downloading the Code


Each chapter in this book contains many examples, the source code for which may be downloaded from
http://www.apress.com/9781484206638 in zipped form.
Subdirectories within each chapter’s zip file contain source code (often executable) that corresponds
to specific example listings in each chapter. The first line in each chapter listing will be a source code
comment identifying the specific file path where the source code lives. If you were to encounter
Listing 0-1 in Chapter 10 (covering Mach), for example, the actual source code file would be located in
mach/example-000/no-such-file.js, relative to where the mach.zip file was extracted.

Listing 0-1. Not a Real Example


// example-000/no-such-file.js
console.log('this is not a real example');

Most examples are run with the Node.js runtime, which may be obtained from https://nodejs.org.
Chapters with additional prerequisites will explain the necessary procedures for downloading and
installing the examples. (For example, MongoDB is necessary to run examples in Chapter 11, which covers
Mongoose.)
Any additional steps necessary for running code examples (e.g., executing curl requests) or interacting
with a running example (e.g., opening a web browser and navigating to a specific URL) are explained
alongside each listing.

xxix

www.it-ebooks.info
Chapter 1

Bower

Great things are done by a series of small things brought together.


—Vincent Van Gogh

The concept of package management, also known as dependency management, is not new. Utilities within
this category provide developers with a mechanism for managing the various third-party libraries that a
project relies on. Widely used examples include
• npm: The package manager for Node.js
• Composer: A tool for dependency management in PHP
• pip: The PyPA recommended tool for installing Python packages
• NuGet: The package manager for the Microsoft development platform including .NET
While package management is hardly a new idea, a practice that has only recently begun to see
widespread adoption is the application of this concept to the management of front-end web assets—the
JavaScript libraries, stylesheets, fonts, icons, and images that serve as the building blocks of modern web
applications. The need for such structure has become evident as the foundations on which modern web
applications are built have grown in complexity. Web applications that once relied on a small selection of
broadly defined, “one size fits all” third-party libraries (e.g., jQuery) now find themselves using the work
of many more smaller libraries, each with a tightly defined purpose. Benefits of this approach include
smaller modules that are easier to test, as well as an enhanced degree of flexibility on the part of the
parent application, which can more easily extend third-party libraries or replace them altogether when
necessary.
This chapter is designed to get you up and running quickly with Bower, the front-end package manager
whose roots lie in open source initiatives at Twitter. Topics covered include
• Installing and configuring Bower
• Adding Bower to a project
• Finding, adding, and removing packages
• Semantic Versioning
• Managing the dependency chain
• Creating Bower packages

www.it-ebooks.info
Chapter 1 ■ Bower

Getting Started
All interaction with Bower occurs through a command-line utility that can be installed via npm. If you do not
already have Bower installed, you should install it before you continue, as shown in Listing 1-1.

Listing 1-1. Installing the bower Command-Line Utility via npm


$ npm install -g bower
$ bower --version
1.3.12

■■Note Node’s package manager (npm) allows users to install packages in one of two contexts: locally
or globally. In this example, bower is installed within the global context, which is typically reserved for
command-line utilities.

Configuring Bower
Bower is configured on a per-project basis through a single (optional) JSON file that exists in your project’s
root folder, .bowerrc. For the purposes of this introduction, we’ll only look at the most frequently changed
setting within this file (see Listing 1-2).

Listing 1-2. The .bowerrc File from This Chapter’s Sample Project
// example-bootstrap/.bowerrc

{
"directory": "./public/bower_components"
}

By default, Bower will store your project’s dependencies in the bower_components folder. You will likely
want to change this location, and the directory setting allows you to do so.

The Manifest
Bower provides developers with a single point of entry from which third-party libraries can be found, added,
upgraded, and removed. As these actions occur, Bower updates a JSON file referred to as the “manifest”
with an up-to-date list of the project’s dependencies. The Bower manifest for this chapter’s sample project is
shown in Listing 1-3. In this example, Bower is aware of a single dependency, the Bootstrap CSS framework.

Listing 1-3. Bower Manifest for This Chapter’s Sample Project


// example-bootstrap/bower.json

{
"name": "example-bootstrap",
"version": "1.0.0",
"homepage": "https://github.com/username/project",

www.it-ebooks.info
Chapter 1 ■ Bower

"authors": [
"John Doe <john.doe@gmail.com>"
],
"dependencies": {
"bootstrap": "3.2.0"
}
}

If we were to accidentally delete all of our project’s dependencies by removing the public/bower_
components folder, we could easily restore our project to its previous state by issuing a single command, as
shown next. Doing so would cause Bower to compare its manifest with our project’s current file structure,
determine what dependencies are missing, and restore them.

$ bower install

As a result of this behavior, we have the option of ignoring our project’s /public/bower_components
folder within version control. By committing only Bower’s manifest, and not the dependencies themselves,
our project’s source code can be kept in a cleaner state, containing only files that pertain directly to our
own work.

■■Note Opinions differ as to whether or not keeping your project’s dependencies out of version control is
a good idea. On the one hand, doing so results in a cleaner repository. On the other hand, this also opens the
door to potential problems should you (or the Bower registry, or GitHub, etc.) encounter connection issues.
The general consensus seems to be that if you are working on a “deployable” project (i.e., an application,
not a module), committing your dependencies is the preferred approach. Otherwise, keeping your project’s
dependencies out of version control is probably a good idea.

Creating a New Manifest


When you begin to use Bower within a project for the first time, it’s typically best to allow Bower to create a
new manifest for you, as shown next. Afterward, you can modify it further if necessary.

$ bower init

Finding, Adding, and Removing Bower Packages


Bower’s command-line utility provides a number of useful commands for locating, installing, and removing
packages. Let’s take a look at how these commands can help simplify the process of managing a project’s
external dependencies.

Finding Packages
One of the primary ways in which Bower can improve your development workflow is by providing you with a
centralized registry from which third-party libraries can be found. To search the Bower registry, simply pass
the search argument to Bower, followed by a keyword to search for, as shown in Listing 1-4. In this example,
only a short excerpt from the returned list of search results is shown.

www.it-ebooks.info
Chapter 1 ■ Bower

Listing 1-4. Searching Bower for jQuery


$ bower search jquery

Search results:

jquery git://github.com/jquery/jquery.git
jquery-ui git://github.com/components/jqueryui
jquery.cookie git://github.com/carhartl/jquery-cookie.git
jquery-placeholder git://github.com/mathiasbynens/jquery-placeholder.git

Adding Packages
Each search result includes the name under which the package was registered, along with the URL of the
GitHub repository at which it can be accessed directly. Once we have located the desired package, we can
add it to our project as shown in Listing 1-5.

Listing 1-5. Adding jQuery to Our Project


$ bower install jquery --save
bower jquery#* cached git://github.com/jquery/jquery.git#2.1.3
bower jquery#* validate 2.1.3 against git://github.com/jquery/jquery.git#*
bower jquery#>= 1.9.1 cached git://github.com/jquery/jquery.git#2.1.3
bower jquery#>= 1.9.1 validate 2.1.3 against git://github.com/jquery/jquery.git#>= 1.9.1
bower jquery#>= 1.9.1 cached git://github.com/jquery/jquery.git#2.1.3
bower jquery#>= 1.9.1 validate 2.1.3 against git://github.com/jquery/jquery.git#>= 1.9.1
bower jquery#>= 1.9.1 install jquery#2.1.3

jquery#2.1.3 public/bower_components/jquery

■■Note Bower does not host any of the files associated with the packages contained within its registry; it
defers to GitHub for that responsibility. While it is possible to host packages at any URL, the majority of public
packages are found on GitHub.

Take note of the fact that in Listing 1-5, we pass the --save option to Bower’s install command. By
default, the install command will add the requested package to a project without updating its manifest.
By passing the --save option, we instruct Bower to permanently store this package within its list of
dependencies.
Listing 1-6 shows the HTML from this chapter’s sample project. After adding jQuery to our project via
Bower, we can load it via a script tag as we would any other library.

www.it-ebooks.info
Random documents with unrelated
content Scribd suggests to you:
raft might have appeared, even to close observation, to be no more
than a piece of drifting wood, but for the gleams sent forth from the
precious stones with which Marana’s silver hair-pins were set, and
for the ripple of Rayo’s paddle, which he contrived to ply as he lay.
The critical moment must be when he plunged, as there were no sea
sounds amidst which the splash might be lost. All was as quiet as a
lake. The guard-boat was no cradle to those who slept within it, for
it kept its place as if it had been fixed in the sand of the beach. The
black points of rock which rose above the surface at a distance
towards the land were reflected with perfect fidelity, instead of in
fluctuating lines of shadow. Marana dreaded the plunge for her lover,
and fearfully watched to see dark figures rise up in the guard-boat
while the circles were yet spreading, and breaking the moonlight to
shivers on the surface. No foe appeared, however; and Marana was
at liberty for new fears. There were enemies in the green depths
below more formidable than any to the right hand or the left. It was
quite as probable that a shark might take a fancy to this locality as a
diver; and a chance meeting was little likely to end without strife.
Marana drew towards the edge of the raft as its heavings subsided,
and looked eagerly down, dreading to see a red tinge diffuse itself in
the lucid depth, and starting at every shadow that floated through it.
She was fingering her ebony beads meanwhile, and her lips moved
as she murmured some aspirations compounded of a catholic prayer
and a native charm. The depth was little more than two fathoms in
this place, and Rayo was soon up again, though the minute of his
submersion seemed incalculably longer to Marana. He delivered his
pouch to her to be emptied, and rested himself by floating till he
was ready for another descent.
Again and again he dived, till Marana discovered a treasure in the
pouch which destroyed all further temptation to theft that night, and
relieved the damsel from the anxiety of watching more descents of
her lover. A shell which opened to the right, commonly called a right-
handed chank, a shell esteemed worth its weight in gold, appeared
in the heap, and it was not worth while to run any further risk when
so rare a possession as this was obtained. Rayo’s spirits were so
raised by his good fortune that he insisted on paddling quite round
the guard-boat, near enough to see whether there was any one in it,
while Marana looked anxiously at the ascending moon, whose flood
of light was now veiling the stars. When she saw arms gleaming in
the boat, she thought it too rash of her lover to come between the
sleeping guard and the moon, and looked imploringly at him while
she pointed to the shore. His curiosity once satisfied, the danger was
soon over. Rayo ventured to stand up to paddle, when the raft had
distanced the boat by half a mile, and Marana began her inquiries as
to what he had seen in the deep.
Rayo made light, as he had done for some time past, of the
achievement of diving for chanks. He had practised it as a
preparation for becoming a pearl-fisher in waters three times as
deep, and for a much more precious treasure. He was to make his
first trial of the nobler occupation at the approaching pearl fishery;
and he spoke with becoming indifference of all meaner
accomplishments. He had seen no sharks to-night; there would be
more chance of them in deeper water. He had been startled by no
strange appearances: nine fathoms down was the scene for
wonders. He had found no difficulty in filling his pouch: the oyster
beds would afford harder work. Marana thought all this was
counterbalanced by the absence of a charmer who might say
“avaunt!” to sharks, and interpret all marvels, and lighten all toils. If
her father could have been on the raft with them to-night, she
should think as little of the trip as Rayo himself; and if he could but
get himself engaged for the same boat that was to carry Rayo out to
his first pearl fishing, she should have confidence in his prosperity
and safe return.
They fell in with no other vessel till they came in sight of the
shore,—the wildest and dreariest part of the shores of Ceylon. A flat
yellow beach stretched away on either hand, without rock or tree, or
any object which could cast a shadow, except the huts of mud and
rushes which afforded a shelter to the natives. In no place was it
easier to make a landing, and in none was it more difficult to land
unperceived, when sun or moon was above the horizon. No jutting
rocks were there, behind whose screen a raft might lie concealed:
no shady creek into which a skiff might glide and secrete itself
beneath the mangroves: no groves of cocoa-nut, feathering the
margin of the tide, beneath whose canopy dusky pilferers might
creep to divide their spoils. All was here open to the sky, and to a
sky whose lesser lights leave little unrevealed even on the night of a
new moon.
Rayo and Marana had little chance of stealing to their homes
unobserved while so many eyes were looking upon them from
above, and while a certain pair of vigilant human eyes preserved
their wont of looking abroad upon the night. The tall figure of Father
Anthony, the priest, was moving on the beach, preceded by his still
taller shadow, when the raft floated on shore. Rayo saw this while
still afloat; and if he had been an English smuggler, he would have
pushed off again before he was recognized, and have kept out of
sight till Father Anthony was safely housed. But Rayo’s ideas of good
manners would not allow of this. He had no notion of failing to pay
his respects to any who came in his way, whatever might be the
consequence of the meeting; and he now greeted Father Anthony
with as much deference as Marana herself, hoping that it was no evil
which kept their friend awake at this hour.
“No worse evil than being unable to rest so well here as in Europe,
where there are no excessive heats of the day to make us restless at
night. But what fish do you seek so late? I fear you have lost your
nets,” he continued, seeing no fishing apparatus on board the raft.
Marana looked at Rayo, and Rayo said nothing.
“Chanks!” exclaimed Father Anthony, perceiving now of what
Marana’s burden consisted. “These chanks cannot be yours.”
“His hands brought them up,” declared Marana, pointing to her
lover.
“It may be so, but they are no more his than the comb in his hair
would be mine if I were to take it from him. Rayo, why did you steal
these chanks? Do not you know that God punishes theft?”
“Is it theft to get chanks for my bride, when I have worked long
for them, and can get no chanks by working? I thought God laid the
chanks in our seas for our brides.”
“They have become the property of some who may let your
brides, or the brides of India have them, as they may see fit. God
gave them into the hands of those who possess them; and He will
be angry with any who take them away by fraud or violence. All
cannot have these chank-beds, and those who have bought them
must be protected in their possession.”
“I have earned as many as I have taken,” replied Rayo; “and to-
night God has given them to me. The guard did not even stir when I
plunged.”
“And God gave him this,” added Marana, showing the precious
shell as an indubitable proof of all being right. Father Anthony had
not been long enough in his present station to know the full value of
what he now took into his hand; but if he had, his decision would
have been the same,—that the chanks were not Rayo’s.
Rayo was much in want of his friend’s guidance. In the school, it
was taught as a duty that a just reward should be given for toil. Was
it a duty out of school to toil without reward?
Certainly not, except in the case of the mutual services which
friends and neighbours should yield to each other. But nobody
thought of toiling without reward, as far as Father Anthony knew.
The chank-fishers, he was sure, were paid. Rayo acknowledged
having received certain portions of rice, and of cotton for clothing;
but never any wages which would purchase what was necessary for
Marana before her father would allow her to marry. Rayo had no
objection to work, but he had not doubted about the liberty of
paying himself, in case of an insufficiency of wages. When he heard,
however, all the denunciations that Father Anthony had to bring
against the sin of theft, and it was pressed upon him that he had
actually been guilty of the crime, he was perfectly submissive; no
less so than Marana, though his eyes did not stream like hers, and
he did not so instantly betake himself to his devotions. He stood with
his eyes cast down, waiting for instructions.
“Your duty is clear, Rayo,” said Father Anthony. “He that hath
stolen must not only steal no more, but must restore what he hath
stolen. When the sun rises, you must go to the owners of these
chanks and restore them, relating your offence and seeking their
pardon;—I need not say humbly, for I have never observed you fail
in humility.”
Rayo made obeisance, and Marana hoped he might also relate
how he fell into the offence.
“If he does it without any pretence of justifying himself,” said
Father Anthony, who was not unwilling that the facts of the
oppression under which his poor friends laboured should be brought
home, on every possible occasion, to the owners of the wealth which
surrounded them, and which they might not appropriate, “Rayo may
say why he wishes for chanks and for the money that chanks will
bring; but he must not defend himself for having taken them without
leave. Neither must you excuse yourself before God, Rayo; but seek
His pardon before you sleep. May He pardon and bless you, Rayo!”
“How far will you have to carry them?” asked Marana, as soon as
Father Anthony was out of hearing. “If it is not too far for a woman,
I will go with you, and carry them, and confess for you. How far
must they be carried.”
Rayo pointed to his father’s hut,—his own abode, and began
walking towards it with a countenance of perfect content. But
Marana stopped, and looked the entreaty which she dared not
speak.
“They are heavy,” observed Rayo, taking the chanks from her.
“No, no. I will carry them to the mountains,—I will swim with
them through the sea, sooner than that the curse shall light upon
you, Rayo. Father Anthony says the curse comes upon those who do
not do as they say, and a great curse upon those who steal as we
have done, unless they restore.”
“It will bring a curse to say what he bids me say to the rich men. I
shall fish no more chanks, and lose what I have got, and perhaps
fish no pearls. This will be a curse.”
“But what will Father Anthony say to-morrow?”
“Let us see if he finds it out.”
“But the curse will come, whether Father Anthony knows or not.”
“Your father shall charm it away, and you shall have your rings;
and the rest shall be sold at the fishery. Then we will build a house,
and we will each have new clothing, and we will be married.—But let
us hide the chanks. If my father finds them, he will sell some. If
Neyna finds them, she will ask for rings too. We will hide them in the
rushes.”
Marana dared not resist, but her horror of the curse grew every
moment. She did not think at all the worse of her lover for his
determination. She rather admired the bravery of it, her thoughts
being employed, not on the sin, but on its apprehended
consequences. She doubted whether her father had a charm strong
enough to obviate the effects of her lover’s rashness; and she was
far less afraid of anything that might come out of the rushes than of
what might come out of the deed which Rayo went to do there.
When the torches were lighted, without which it is unsafe to
penetrate the places where leopards may be crouching on dry sand,
hidden by the silky rushes, she went first, fearing, not the glaring
eye of a savage beast, but the vigilant glance of some saint or
demon whom her religion or the old superstitions of the country
taught her to regard as the dispenser of punishment from above.
She started as the night-wind swept among the reeds, not so much
from dread of some velvet paw that might be stealing towards her,
as from expectation of some token of wrath. All was quiet, however.
The curse was not perceived immediately to light, and the lovers
parted in safety at the door of her father’s hut.
Marana stood for some time hesitating between lying down at
once on her mat to sleep, and waking her father, to trouble him for a
charm without loss of time. A better plan than either flashed across
her mind, and found more and more favour the longer she
entertained it. It might avert the curse without exposing Rayo to
shame; and the loss of the chanks (which was involved in her
scheme) was a small price to pay for such security. She hoped Rayo
might be brought to think so; and if not, she could rather bear his
anger than see the curse light upon him. The chanks were intended
chiefly for her; and she could do without them for ornaments, and
had rather marry Rayo without a house and without new clothing,
than expose him to the curse: and thus, by a process of reasoning
over which the fear of a curse presided, she convinced herself that
the best thing she could do was to restore the chanks to their oozy
bed.
Without a torch, for she had not now the means of getting one,
she stole out, and crept to the hiding place among the rushes.
Without bite from snake, or alarm from any living thing more
formidable than a bat, she made her way out again. Without help or
hinderance, she pushed the little raft into the water, hoisted its mast
and mat, and stood out alone into the shining sea. What kind of
malignant beings she could imagine to be hovering between the
glorious constellations and their earthly mirror, it was for her to tell.
The miseries which she believed them commissioned to dispense
came from a much nearer place than the nearest of those radiant
spheres, or even of the dense clouds which began to show like a low
wall along the horizon. The miseries under the pressure of which her
lover had committed crime, and she was now dreading the
atonement, came from the corrupt desires and infirm judgments of
men near at hand, whose passion was for the possession of the
powers of the earth, and not for alliance with the powers of the air.
When Rayo rose in the morning at his father’s call, to trim the
boat for a fishing expedition, he was surprised to see no sign of his
little raft on the beach. It might have been washed away,—the sea
being no longer so smooth as it was a few hours before: or some
unscrupulous neighbour might have used it for his own convenience.
It was of little consequence; a raft being the simplest and cheapest
of all contrivances by which a Cingalese can set himself afloat.—The
disappearance was explained when old Gomgode’s flat-bottomed
fishing-boat, containing himself and Rayo, had made some progress
from the land, and was pitching in the rising swell, while the young
man threw out his nets.
“Rayo, Rayo,” said Gomgode, “what is floating out beyond? Rayo,
Rayo, tell me whether it is not your raft.”
Rayo believed it was, but could scarcely distinguish it yet with
sufficient certainty to claim it. The old man’s sight might not be
really better than his son’s, but it was usually sharpened by curiosity
to a much greater degree than that of the less vivacious Rayo. He
now perceived that there was a woman upon the raft, and then Rayo
also began to see very clearly;—and not only to see, but to act.
Gomgode could not conceive what possessed Rayo to draw in the
nets so hastily, and quit their station, and give up every thing for the
sake of following or meeting this raft, when to-day, of all days, it
was important to secure a good draught of fish. They had come out
early on purpose, the auction of the oyster-banks being just about to
be held, giving a fine opportunity for the sale of fish. One boat after
another was dropping out from the shore, and Rayo was losing all
the advantage of being out first,—was giving up all his preparations,
for the sake of making towards the raft.
“Rayo, Rayo,” the old man exclaimed.
“Father, Marana is there, dripping and struggling.”
“Is it Marana? It is Marana. What sent her out, Rayo? How long
has she been out, Rayo? Did you know that she had your raft, Rayo?
O, Rayo, what is she going to do now, Rayo?”
Marana was about to do a somewhat perilous thing. She was
about to dash through a threatening wave as a horserider bursts
through a blind hoop, trusting to light again. The sea was now far
too rough for so slight a machine as this raft. It pitched and shivered
as every wave broke over it, and afforded so little secure hold
against the stronger swells which succeeded each other, that Marana
seemed to find it her best way to pass through them separately. She
was seen standing with her face towards the approaching wave,
eyeing it steadily, and cleaving her way through it so as to come out
near the very point to which the raft was descending from its ridge.
This was all very well for awhile; but Marana was yet a great way
from shore, and it was scarcely possible but that such a succession
of plunges must exhaust her before she could commit herself finally
to the waves to be cast upon the beach. It was contrary to her
habits also to use much exertion, and the effort which brought her
out thus alone upon the sea,—whatever might be its motive,—could
hardly be long sustained. Rayo was full of wonder and of fear; and
his father’s remonstrances and questions stood little chance of being
attended to till Marana was safe on board.
Marana herself, though by far the most deferential person that
Gomgode was wont to meet, could scarcely bring herself to give an
answer to his inquiries till she had obtained Rayo’s forgiveness for
having, at great sacrifice to herself, averted the curse from him.
Meek and downcast, the dusky beauty stood before him, her half-
clothed frame trembling with her late exertions, and the salt water
dripping from her hair. One corner of her garment seemed to be very
carefully cherished by her. It contained the precious right-handed
chank. She had not found in her heart to part with it, on arriving at
the place of deposit: and, while hesitating, several good reasons for
keeping it occurred to her,—as is not unfrequently the case with
those who are religious after her manner, any more than with those
who are not religious at all. It was a pity the shell should be lost,
and it was likely never to be fished up among so many. It might be
turned to a much better purpose, if her father would make it a
charm. There could be no sin in keeping it, if it was thus converted
to a religious use instead of being sold for a profit. Marana therefore
kept the chank, and was the better able to bear her lover’s
displeasure from the silent consciousness that she held a treasure
for him in her possession.
She did not make a syllable of reply to his lowering look and few
cutting words against herself; and when his wrath turned upon
Father Anthony, or rather upon any priest or religion which interfered
with his doings, Marana testified only by a slight glance round her
that she was uneasy under this rashness of complaint.
The moment the boat touched the shore after a prosperous trip,
she hastened to her father’s cottage, not waiting to observe how
much more Gomgode would ask for his fish than they were actually
worth, nor even to hear whether anything was yet known of the
quality of the oysters which had been brought up as a sample from
the pearl banks, and on whose evidence the auction was to proceed.
She had an office to discharge, in common with her neighbours;—to
dress and light up the road by which the agent of the government
was to approach: and she was anxious to obtain the desired favour
from her father before she went forth.
The Charmer, who was expecting an application, in the course of
this day, to hold his services in readiness for the fishery, was now
absorbed in his preparations. He sat in a corner of his hut with his
documents spread before him. Strips of the talipot-leaf, on which
some consecrated style, guided by a wise man’s hand, had traced
mysterious characters, lay before the Charmer, and beads and
images and various sacred indescribable articles were scattered
around. He gave no heed to his child when she entered, and his
melancholy countenance wore a deeper sadness than usual.
“Father!” softly said Marana, after some time waiting his pleasure;
“where will the sharks be during the fishery?”
The Charmer shook his head, and acknowledged his doubt
whether St. Anthony would be permitted to keep them all within the
bounds of Adam’s Bridge, or whether some would be left at large
between the north banks and the shore. The south banks would be
safe; but the north, alas! were those in which Marana was
interested.
“Father! the monsoon will surely not arrive too early?”
“Not till April is nearly past,” he replied, cheerfully. “It is even likely
that there may be complaints in the south of drought, from the delay
of the rains. There will be no storms in our fishery.”
“I will ask Father Anthony to praise the saints.—Will the fishery be
rich?”
“To some, and not to others. This is commonly the case; and I
cannot discover whose countenances will be sad in Aripo, and whose
merry voices will sing along the shore at Condatchy, when the last
signal-gun has brought back the last boat.”
There was a long pause before Marana ventured to utter the more
important question,
“Father! will any one be waited for in the paradise under the sea?”
The Charmer rubbed his hand over his brow, and said that this
was the point he was endeavouring to ascertain when his daughter
entered. His indications were at variance; and whether the fishery
was to be fatal to none, or to more than he had put the question for,
he could not decide.—Marana felt that she must request Father
Anthony to intercede with, as well as praise the saints.
“Is it a blind day to you, father?” she inquired, struck by his tone
of doubt on almost every topic she had introduced.
“My blind days are many,” he replied, “and the blindness troubles
me. Marcair looks doubtfully upon me, and I look doubtfully upon
myself,—because I warned him that a wild elephant would tread his
rice-ground seven nights ago. Marcair lighted eleven fires, and thirty-
two friends kept watch with him for three nights; and not a twig was
heard to snap in the jungle: and those who laid ear to the ground
say that not so much as a panther trod within a mile.”
“Seven nights since? That was the night that ball of white fire
crossed the sky——”
“A ball of fire! St. Anthony opened your eyes to see it! A ball of
white fire cast from the hand of a saint is more fearful than eleven
fires kindled by men’s hands.”
“The elephant was scared, father, no doubt. The ball passed over
that very jungle, and then above Marcair’s rice-ground, and then into
the sea.”
The Charmer’s spirits were so raised by the news of this
interposition, that he presently contrived to bring his most important
calculations to an agreement, and then lost no time in charming the
shell, that his daughter might be at liberty to reveal to the
neighbours what she had seen on the seventh preceding night, and
thus re-establish her father’s credit.
She had never heard her father speak more positively on any point
than on this,—that if Rayo was married to her before he went out to
the fishery, this charm would bring Rayo back safe from the fishery.
—It followed that Rayo should have his wish, and be married before
the adventure. There being no dwelling ready nor any thing to put
therein, was a matter of small moment in comparison with Rayo’s
safety.
Marana went forth with her usual slow and demure step and
demeanour: but the torches which flashed here and there on her
path were reflected back from her eyes as brightly as from the
topazes on the crown of her head. With a lighter, but no less
graceful touch than usual, did she unfurl the fan-like talipot leaves of
which the tents for the strangers were composed. With more than
her usual fancy did she feather with cocoa-nut leaves the poles of
bamboo to which torches were to be fastened at intervals along the
road. She was too poor to pay the tribute of white cotton cloth for
the government agent to walk upon, when he should arrive within
sight of the huts: but she had a new song to offer, which was worth
full as much. She had, besides, a little cocoa-nut oil to spare for the
anointing of a sister beauty or two, when she had made her own
toilet: so that the remark went round that Marana must have got
some new charm from her father for her special adornment. Rayo’s
manner seemed to show that he thought so too.
Chapter II.

A MUSHROOM CITY.

After the usual expenditure of anxiety, prudence, jealousy, wrath


and cunning, the letting of the Pearl banks had been accomplished.
A great speculator had offered government a certain sum for the
whole fishery of the season, and had then let the different banks to
various merchants, to whom the gracious permission was given to
make what they could of the natives of the land as well as of the
sea;—not only to appropriate the natural wealth of the region, but to
bring its inhabitants as near to the brink of starvation as they
pleased in their methods of employing their toil. Pearls seem to be
thought beautiful all over the world where they have been seen.
Empresses in the north, ladies of all degree in the east and west,
and savages between the tropics, all love to wear pearls; and where
is there a woman, in an Esquimaux hut or a Welsh farmhouse, who
would not wear pearls if she could obtain them? And why should not
all have pearls who wish for them, if there is a boundless store, and
labourers enough willing and ready to provide them? Alas! there are
not only few wearers of pearls because the interests of the many are
not consulted, but the labourers who obtain them are by the same
cause kept bare of almost the necessaries of life, going forth hungry
and half naked to their toil, and returning to seek rest amidst the
squalidness of poverty, while hundreds and thousands of their
families and neighbours stand on the shore envying them as they
depart, and preparing to be jealous of them on their return: both
parties being, all the while, the natural owners of the native wealth
of their region. And why is all this injustice and tyranny? That a few,
a very few, may engross a resource which should enrich the many.
Yet, not many things are more evident than that to impoverish the
many is the most certain method of ultimately impoverishing the
few; and the reverse. If the government would give away its pearl
banks to those who now fish those banks for the scantiest wages
which will support life, government would soon gain more in a year
from the pearls of Ceylon than it has hitherto gained by any five
fisheries. If buyers might bid for pearls from every quarter of the
world to those who might sell any where, and after their own
manner, Cingalese huts of mud and rushes would grow into
dwellings of timber and stone; instead of bare walls, there would be
furniture from a thousand British warehouses; instead of marshes,
there would be rice-fields; instead of rickety coasting boats, there
would be fleets of merchantmen riding in the glorious harbours of
the island; instead of abject prayers from man to man as the one is
about to suffer the dearth which the other inflicts, there would be
the good will and thanksgiving which spring from abundance;
instead of complaints on the one hand of expensive dependence,
and murmurs about oppression on the other, there would be mutual
congratulation for mutual aid. Ceylon would over pay, if required, in
taxes, if not in advantageous commerce, any sacrifice of the
monopolies by which she has been more thoroughly and ingeniously
beggared than any dependency on which British monopoly has
exercised its skill; and Britain might disburthen her conscience of the
crime of perpetuating barbarism in that fairest of all regions, for
whose civilization she has made herself responsible. There are many
methods of introducing civilization; and some very important ones
have been tried upon this beautiful island, and with as much success
as could be expected: but the most efficacious,—the prime method,
—is only beginning to be tried,—the allowing the people to gain the
property which nature has appointed as their share of her
distribution. Let the Cingalese gather their own pearls, exchange
their own timber, sell their own dyes wherever and in whatsoever
manner they like, and they will soon understand comfort, and care
for luxuries, like all who have comforts and luxuries within their
reach; and with these desires and attainments will come the
perceptions of duty,—the new sense of obligation which it is the
object of all plans of civilization to introduce.
Great pains had been taken to civilize Rayo. He had been schooled
and watched over—he could read, and he respected the religion of
his priest; he was willing to toil, and had a taste for comfort. But,
beyond the hope of acquiring a hut and a mat or two, there was
little stimulus to toil, and as little to conduct himself with a view
towards any future circumstances. Strangers not only carried away
the wealth of the land, but they prevented that wealth from
growing, and therefore the labour of the inhabitants from obtaining
a wider field. As pearls were fished ten years before, so they would
be fished ten years hence, for any probability that he saw to the
contrary. A thousand divers carried away a pittance then, insufficient
to bring over to them the desirable things which were waiting on the
shores of the neighbouring continent for a demand; and a like
pittance might such another thousand carry away in time to come;
in like manner might they sigh for foreign commodities, and in like
manner might foreign commodities be still waiting, wrought or
unwrought, for a demand. Therefore was Rayo still in a state of
barbarism, though he understood and praised the trial by jury, and
could read the prayers of his church. He was in a state of barbarism,
for these accomplishments had no influence on his conduct and his
happiness. He was selfish in his love; fraudulent with an easy
conscience in his transactions of business; and capable of a revenge
towards his superiors as remorseless as his deportment was gentle
and polished. No circumstance had ever produced so happy an effect
upon him as his advancement to be a pearl-diver, an advancement in
dignity, if not in gain. It was the last promotion he was ever likely to
obtain; but, besides that it softened his heart by occasioning his
immediate marriage, it gave him the new object of distinguishing
himself, and opened the possibility of his profiting by some stray
pearl, or by some chance opportunity of speculating on a lot of
oysters. He walked to join his company on the beach with a
demeanour unlike that by which Rayo was commonly known; and
his young wife looked after him with a new feeling of pride.
He was sure to be as safe as on shore, for the Charmer was to go
in the same boat, and no shark binder of the whole assemblage was
more confident of having effectually bound the sharks than Marana’s
father. All were confident; and the crowds on the beach looked as
joyous for the night as if the work was going on for their sakes. A
city of bowers seemed to have sprung up like Jonah’s gourd, or like
the tabernacles which, in old times of Jewish festivals, made
Jerusalem a leafy paradise for a short season of every year. Talipot
tents, and bamboo huts dressed with greens and flowers were
clustered around the sordid dwellings on the sands. Throngs of
merchants and craftsmen, black, tawny, and white, with their variety
of costumes, mingled in this great fair. The polisher of jewels was
there with his glittering treasure. The pearl-driller looked to his
needles and pearl dust, while awaiting on his low seat the materials
on which he was to employ his skill. The bald, yellow-mantled priest
of Budhoo passed on amidst obeisances in one place, as did the
Catholic pastor in another. The white vested Mahomedan, the
turbaned Hindoo, the swathed Malay merchants exhibited their
stores, or looked passively on the gay scene. The quiet Dutchman
from the south sent a keen glance through the market in quest of
precious stones in the hands of an ignorant or indolent vender. The
haughty Candian abated his fierceness, and stepped out of the path
of the European; while the stealthy Cingalese was in no one’s path,
but won his way like a snake in the tall grass of the jungle. The
restless lessees of the banks, meanwhile, were flitting near the
boats, now ranged in a long row, each with its platform, ropes and
pullies; each with its shark-binder, its pilot, its commander, its crew
of ten, and its company of ten divers. The boat-lights were being
kindled, one by one, and scattering a thousand sparkles over the
rippling tide. It was just on the stroke of ten, and the signal gun was
all that was waited for. The buzz of voices fell into a deep silence as
the expectation became more intense. Those who were wont to
make the heavens their clock and the stars its hour-hand, looked up
to mark the precise inclination of the Southern Cross; while those
who found an index in the flow of the tide, paced the sands from
watermark to watermark. Yet more turned their faces southward
towards the dark outline of hill and forest that rose on the horizon,
and watched for the land breeze. It came,—at first in light puffs
which scarcely bowed the rushes around the lagoons, or made a stir
among the stalks in the rice-ground. Moment by moment it
strengthened, till the sails of the boats began to bulge, and every
torch and faggot of cocoa-nut leaves on the beach slanted its forks
of flame towards the sea, as if to indicate to the voyagers their way.
Then the signal-gun boomed, its wreath of smoke curled lazily
upward and dispersed itself in the clear air, while a shout, in which
every variety of voice was mingled, seemed to chase the little fleet
into the distance. The shouting ceased amidst the anxiety of
watching the clusters of receding lights, which presently looked as if
they had parted company with those in the sky, and had become a
degree less pure by their descent. Then rose the song of the
dancing-girls, as they stood grouped, each with a jewelled arm
withdrawn from beneath her mantle, and her jet-black hair bound
with strings of pearl. Mixed with their chaunt, came the mutterings
and gabblings of the charmers who remained on shore, contorting
their bodies more vehemently than would have been safe on any
footing less stable than terra-firma.
The most imposing part of the spectacle was now to the people at
sea. As their vessels were impelled by an unintermitting wind
through the calmest of seas, they were insensible to motion, and the
scene on shore, with its stir and its sound, seemed to recede like the
image of a phantasmagoria, till the flickering lights blended into one
yellow haze in which every distinct object was lost. It became at
length like a dim star, contrasting strangely in brightness and in hue
with the constellation which appeared to rise as rapidly as
majestically over the southern hills, like an auxiliary wheeling his
silent force to restore the invaded empire of night. Night now had
here undisputed sway; for the torches which flared at the prows of
the boats were tokens of homage, and not attempts at rivalship of
her splendours.
Sailing is nearly as calculable a matter on these expeditions as a
journey of fifty miles in an English mail-coach. There is no need to
think about the duration of the darkness, in a region where the days
and nights never vary more than fifteen minutes from their equal
length; and, as for a fair wind, if it is certain that there will be one to
carry you straight out at ten to-night, it is equally certain that there
will be an opposite one to bring you straight in before noon to-
morrow. Nature here saves you the trouble of putting engine and
paddle-box into your boat, in order to be able to calculate your going
forth and your return. By the time the amber haze in the east was
parting to disclose the glories of a tropical sunrise, the fleet was
stationed in a circle over the banks. Every stray shark had received
its commands to close its jaws, and hie back to Adam’s Bridge; and
on each side of every platform stood five men, every one with his
foot slung on the pyramidal stone, whose weight must carry him
nine fathoms down into the regions of monstrous forms and
terrifying motions.
Rayo was one who was thus in readiness. He stood next to the
Charmer,—Marana’s father,—over whom a change seemed to have
come since he left the land. It might be from the fasting necessary
to his office; it might be from the intensity of his devotion; but it
might also be from fear, that his hands shook as he fumbled among
his sacred furniture, and his voice quavered as he chaunted his
spells. Rayo perceived his disorder, and a qualm came over the heart
of the young diver,—a qualm such as assails the servile agent of a
rich man’s prosperity much sooner than one in whom independence
brings bravery. Rayo looked keenly at the Charmer; but the Charmer
avoided meeting his eye, and it was not permitted to interrupt his
incantation.
It was, perhaps, not the better for Rayo that the opposite five
went first,—it gave more time for the unstringing of his nerves. The
splash of the thousand men who descended within the circle took
away his breath as effectually as the closing waters were about to
deprive him of it. It was a singular sight to see the half of this vast
marshalled company thus suddenly engulphed, and to think of them,
in one moment after, as forming a human population at the bottom
of the sea. To be a subject of the experiment was to the full as
strange as to witness it, as Rayo found, when the minute of his
companions’ submersion was at length over, and a thousand faces
(very nearly scarlet, notwithstanding their tawny skins) rushed up
through the green wave. Spouting, dripping, and panting, they
convulsively jerked their burden of oysters out upon the platform,
and then tried to deliver their news from the regions below; but for
this news their comrades must not wait. Down went Rayo, to find
out the difference between three fathoms and nine. How far the
lively idea of a shark’s row of teeth might have quickened his
perceptions, he did not himself inquire; but he was conscious of a
more dazzling flash before his eyes, a sharper boring of the drum of
his ear, and a general pressure so much stronger than ever before,
that it would have been easy for him to believe, if he had been a
Hindoo, like his neighbours, that he supported the tortoise that
supported the elephant that supported the globe. He could see
nothing at first in the dizzy green that was suffocating and boiling
him; but that did not signify, as he had no time to look about him.
He thought he was descending clean into a shark’s jaws, so sharp
was that against which his left great toe struck, when his descent
from the ninth heaven to the ninetieth abyss was at length
accomplished. (How could any one call it nine fathoms?) On meeting
this shark’s tooth, or whatever it was, yelling was found to be out of
the question. It was luckily forgotten in the panic, that the rope was
to be pulled in case of accident;—luckily, as there was no alternative
between Rayo’s losing all credit as a diver, and the fishing being at
an end for that day, from his spreading the alarm of a shark. He did
not pull the rope; he only pulled up his left leg vigorously enough to
assure himself that it was still in its proper place; by which time he
discovered that he had only mistaken a large, gaping oyster for a
hungry shark. Rayo’s great toe being not exactly the viand that this
oyster had a longing for, it ceased to gape, and Rayo manfully
trampled it under foot, before wrenching it from the abode of which
its seven years’ lease had this day expired. These oysters required a
terrible wrenching, considering that there was no taking breath
between. Now he had got the knack. A pretty good handful, that!—
St. Anthony! where did that slap in the face come from—so cold and
stunning? Rayo’s idea of a buffet from the devil was, that it would be
hot; so he took heart, and supposed it was a fish, as indeed it was.
He must go now,—O! O! he must go. He should die now before he
could get up through that immeasurable abyss. But where was the
rope? St. Anthony! where was the rope? He was lost! No! it was the
rope slapped his face this time. Still he was lost! A shadowy, striding
mountain was coming upon him,—too enormous to be any fish but a
whale. Suppose Rayo should be the first to see a whale in these
seas! St. Anthony! It was one of his companions. If they were not
gone up yet, could not he stay an instant longer, and so avoid being
made allowance for as the youngest diver of the party? No, not an
instant. He rather thought he must be dead already, for it was hours
since he breathed. He was alive enough, however, to coil himself in
the rope. Then he went to sleep for a hundred years; then,—what is
this? dawn? A green dawn?—brighter,—lighter,—vistas of green light
everywhere, with wriggling forms shooting from end to end of them.
Pah! here is a mouthful of ooze. Rayo should not have opened his
mouth. Here is the air at last! Rayo does not care; the water does as
well by this time. If he is not dead now, water will never kill him, for
he has been a lifetime under it.
“Well, Rayo,” says the captain, “you have done pretty well for the
first time. You have been under water a full minute, and one man is
up before you. Here comes another.”
“A full minute!”
Even so. Who has not gone through more than this in a dream of
less than a minute? and yet more if he has been in sudden peril of
instant death, when the entire life is lived over again, with the single
difference of all its events being contemporaneous? Since it is
impossible to get into this position voluntarily, let him who would
know the full worth of a minute of waking existence, plunge nine
fathoms deep,—not in the sandy ooze of a storm-vext ocean, where
he might as well be asleep for anything that he will see,—but in
some translucent region which Nature has chosen for her treasury.
Rayo had re-discovered one of the natural uses of air; but he was
in despair at the prospect before him. Forty or fifty such plunges as
this to-day! and as many more to-morrow, and almost every day for
six weeks! Forty or fifty life-times a-day for six weeks! This is not the
sort of eternity he had ever thought of desiring: and if purgatory is
worse, Father Anthony had not yet spoken half ill enough of it. Rayo
had better turn priest: he could speak eloquently now on any subject
connected with duration.
Before the end of the day’s work, however, the impression was
much weakened. The minutes of submersion grew shorter, fish and
their shadows more familiar, and much of the excessive heat and
cold were found to have proceeded from within. Before noon, Rayo
could consider of certain things to be attended to on the platform, as
well as on the oyster-bed.
Oysters gape sometimes in the air as well as in the water. As Rayo
floated in the intervals of his plunges, (having grown so hardy as to
resist the remonstrances of the Charmer,) he observed the
commander take the opportunity of slipping a morsel of wood into
any oyster-shell that might happen to open, to prevent its closing
again, and thus to save the necessity of waiting for the putrefaction
of the fish before its treasure could be extracted. Rayo also
perceived, that by an unheeded touch of the commander’s foot, one
of these oysters was dislodged from its horizontal position, and
slipped with its hinge uppermost, so as to give exit to a large white
pearl, so round that it rolled on and on, till it was stopped by a piece
of rope, under whose shadow it lay apparently unperceived. It would
have been risking too much to mount the boat in this present
interval, for the purpose of picking up the pearl. Rayo must wait till
after the next plunge; and in the meantime, it was but too probable
somebody would move the rope, and either discover the pearl, or let
it run away to some useless place. Such a pearl as this was worth all
the chanks that Marana had cast away, including the right-handed
one. Such a pearl as this would build a boat as well as a house, and
make Marana look like a bride indeed. Such a pearl as this was no
more than Rayo believed the proper payment of his labour,
considering that strangers carried away all the profit from the
country people. Such a pearl—this very pearl—might have come into
his possession, if he had taken the chance, like some of his
companions, of a lot of oysters, instead of small, fixed wages. In
short, Rayo designed to have the pearl, and found means of
justifying the act of dishonesty, which he would have strongly
scrupled if he had been serving a party in whose prosperity he was
interested, instead of one who interfered with the prosperity of
himself and his countrymen. What Father Anthony had taught served
little other purpose at present than quickening Rayo’s ingenuity in
finding reasons for doing whatever suited him. Such instruction
might confirm and exalt his integrity, when he should have any. In
the meantime, his social circumstances did more to make him
dishonest than his religion to render him honest.
When he came up next time, he made so much haste to scramble
into the boat, and seemed so much hurried that the Charmer started
up in terror lest he should have lost a limb,—an accident which the
binder of sharks had been expecting all the morning, from a
complete failure of confidence in his own skill. When he saw that all
was safe, he very nearly forgot his dignity so far as to assist the
youth in emptying his net of oysters upon the heap in the middle of
the platform. He stopped short, however, on Rayo’s repulsing his
offers of help, and went back to his seat, commending the practice
of coming on board instead of floating between the plunges. Rayo
sank down on his knees to empty his pouch. The rope was within
reach, and under it still lay the pearl. It was very natural for Rayo to
draw the rope towards him, if he really wanted to ascertain whether
the one round his body was strong enough; but it was not equally
natural for him to put his hand to his mouth under pretence of
dashing the wet from his face where little wet remained. So, at least,
the commander thought; and he was confirmed by observing a
hasty effort to swallow when Rayo was summoned to descend again.
Measures of which the youth little dreamed were in preparation for
him while he was down. He was hoisted upon the platform, and
before he knew what he was about, a man seized him by either arm,
a third stepped behind him, flourishing a knotted rope, while a
fourth presented a cocoa-nut shell of liquid, which did not look or
smell very tempting. He was told of a summary sentence to be
flogged for putting his hand to his mouth while within arm’s-length
of oysters, (a great crime in Ceylon, whatever it may be elsewhere,)
and to swallow a strong emetic as the ordeal of innocence of a
further crime. It would have been useless to attempt to upset the
cup; for a double dose would have been the consequence, an ample
stock of emetics being the part of the apparatus of pearl-fishing
least grudged by the speculators. Bolting was equally impossible.
There was nothing for it but to bolt the medicine. The pearl of
course appeared, in due time; and when it once more vanished
beneath the lid of the commander’s spring-box, the fairest of poor
Rayo’s hopes vanished with it. He might consider himself, not
disgraced,—for his companions were wont to applaud the act of
stealing pearls,—but turned off from his employment for this bout,
and precluded from the means of establishing Marana in any thing
better than four bare mud walls.
“Pillal Karra,” (binder of sharks,) “you are wise,” observed the
commander respectfully. “I have seen your downcast looks.
Doubtless you knew what should befal this youth.”
“If any doubted our power,” said the Charmer, “they should
observe how a mysterious trouble comes first to foreshow the
misfortune that will follow. When I was younger, I was content to
keep off the misfortune; and when I was over-ruled by the Malabar
hags, to let the mischief come without warning to myself. Now when
my mind is tossed, I am learning to know that the Malabar hags are
riding a coming storm.”
“Have these hags bewitched your son-in-law?”
“No doubt; and I know which of them it is. It is Amoottra, who
owes me a grudge on account of Marana’s beauty. If she could meet
my daughter out of the line of my charms, she would touch her with
leprosy.”
“Well; if you can convince my employer of this, and disenchant
Rayo, he may come out again to-morrow. Otherwise, he has taken
his last plunge for this season; for there parts the first boat from the
circle.”
As the boats warped round into line, the sea-breeze freshened,
and all were presently making a steady progress homewards. Almost
as soon as they came in sight of the orange-tinted shore, apparently
floating in the hot haze of noon, they saw a spark glitter, and some
seconds after came the boom of the signal-gun which was to
announce their return to the anxious speculators and the public at
large in the fair. The flag was next hoisted, and then every man,
woman, and child was looking to seaward while hastening to secure
standing-room on the margin of the tide. The Charmers began to be
ambiguous about this day’s success, and to prophesy magnificently
for the next. The dancing girls stationed themselves round certain
matted enclosures, ready to welcome the oysters to their place of
putrefaction. Father Anthony borrowed a telescope of a contractor,
whose hand shook so that he could make no use of it himself; and
Marana stood apart under the shade of a talipot leaf, lowering her
primitive umbrella, with tantalizing constancy, as often as a gallant
stranger or a curious country-woman would have peeped under it.
A talipot leaf will shelter two heads, and hide two faces, as was
soon proved with Marana’s. Rayo did not particularly wish to
encounter Father Anthony, and had withdrawn Marana among the
huts, where, screened by the umbrella, they mourned the
adventure. Father Anthony’s eyes, however, were keen. Keenly they
peered under the shelter, and made Rayo’s droop before them. In
vain Rayo pleaded his father-in-law’s word, that he was bewitched
by a Malabar hag. Father Anthony did not allow Malabar hags to lay
waste the fold of which he was the shepherd.—Rayo bowed his head
submissively, and waited for orders.
“Do not insult the contractor by a plea of witchcraft.”
“I will not, father.”
“Do not seek to be employed again this season. There are many
waiting for the office who deserve it better than you. For this
season, I shall recommend Tilleke in your place; by next season, I
hope you will have wrestled with temptation, so that I may send my
blessing forth with you.”
“Is the blessing passed away?” asked Rayo, prostrating himself
before the priest, with deep sorrow in his tone and countenance.
“Perhaps not, if you will freely confess.”
“I will, father.”
Marana moved away, and remained out of hearing with her back
turned towards them, till the priest at length passed her. Dropping a
few words of good cheer, he exhorted her to be a tender wife, but
withal faithful to her religion, and then he trusted Rayo would
become proof against every kind of evil instigation or influence. It
really was remarkable that such influences seemed to beset him in
particular places. His sins of theft took place at sea, where
compunction never seemed to visit him; while no one could be more
penitent and submissive than Rayo on land. Did Marana know of any
instance of his committing a theft on shore, or being penitent at
sea? Marana could recollect none, and was confirmed in her dread of
the Malabar witch. If she could but get Rayo farther inland!—she
said to herself, as father Anthony gave her his blessing, and went on
his way.
This aspiration was nearer its accomplishment than she could have
supposed.
“Rayo, what could make you take the pearl?” she asked, when she
returned to her husband.
“If there were a cocoa-nut tree here, as in the south, I should not
want the money which I cannot get. We might build under its shade,
and eat its fruit, and drink the milk from the kernel, and make our
ropes of its fibres, and burn lamps of its oil. But as there are no
cocoa-nuts where we live, I got chanks. You threw them away, and I
tried to get a pearl. If I must not have a pearl——”
“Let us go to the cocoa-trees, as they cannot come to us.”
“If I go at all, I will go far;—down among the cinnamon gardens,
Marana.”
“Not to be a cinnamon peeler!” exclaimed Marana, who thought
she saw a desperation in her husband’s countenance, such as a man
might wear who was about to lose caste. It was now a disputed
point which caste ought to rank highest,—the fishermen or the
cinnamon-peelers; but Marana, as in duty bound, as a fisherman’s
daughter, regarded the cinnamon-peelers as upstarts. “You, a
fisherman, will not mix with the cinnamon-peelers?”
Rayo explained no more of his purpose in going among the
cinnamon gardens than that it was not to mix with the peelers. But
he gloomily hinted that perhaps Marana ought not to go,—would she
not there be out of the limit of her father’s charms? Might not the
hag Amoottra——
“Touch me with leprosy? No,” said Marana, producing the precious
shell from a corner of her mantle. “My father needs not draw out his
spell at home while I carry this with me. I have shown it to you,
Rayo, but you will not sell it? If we live among the cocoa-nuts, we
shall not want the money. You will not take it from me to part with
it?”
Rayo let her deposit it in her mantle, and then she was ready to
go. Every thing that she possessed was now on her person. Her
father was certain, from the nature of his profession, of being well
taken care of; and, if not, her husband’s claims upon her would have
been paramount. Leaving the Charmer to discover by his spells why
and whither they were gone, and old Gomgode to catch fish for
himself and his daughter, the young folks stole away towards the
richer country to the south. They knew that there was little danger
of pursuit. There was no lack of divers to supply Rayo’s place.
Nobody supposed they would actually starve; and, as for living
poorly, it was what thousands had done before them, thousands
were doing now, and thousands would do after them. Gomgode
supposed Rayo would preserve caste. The charmer trusted his
daughter not to expose herself rashly to the hag’s wrath, as she
knew the consequences. Perhaps Father Anthony missed and
mourned them most; but he had a firm faith that Rayo would prove
an honester man in the jungle, or among the paddy-fields, than on a
haunted sea.
Chapter III.

MORNING IN THE JUNGLE.

During the time of the cinnamon harvest, it was the custom of Mr.
Carr, the agent of the East India Company for the management of
their cinnamon contract, to ride every morning through one
department or another of the Marandahn, or great cinnamon garden
near Columbo. The beauty of the ride might afford sufficient
temptation at any season of the year. The blue lake of Colombo,
whether gleaming in the sunrise, or darkening in the storms of the
monsoon, never lost its charms. The mountain range in the distance
was an object for the eye to rest lovingly upon, whether clearly
outlined against the glowing sky, or dressed in soft clouds, from
which Adam’s Peak alone stood aloft, like a dark island in the waters
that are above the firmament.
Whether the laurel-like cinnamon wore its early foliage of red or
its later of green, or its white blossom that made the landscape
dazzling with beauty and voluptuous with fragrance; whether the
talipot upreared its noble crest of straw-coloured blossoms above its
green canopy, or presented its clustering fruit; whether the cocoa-
nut tree bowed before the gusts of autumn, or stood in dark,
majestic clumps above the verdure of a less lofty growth, the groves
and gardens were a paradise to the eye of the Europeans.
The reaches of road, and the green paths which might be
detected here and there amidst the vast plantation, the rice grounds
and patches of meadow land interspersed, and the lowly roof
peeping out occasionally from beneath the palms, gave hints of the
presence of man and civilization; while the temple, with its oriental
dome supported on slender pillars, jutting out at the extreme end of
a promontory into the blue waters of the lake, or perched on some
point of the piled rocks in the background, carried back the thoughts
to old days of barbarian superstition. In all this there was so much
pleasure as to make a ride in the Marandahn a tempting pleasure at
all times and seasons; though Mr. Carr’s interest was at its height
during the cinnamon harvest.
As he was about to mount his horse one morning, the sound of
argument, not to say dispute, reached him from within.
“My dear child,” Mrs. Carr was saying, “Roomseree and Pellikee
shall give you an airing nearer home, so that you will not be killed
with the heat. Do not think of going with papa this morning.”
“O, mama, you know papa says nothing tires me. I can ride as far
as papa; and papa says he likes to show me what the people are
doing; and I am sure the people like me to go too. Papa enjoys his
ride so much more when I go with him; and the horse does not
think me very heavy.”
“Heavy! no, love! You are so small and slight, Alice, that it makes
me tremble to think of your going out under such a sun as it will be
by the time you get back. Papa always promises to take a very short
ride; and it ends with his bringing you home at the end of four or
five hours. Better stay with me, love.”
“All the rest of the day, mama; but papa has had the right saddle
put on, and we are to go the west ride this morning. Cannot you go
to sleep till we come back?”
Mrs. Carr promised to try; and, to do her justice, she was always
ready to do her best to sleep, day and night, bidden and unbidden.
With a few sighs over the charming spirits and the unquenchable
curiosity of the dear child, she closed her eyes on the dewy radiance
of a morning in paradise, and was glad that she had nothing more to
do with cinnamon than to be tired of hearing of it, and to taste it
when she pleased.
Alice used her eyes to more purpose this morning. She was yet
new enough to scenes like those before her to be full of wonder, and
other feelings, as natural, perhaps, but less desirable.
“Papa, do giants live in this place?”
“Giants, my dear, no. What made you fancy such a thing? You
have seen no very amazing people, have you?”
“No; they are very small pretty people, I think. Sometimes, when I
see them under such a very tall clump of trees as that, or among the
jungle grass, they put me more in mind of dark fairies than giants;
but——”
“But the trees are some of them fit for giants’ walking-sticks, I
suppose you think; and an elephant is a very proper animal for a
giant to ride. Hey?”
“I have seen men on elephants,” replied Alice. “But look there!
Look at that great castle!” And she pointed with awe to a mighty
object which was partially revealed as the morning mists drew off.
“That is not a castle, my dear; though I do not wonder at your
taking it for one. It is a mountain-peak.”
“But the drawbridge, papa;—the drawbridge hanging in the air.”
“Ah! you would be a long time in finding out what that drawbridge
(as you call it) is. You think it made for giants; but it would break
down under your weight. That is only a bridge of creeping plants, for
birds and butterflies to hide in. If a strong wind came, you would see
it swing, like your swing between the cherry trees in the orchard at
your grandmama’s, in England.—When we get out of the garden and
nearer the thickets, you will see some such flowers as that bridge is
made of, hanging from the trees, and binding them together so that
we cannot ride through them.”
“But I do not want to get out of the garden yet. Here come the
people, one after another, from their cottages, with their crooked
knives to cut down the branches. What are those tawny people
doing in the shade? They seem to be sitting very comfortably, all in a
ring. This is prettier than seeing grandmama’s mowers in England,
besides that the mowers do not sing at their work, like these
people.”
“The mowers in England have more reason to sing than many of
these peelers. Look how thin many of them are; and that poor child
playing in the grass appears half-starved. Very few people in England
are so poor as some of the natives here, who yet sing from morning
till night.”
Alice observed that they were not all thin; and she pointed to one
man whose legs were of an enormous size, and to another whose
body was nearly as broad as it was long.—She was told that these
appearances were caused by disease; and that the diseases of the
labourers were in a great degree owing to their poor way of living.
There would be few such swollen or emaciated bodies as these if the
people had flesh to eat, or good bread, or even the seasoning which
was necessary to make their vegetable food agree with them.
“Seasoning! What sort of seasoning?”
“Salt, and pepper, and cardamoms, and cinnamon.”
“Salt, papa! They must be very lazy if they do not get salt enough.
There is the sea all round Ceylon; and I have seen several ponds
where the water was so salt I could not drink it. There was a crust
of salt all about the edge, papa.”
“Very true, my dear; but the people are not allowed to take it. The
king of Candy lives in the middle of this island; and the kings of
Candy have sometimes been troublesome people to the English, as
they were to the Dutch before them. Now, as the king of Candy
cannot get to the sea, or to any salt lake, without our king’s leave,
he and his people depend upon us for salt; and our government likes
to keep him quiet, and get a great price for its salt at the same time
by selling it to the Candians very dear, and by letting nobody else
sell any. So the people of the country are not allowed to help
themselves to salt.”
“But if there was not enough, I would rather make the king of
Candy go without than these poor people who belong to us. We
ought to take care of them first.”
“The government likes to take care of itself before either its own
people or the Candians. There is salt enough for every body here,
and for half India besides; and large quantities are destroyed every
year, to keep up the price, while many are dying for want of it, and
those who live can get nothing better than coarse dirty salt which
the beasts in your grandmama’s farm-yard would turn away from. If
we could count the numbers of Hindoos who die in India for want of
the salt which their own country produces, we should find that a
fearful reckoning awaits the Company there, as there does the
government here; a fearful balance of human life against a high
price for salt.”
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

textbookfull.com

You might also like