Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: jashkenas/underscore
base: 0.5.8
...
head fork: jashkenas/underscore
compare: 0.6.0
Checking mergeability… Don't worry, you can still create the pull request.
Commits on Feb 05, 2010
@jashkenas adding type tests across iframes for all isType functions d01bb56
Commits on Feb 08, 2010
@jashkenas close that iframe document after writing to it 11e7af0
Commits on Feb 17, 2010
@ratbeard ratbeard Make internal var each = _.each
We use it everwhere, so this should be a slight speedup
but make code more readable
59a4f49
@ratbeard ratbeard rename underscore methods after the native [] method names, aliases f…
…or 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.
7ec8d12
@ratbeard ratbeard delegate to native Object.keys in nightlies c4daac0
@ratbeard ratbeard 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
c43de54
@ratbeard ratbeard add reference to underscore.js on docs page, since this is a good pla…
…ce to play around with it in the console
386ee8a
@ratbeard ratbeard improve #isEmpty implementation. add 2 tests 130e860
@ratbeard ratbeard our #reduceRight delegates to #reduce after reversing.
no need to reimplement it.

also, reduceRight is worthless :)
76bbfdd
@ratbeard ratbeard implement include in terms of detect 1b1943b
@ratbeard ratbeard add #buildLookup method to turn collection in to a fast lookup hash
implement #without in terms of it
add tests and internal docs
263b1ee
@ratbeard ratbeard add #times utility method.
_(3).times(alert)

added tests and internal docs
5a5e14d
Commits on Feb 22, 2010
@ratbeard ratbeard delegate to ECMA5 native Array.isArray if available b774bf7
@ratbeard ratbeard Much better strategy for calling native Array methods.
Compare an object's function with === to the native
version before calling it.  That is, don't just assume that
because an object has a 'filter' property thats a function,
that we should call that in _.filter().

Expose the native methods found as _.native

On the way towards being able to turn off native implementations,
though there are tradeoffs...
bb250e7
@ratbeard ratbeard make a local variable that points to Array.prototype since the former…
… is not min'd down.

Won't effect gzip size, but reduces min size.  Saves about:

15 bytes per instance * 13 instances ≅ 200 bytes
31f0f8c
Commits on Feb 23, 2010
@ratbeard ratbeard Add rake task to build with closure advanced optimizations.
You would use this to compile your code _with_ underscore, to
remove all those dead underscore functions you don't use.

Slight tweak to code to `root._` code to get working, and must
remove anonymous wrapper function for current closure compiler to
remove dead code.
b5449ca
@ratbeard ratbeard use `var native_reduceRight` etc. variables instead of `Native = { re…
…duceRight: ... }`

This way we only get the native versions of functions we use.
Will make testing non-native versions as we can't just swap do `_.Native = {}`,
but this wouldn't have worked for `isArray` and `keys` anyways, as these are
looked up on initialization, so I think the solution is to have an init()
method on underscore where we will re-initialize functions and try and use
native versions then
164e19c
@ratbeard ratbeard Revert "Create #alias method, callable on any object, _ by default."
This reverts commit c43de54.

Conflicts:

	test/objects.js
59d383c
@ratbeard ratbeard Re-arrange baseline setup section.
Put all variable declartions in a row, so they can all be
chained together with commas by compiler.

Move wrapper creation code down in OO section.  Not necissary
for `var wrapper` to be defined when _ constructor is defined.
Preparing way to make OO wrapping optional..
1cf73c5
Commits on Feb 24, 2010
@ratbeard ratbeard make _.initWrapper() that builds the wrapper prototye
The intention is that underscore Consumers MUST call _.initWrapper()
in their code to allow the OO style usage, or a runtime error is thrown.
This would break backwards compatability, so for the moment I call
initWrapper myself at the end of underscore.

However, if I comment out my call to initWrapper and don't call it
in user code, then the compiler can strip an empty underscore with
no user code from 2137 -> 100 bytes.  Making the user explicitly say
they want OO wrapping is the only way to achieve this, otherwise the
compiler will always keep the OO wrapper code around.
f591f68
@ratbeard ratbeard modify rakefile build_advanced to strip off my call to _.initWrapper() c9b41a4
@ratbeard ratbeard only initWrapper() once. make wrapper constructor accessable as `_._w…
…rapper`.

Previously, there was no way to get at the OO wrapper object.
So if a user added a custom method on to _, or defined a custom
alias, it would not be reflected in the wrapper.  Now it is at
least possible, though there is no API to do it.  I alluded to
making one in my commit that added _.alias() (which I recently reverted,
as it added weight to the stripped version), but honestly I think
the wrapping behavior should go in to a seperate library, not because
it is bad, but because it is an awesome pattern that I want to use
on objects other than underscore.
b8fd129
@rfletcher rfletcher Added tests for templates with regex-significant characters in their …
…delimiters
625adb8
@rfletcher rfletcher Added failing test for quotes in statements with regex-significant ch…
…aracters in tokens
38a8259
@rfletcher rfletcher Escape template delimiters before using them in a RegExp 3482ec1
@jashkenas merging rlfletchers branch with a safer _.template when the template …
…delimiter includes RegExp characters.
8756331
@jashkenas merging ratbeard's numerous improvements a2aab7c
@jashkenas merging ratbeard/closure 2ec05e7
@jashkenas waypoint commit on the big merge 39024c3
@jashkenas camelcase conventions 69bb349
@jashkenas remove the advanced_optimizations concessions and the advanced_optimi…
…zations rake task. Simple will do.
2c8fbe7
@jashkenas make the new faster isEmpty a little safer too 7824d63
@jashkenas avoiding isFunction in _.include 412d2e4
@jashkenas reverted _.buildLookup, restoring _.without to it's previous implemen…
…tation, adding a test for object identity
d7acbca
@jashkenas don't use root as the default 'this' for a bound function, use an emp…
…ty object instead.
65d2c30
@jashkenas added documentation for _.times c23b2ce
@jashkenas adding an _.mixin utility function that allows you to add functions t…
…o Underscore (also used internally)
d855def
@jashkenas move the OOP-setup bits down into that section for clarity. JavaScrip…
…t allows this it's pre-declaration pass.
85d8f90
@jashkenas it's now 2010, and adding a list of contributors (everyone who's ever…
… gotten a patch in)
513f878
@jashkenas added documentation for _.mixin 8d632ad
@jashkenas A whole slew of IE fixes and safety guards. 71b6e4f
@jashkenas Underscore 0.6 is on the books. Think of it as a pre-release of 1.0 b8a633a
Something went wrong with that request. Please try again.