7685 Commits

Author SHA1 Message Date
Mike Frawley
263b1ee92d add #buildLookup method to turn collection in to a fast lookup hash
implement #without in terms of it
add tests and internal docs
2010-02-17 10:12:22 -06:00
Mike Frawley
1b1943b0ca implement include in terms of detect 2010-02-17 09:53:36 -06:00
Mike Frawley
76bbfddd95 our #reduceRight delegates to #reduce after reversing.
no need to reimplement it.

also, reduceRight is worthless :)
2010-02-17 09:51:38 -06:00
Mike Frawley
130e860ecf improve #isEmpty implementation. add 2 tests 2010-02-17 09:48:29 -06:00
Mike Frawley
386ee8ade9 add reference to underscore.js on docs page, since this is a good place to play around with it in the console 2010-02-17 09:45:24 -06:00
Mike Frawley
c43de549ba Create #alias method, callable on any object, _ by default.
While I'm not a fan of making abstractions where a simpe solution
exists, I think this is good as it makes a public API for extending
underscore, therefore making it "ok" to make your own alias names.

Also give us some future proofing in case we ever add in hooks on
method definition. For example, right now if you add a method
or make an alias in user code, it isn't added to the wrapper prototype.

Added tests and inline docs, no external docs
2010-02-17 09:41:18 -06:00
Mike Frawley
c4daac089b delegate to native Object.keys in nightlies 2010-02-17 09:26:34 -06:00
Mike Frawley
7ec8d12d6c rename underscore methods after the native [] method names, aliases for ruby versions
Even though the native methods have worse names (forEach, every, some),
since this library is trying to smooth over the native language it makes
more sense to use the native names, and provide aliases for more sensible
names from other languages, not the other way around.

Note this doesn't change any external usage, it just makes more sense.

This should also be useful for abstraction purposes for building underscore
functions, something like:

  addFn('some', {has_native: true, our_version: function () {...}})

this way we could feature detect on load for native versions and build a
function, and also have the option to turn off native versions for testing
our implementation.

I Also standardized the comments to look like:
  Delegates to JavaScript 1.x's native y if available.
2010-02-17 09:23:38 -06:00
Mike Frawley
59a4f49bfa Make internal var each = _.each
We use it everwhere, so this should be a slight speedup
but make code more readable
2010-02-17 09:05:45 -06:00
Jeremy Ashkenas
11e7af06e9 close that iframe document after writing to it 2010-02-08 07:12:40 -05:00
Jeremy Ashkenas
d01bb56833 adding type tests across iframes for all isType functions 2010-02-05 08:22:40 -05:00
Jeremy Ashkenas
5b5ee87c7a Underscore 0.5.8, with collection functions that once again work on NodeLists and HTMLCollections 2010-01-28 00:55:41 -05:00
Jeremy Ashkenas
21f37e43a1 adding duck typing section so that it's not unexpected 2010-01-27 14:05:27 -05:00
Jeremy Ashkenas
30858c50a8 added suggested speed boost for isNumber 2010-01-20 13:50:08 -05:00
Jeremy Ashkenas
52ac3db77c Underscore 0.5.7 is on the books 2010-01-20 13:17:28 -05:00
Jeremy Ashkenas
7ec091cc55 safer isArguments function -- make sure we're not dealing with strings or functions 2010-01-20 12:45:32 -05:00
Jed Schmidt
4a94246fd1 added obj.calle check to isArguments, to prevent misfiring for typeof String 2010-01-20 10:18:45 -07:00
Jeremy Ashkenas
7d9e603be8 Underscore 0.5.6, with custom template delimiters 2010-01-18 12:45:04 -05:00
noah
94195e661d Made _.template delimeters customizable 2010-01-15 23:25:52 -05:00
Jeremy Ashkenas
4f1a72da51 update docs to mention native 'reduce' -- but it's JS 1.8, not 1.6 2010-01-14 09:39:58 -05:00
Jeremy Ashkenas
cda9099a21 Underscore 0.5.5, with a fix for OOP-wrapping in MobileSafari, thanks to terrcin. 2010-01-09 19:34:32 -05:00
Jeremy Ashkenas
6866ffb840 adding a test for single quotes in templates 2010-01-05 11:28:29 -05:00
Jeremy Ashkenas
0a8a4834b2 Underscore 0.5.4 -- bugfix for single quotes in _.template strings 2010-01-05 11:26:14 -05:00
Jeremy Ashkenas
fde8b1f63f Underscore 0.5.3 2010-01-04 11:34:26 -05:00
Jeremy Ashkenas
75a31fffc5 adding boolean coercions to the faster isType methods 2010-01-04 10:20:46 -05:00
Jeremy Ashkenas
abb0f7f194 _.toArray is just _.values for objects 2010-01-03 22:05:10 -05:00
Jeremy Ashkenas
6427ac5813 22k now in dev mode 2010-01-01 21:36:01 -05:00
Jeremy Ashkenas
385404b685 Underscore 0.5.2 2010-01-01 21:32:44 -05:00
Jeremy Ashkenas
4be6a194cd replacing all isType tests that relied on string comparisons with versions that check for existence of known methods and properties. Less safe, but more than an order of magnitude faster. 2010-01-01 19:05:34 -05:00
Jeremy Ashkenas
d49196f2e7 pulling Evgeniy Dolzhenko's patch to add _.tap, with tests 2009-12-11 09:25:20 -05:00
Jeremy Ashkenas
c17879453a utf8 meta tag 2009-12-10 14:14:48 -05:00
Jeremy Ashkenas
a418153800 quick fix for 0.5.1 for IE -- need to define functions in the right order 2009-12-09 14:36:19 -05:00
Jeremy Ashkenas
4042a38dc6 Underscore 0.5.1 2009-12-09 14:22:05 -05:00
Jeremy Ashkenas
5c314d206e adding an isArguments checker and enabling iteration (using each) over JS object hashes that have numeric length properties 2009-12-09 13:41:19 -05:00
Jeremy Ashkenas
225d795836 merging in iamnoah's optimizations for the isType family of functions, and other references to core prototoypes 2009-12-09 12:44:55 -05:00
Jeremy Ashkenas
e863fbf285 Merge branch 'master' of git://github.com/iamnoah/underscore 2009-12-09 12:07:24 -05:00
Noah Sloan
76cccb6a2d added JSLitmus tests for isType functions 2009-12-09 10:25:58 -06:00
Jeremy Ashkenas
2ba87d6b44 adding test case for previous commit 2009-12-09 11:20:09 -05:00
Jeremy Ashkenas
99564138e8 added an extra check in isEqual to test for falsy against truthy values (so as to short circuit before trying to look for properties on null) 2009-12-09 11:17:30 -05:00
Jeremy Ashkenas
3eb9c28039 Underscore shouldn't be able to iterate over the letters of a string cross-browser -- indexing into a string isn't supported in IE 2009-12-08 17:31:01 -05:00
Noah Sloan
37930f92e0 doh. messed up isNumber fix 2009-12-08 16:03:53 -06:00
Noah Sloan
6554c6d976 have to define isNumber before _.each will work in IE 2009-12-08 15:57:04 -06:00
Noah Sloan
a5454d6972 cache hasOwnProperty 2009-12-08 14:24:44 -06:00
Noah Sloan
38cae13d69 cache wrapper methods 2009-12-08 14:21:05 -06:00
Noah Sloan
8c7fcb7781 cache is string and toString to improve performance 2009-12-08 14:11:28 -06:00
Jeremy Ashkenas
0ed4212ec6 adding pervasive safety checks for using Underscore functions on objects that jsut happen to have 'map', 'reduce', or 'filter' etc. properties that aren't functions. 2009-12-08 00:06:34 -05:00
Jeremy Ashkenas
30329c051b dont try to look at the keys of zero-length arrays or arguments objects when calling each() 2009-12-07 23:41:55 -05:00
Jeremy Ashkenas
2afcffb30a added guards to _.first and _.rest and tests, they now work as function parameters to _.map 2009-12-07 23:36:31 -05:00
Jeremy Ashkenas
21e0cbc229 simplified the bindAll example 2009-12-07 00:26:00 -05:00
Jeremy Ashkenas
f2670259d1 0.5.0 is out, with variants of grayrest's patches 2009-12-07 00:14:07 -05:00