diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..48ecc30c3 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +raw \ No newline at end of file diff --git a/docs/images/background.png b/docs/images/background.png new file mode 100644 index 000000000..90ee6934d Binary files /dev/null and b/docs/images/background.png differ diff --git a/docs/images/bright_squares.png b/docs/images/bright_squares.png new file mode 100644 index 000000000..c75a05a94 Binary files /dev/null and b/docs/images/bright_squares.png differ diff --git a/docs/images/goovepaper.png b/docs/images/goovepaper.png new file mode 100644 index 000000000..61f81a763 Binary files /dev/null and b/docs/images/goovepaper.png differ diff --git a/docs/images/subtle_freckles.png b/docs/images/subtle_freckles.png new file mode 100644 index 000000000..1a3a99ffd Binary files /dev/null and b/docs/images/subtle_freckles.png differ diff --git a/docs/images/underscore.png b/docs/images/underscore.png new file mode 100644 index 000000000..dce9edb0f Binary files /dev/null and b/docs/images/underscore.png differ diff --git a/index.html b/index.html index d1e7d002b..82ee1d26d 100644 --- a/index.html +++ b/index.html @@ -6,37 +6,81 @@
+
+
Underscore is a @@ -135,122 +319,9 @@ -
- Collections
-
- each, map,
- reduce, reduceRight,
- find, filter,
- reject, all,
- any, include,
- invoke, pluck,
- max, min,
- sortBy, groupBy,
- sortedIndex, shuffle,
- toArray, size
-
- Arrays
-
- first, initial, last, rest,
- compact, flatten, without,
- union, intersection, difference,
- uniq, zip, indexOf,
- lastIndexOf, range
-
- Functions
-
- bind, bindAll,
- memoize, delay, defer,
- throttle, debounce,
- once, after, wrap, compose
-
- Objects
-
- keys, values,
- functions, extend, defaults, clone, tap,
- isEqual, isEmpty, isElement,
- isArray, isArguments, isFunction, isString,
- isNumber, isBoolean, isDate, isRegExp,
- isNaN, isNull,
- isUndefined
-
-
- Utility
-
- noConflict,
- identity, times,
- mixin, uniqueId,
- escape, template
-
- You can use Underscore in either an object-oriented or a functional style, - depending on your preference. The following two lines of code are - identical ways to double a list of numbers. -
- -
-_.map([1, 2, 3], function(n){ return n * 2; });
-_([1, 2, 3]).map(function(n){ return n * 2; });
-
- - Using the object-oriented style allows you to chain together methods. Calling - chain on a wrapped object will cause all future method calls to - return wrapped objects as well. When you've finished the computation, - use value to retrieve the final value. Here's an example of chaining - together a map/flatten/reduce, in order to get the word count of - every word in a song. -
- -
-var lyrics = [
- {line : 1, words : "I'm a lumberjack and I'm okay"},
- {line : 2, words : "I sleep all night and I work all day"},
- {line : 3, words : "He's a lumberjack and he's okay"},
- {line : 4, words : "He sleeps all night and he works all day"}
-];
-
-_.chain(lyrics)
- .map(function(line) { return line.words.split(' '); })
- .flatten()
- .reduce(function(counts, word) {
- counts[word] = (counts[word] || 0) + 1;
- return counts;
-}, {}).value();
-
-=> {lumberjack : 2, all : 4, night : 2 ... }
-
- - In addition, the - Array prototype's methods - are proxied through the chained Underscore object, so you can slip a - reverse or a push into your chain, and continue to - modify the array. -
- -
each_.each(list, iterator, [context])
@@ -511,7 +582,7 @@ _.size({one : 1, two : 2, three : 3});
=> 3
-
Note: All array functions will also work on the arguments object. @@ -707,7 +778,7 @@ _.range(0); => [] -
bind_.bind(function, object, [*arguments])
@@ -881,7 +952,7 @@ welcome('moe');
=> 'hi: moe!'
-
keys_.keys(object)
@@ -1126,7 +1197,7 @@ _.isUndefined(window.missingVariable);
=> true
-
noConflict_.noConflict()
@@ -1254,14 +1325,59 @@ var template = _.template("Hello {{ name }}!");
template({name : "Mustache"});
=> "Hello Mustache!"
-
+ You can use Underscore in either an object-oriented or a functional style, + depending on your preference. The following two lines of code are + identical ways to double a list of numbers. +
+ +
+_.map([1, 2, 3], function(n){ return n * 2; });
+_([1, 2, 3]).map(function(n){ return n * 2; });
+
+ + Using the object-oriented style allows you to chain together methods. Calling + chain on a wrapped object will cause all future method calls to + return wrapped objects as well. When you've finished the computation, + use value to retrieve the final value. Here's an example of chaining + together a map/flatten/reduce, in order to get the word count of + every word in a song. +
+ +
+var lyrics = [
+ {line : 1, words : "I'm a lumberjack and I'm okay"},
+ {line : 2, words : "I sleep all night and I work all day"},
+ {line : 3, words : "He's a lumberjack and he's okay"},
+ {line : 4, words : "He sleeps all night and he works all day"}
+];
+
+_.chain(lyrics)
+ .map(function(line) { return line.words.split(' '); })
+ .flatten()
+ .reduce(function(counts, word) {
+ counts[word] = (counts[word] || 0) + 1;
+ return counts;
+}, {}).value();
+
+=> {lumberjack : 2, all : 4, night : 2 ... }
+
+ + In addition, the + Array prototype's methods + are proxied through the chained Underscore object, so you can slip a + reverse or a push into your chain, and continue to + modify the array. +
chain_.chain(obj)
Returns a wrapped object. Calling methods on this object will continue
- to return wrapped objects until value is used. (
- A more realistic example.)
+ to return wrapped objects until value is used.
var stooges = [{name : 'curly', age : 25}, {name : 'moe', age : 21}, {name : 'larry', age : 23}];
@@ -1283,7 +1399,7 @@ _([1, 2, 3]).value();
=> [1, 2, 3]
-