From acf3bff703530432bad37a7aa76eae34775e66a4 Mon Sep 17 00:00:00 2001 From: Luke Galea Date: Tue, 18 Jan 2011 15:14:31 -0500 Subject: [PATCH] Corrected some spelling mistakes and grammar. Changed some awkward wording. Changed api -> API, utilize -> use. Signed-off-by: Luke Galea --- chapters/buffers.md | 8 ++++---- chapters/events.md | 6 +++--- chapters/fs.md | 2 +- chapters/globals.md | 10 +++++----- chapters/installation.md | 4 ++-- chapters/modules.md | 8 ++++---- chapters/streams.md | 2 +- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/chapters/buffers.md b/chapters/buffers.md index b0ce4f5..04d0f1a 100644 --- a/chapters/buffers.md +++ b/chapters/buffers.md @@ -13,7 +13,7 @@ The simplest way to construct a `Buffer` from a string is to simply pass a strin console.log(hello.toString()); // => "Hello" -By default the encoding is "utf8", however this can be specified by passing as string as the second argument. The ellipsis below for example will be printed to stdout as the '&' character when in "ascii" encoding. +By default the encoding is "utf8", however this can be specified by passing a string as the second argument. The ellipsis below for example will be printed to stdout as the '&' character when in "ascii" encoding. var buf = new Buffer('…'); console.log(buf.toString()); @@ -23,7 +23,7 @@ By default the encoding is "utf8", however this can be specified by passing as s console.log(buf.toString()); // => & -An alternative method is to pass an array of integers representing the octet stream, however in this case functionality equivalent. +An alternative method is to pass an array of integers representing the octet stream. The case below is functionally equivalent. var hello = new Buffer([0x48, 0x65, 0x6c, 0x6c, 0x6f]); @@ -36,7 +36,7 @@ Buffers can also be created with an integer representing the number of bytes all console.log(buf.toString()); // => "Hello" -The `.length` property of a buffer instance contains the byte length of the stream, opposed to JavaScript strings which will simply return the number of characters. For example the ellipsis character '…' consists of three bytes, however the buffer will respond with the byte length, and not the character length. +The `.length` property of a buffer instance contains the byte length of the stream, as opposed to JavaScript strings which will simply return the number of characters. For example the ellipsis character '…' consists of three bytes, however the buffer will respond with the byte length, and not the character length. var ellipsis = new Buffer('…', 'utf8'); @@ -51,7 +51,7 @@ The `.length` property of a buffer instance contains the byte length of the stre When dealing with JavaScript strings, we may pass it to the `Buffer.byteLength()` method to determine it's byte length. -The api is written in such a way that it is String-like, so for example we can work with "slices" of a `Buffer` by passing offsets to the `slice()` method: +The API is written in such a way that it is String-like, so for example we can work with "slices" of a `Buffer` by passing offsets to the `slice()` method: var chunk = buf.slice(4, 9); console.log(chunk.toString()); diff --git a/chapters/events.md b/chapters/events.md index eea695c..710acfa 100644 --- a/chapters/events.md +++ b/chapters/events.md @@ -5,7 +5,7 @@ ## Emitting Events -Typically an object inherits from _EventEmitter_, however our small example below illustrates the api. First we create an `emitter`, after which we can define any number of callbacks using the `emitter.on()` method which accepts the _name_ of the event, and arbitrary objects passed as data. When `emitter.emit()` is called we are only required to pass the event _name_, followed by any number of arguments, in this case the `first` and `last` name strings. +Typically an object inherits from _EventEmitter_, however our small example below illustrates the API. First we create an `emitter`, after which we can define any number of callbacks using the `emitter.on()` method which accepts the _name_ of the event, and arbitrary objects passed as data. When `emitter.emit()` is called we are only required to pass the event _name_, followed by any number of arguments, in this case the `first` and `last` name strings. var EventEmitter = require('events').EventEmitter; @@ -20,7 +20,7 @@ Typically an object inherits from _EventEmitter_, however our small example belo ## Inheriting From EventEmitter -A perhaps more practical use of `EventEmitter`, and commonly used throughout node is to inherit from it. This means we can leave `EventEmitter`'s prototype untouched, while utilizing its api for our own means of world domination! +A perhaps more practical use of `EventEmitter`, and commonly used throughout node is to inherit from it. This means we can leave `EventEmitter`'s prototype untouched, while using its API for our own means of world domination! To do so we begin by defining the `Dog` constructor, which of course will bark from time to time, also known as an _event_. @@ -50,7 +50,7 @@ Bark twice a second: ## Removing Event Listeners -As we have seen event listeners are simply functions which are called when we `emit()` an event. Although not seen often we can remove these listeners by calling the `removeListener(type, callback)` method. In the example below we emit the _message_ "foo bar" every `300` milliseconds, which has the callback of `console.log()`. After 1000 milliseconds we call `removeListener()` with the same arguments that we passed to `on()` originally. To compliment this method is `removeAllListeners(type)` which removes all listeners associated to the given _type_. +As we have seen, event listeners are simply functions which are called when we `emit()` an event. Although not seen often we can remove these listeners by calling the `removeListener(type, callback)` method. In the example below we emit the _message_ "foo bar" every `300` milliseconds, which has the callback of `console.log()`. After 1000 milliseconds we call `removeListener()` with the same arguments that we passed to `on()` originally. To compliment this method is `removeAllListeners(type)` which removes all listeners associated to the given _type_. var EventEmitter = require('events').EventEmitter; diff --git a/chapters/fs.md b/chapters/fs.md index 70daa07..bb34cdf 100644 --- a/chapters/fs.md +++ b/chapters/fs.md @@ -84,7 +84,7 @@ ## Nodejs Docs for further reading - The node api [docs](http://nodejs.org/api.html#file-system-106) are very detailed and list all the possible filesystem commands + The node API [docs](http://nodejs.org/api.html#file-system-106) are very detailed and list all the possible filesystem commands available when working with Nodejs. diff --git a/chapters/globals.md b/chapters/globals.md index a700986..f536227 100644 --- a/chapters/globals.md +++ b/chapters/globals.md @@ -1,7 +1,7 @@ # Globals - As we have learnt node's module system discourages the use of globals, however node provides a few important globals for use to utilize. The first and most important is the `process` global which exposes process manipulation such as signalling, exiting, the process id (pid), and more. Other globals help drive to be similar to other familiar JavaScript environments such as the browser, by providing a `console` object. + As we have learnt node's module system discourages the use of globals, however node provides a few important globals for us to use. The first and most important is the `process` global which exposes process manipulation such as signalling, exiting, the process id (pid), and more. Other globals help drive to be similar to other familiar JavaScript environments such as the browser, by providing a `console` object. ## console @@ -9,7 +9,7 @@ The `console` object contains several methods which are used to output informati ### console.log() -The most frequently used console method is `console.log()` simply writing to _stdout_ with a line feed (`\n`). Currently aliased as `console.info()`. +The most frequently used console method is `console.log()` which simply writes to _stdout_ with a line feed (`\n`). Currently aliased as `console.info()`. console.log('wahoo'); // => wahoo @@ -19,13 +19,13 @@ The most frequently used console method is `console.log()` simply writing to _st ### console.error() -Identical to `console.log()`, however writes to _stderr_. Aliased as `console.warn()` as well. +Identical to `console.log()`, however it writes to _stderr_. Aliased as `console.warn()` as well. console.error('database connection failed'); ### console.dir() -Utilizes the _sys_ module's `inspect()` method to pretty-print the object to +Uses the _sys_ module's `inspect()` method to pretty-print the object to _stdout_. console.dir({ foo: 'bar' }); @@ -39,7 +39,7 @@ Asserts that the given expression is truthy, or throws an exception. ## process -The `process` object is plastered with goodies, first we will take a look +The `process` object is plastered with goodies. First we will take a look at some properties that provide information about the node process itself. ### process.version diff --git a/chapters/installation.md b/chapters/installation.md index 5d4ebe7..db02eb3 100644 --- a/chapters/installation.md +++ b/chapters/installation.md @@ -24,7 +24,7 @@ several 3rd party modules. module visionmedia jade module visionmedia ejs -Any machine that can run a shell script can install distributions, and keeps dependencies defined to a single directory structure, making it easy to maintain an deploy. nDistro uses [pre-compiled node binaries](http://github.com/visionmedia/nodes) making them extremely fast to install, and module tarballs which are fetched from [GitHub](http://github.com) via _wget_ or _curl_ (auto detected). +Any machine that can run a shell script can install distributions, and keeps dependencies defined to a single directory structure, making it easy to maintain and deploy. nDistro uses [pre-compiled node binaries](http://github.com/visionmedia/nodes) making them extremely fast to install, and module tarballs which are fetched from [GitHub](http://github.com) via _wget_ or _curl_ (auto detected). To get started we first need to install nDistro itself, below we _cd_ to our bin directory of choice, _curl_ the shell script, and pipe the response to _sh_ which will install nDistro to the current directory: @@ -59,6 +59,6 @@ For those without _git_, or who prefer not to use it, we can also download the s $ curl -# http://nodejs.org/dist/node-v0.1.99.tar.gz > node.tar.gz $ tar -zxf node.tar.gz -Now that we have the source on our machine, we can run `./configure` which discovers which libraries are available for node to utilize such as _OpenSSL_ for transport security support, C and C++ compilers, etc. `make` which builds node, and finally `make install` which will install node. +Now that we have the source on our machine, we can run `./configure` which discovers which libraries are available for node to use such as _OpenSSL_ for transport security support, C and C++ compilers, etc. `make` which builds node, and finally `make install` which will install node. $ ./configure && make && make install diff --git a/chapters/modules.md b/chapters/modules.md index 33d7925..3495cd6 100644 --- a/chapters/modules.md +++ b/chapters/modules.md @@ -3,7 +3,7 @@ [CommonJS](http://commonjs.org) is a community driven effort to standardize packaging of JavaScript libraries, known as _modules_. Modules written which comply to this standard provide portability between other compliant frameworks such as narwhal, and in some cases even browsers. -Although this is ideal, in practice modules are often not portable due to relying on apis that are currently only provided by, or are tailored to node specifically. As the framework matures, and additional standards emerge our modules will become more portable. +Although this is ideal, in practice modules are often not portable due to relying on APIs that are currently only provided by, or are tailored to node specifically. As the framework matures, and additional standards emerge our modules will become more portable. ## Creating Modules @@ -45,7 +45,7 @@ on the `exports` object like so: return obj; }; -Next we will look at utilizing out new module in other libraries. +Next we will look at using our new module in other libraries. ## Requiring Modules @@ -77,7 +77,7 @@ This technique is usually only helpful when your module has one aspect that it w exports.Animal = function Animal(){}; -which can then be utilized as shown: +which can then be used as shown: var Animal = require('./animal').Animal; @@ -91,7 +91,7 @@ which can now be used without the property: ## Require Paths -We talked about `require.paths`, the `Array` utilized by node's module system in order to discover modules. By default node checks the following directories for modules: +We talked about `require.paths`, the `Array` used by node's module system in order to discover modules. By default node checks the following directories for modules: - ``/../../lib/node - **$HOME**/.node_libraries diff --git a/chapters/streams.md b/chapters/streams.md index 238311d..70d0aa9 100644 --- a/chapters/streams.md +++ b/chapters/streams.md @@ -1,7 +1,7 @@ # Streams - Streams are an important concept in node. The stream api is a unified way to handle stream-like data, for example data can be streamed to a file, streamed to a socket to respond to an HTTP request, or a stream can be read-only such as reading from _stdin_. However since we will be touching on stream specifics in later chapters, for now we will concentrate on the api. + Streams are an important concept in node. The stream API is a unified way to handle stream-like data, for example data can be streamed to a file, streamed to a socket to respond to an HTTP request, or a stream can be read-only such as reading from _stdin_. However since we will be touching on stream specifics in later chapters, for now we will concentrate on the API. ## Readable Streams