Commit Graph

140 Commits

Author SHA1 Message Date
Jeremy Ashkenas
7973d7263c slight speedup to _.template 2010-08-26 01:02:09 -04:00
Jeremy Ashkenas
fc90d57e36 Underscore.js 1.1.0 2010-08-18 09:26:36 -04:00
Jeremy Ashkenas
b2b5a5390b merging a variant of svieira's fix for preserving whitespace within templates. 2010-07-20 13:37:27 -04:00
Jeremy Ashkenas
ef396a9e13 Aliasing _.contains to _.include 2010-07-15 10:18:11 -04:00
Jeremy Ashkenas
9827f87611 (breaking change) moving _.reduce's method signature to that of ECMA5. _.reduce(obj, iterator, memo). Updated tests and docs. 2010-07-15 09:50:55 -04:00
Nick Stenning
e81a2ec516 Allow _.template functions to be called with no arguments.
This change simply allows templates to be called with no arguments, for a behaviour equivalent to being called with an empty object, {}.
2010-07-14 11:09:05 +01:00
Jeremy Ashkenas
29e2c832bc Underscore 1.0.4, with _.memoize 2010-06-22 09:21:03 -04:00
Jeremy Ashkenas
bce016fc72 Underscore 1.0.3 2010-06-14 15:59:24 -04:00
Ryan W Tenney
0e8ca3cb97 NaN is never equal to NaN. Fixed in underscore.js and underscore-min.js, updated tests in test/objects.js 2010-06-12 17:10:48 -04:00
Jeremy Ashkenas
79f65b440a Even though it's not really part of the API, making _.isEmpty work with Strings cross-browser. 2010-04-06 13:01:45 -04:00
Jeremy Ashkenas
c8858f4c8f Underscore 1.0.2, with a fixed _.isArguments for Opera 2010-03-23 11:06:11 -04:00
Jeremy Ashkenas
a6578068d2 Underscore 1.0.1 -- bugfix release for _.isEqual 2010-03-19 10:07:21 -04:00
Jeremy Ashkenas
1d787815af Underscore 1.0 2010-03-18 11:41:02 -04:00
Jeremy Ashkenas
d69c5ae83b merging ratbeard's patch for allowing multiple arguments to be passed to extend, with docs 2010-03-05 15:29:32 -05:00
Mike Frawley
4085b68be4 enhance #extend to allow taking multiple source objects.
This is done in jquery, extjs, and others as well.

added tests, no docs
2010-03-05 15:24:59 -05:00
Jeremy Ashkenas
8c6694c242 comment grammar 2010-03-05 15:24:53 -05:00
Jeremy Ashkenas
9903905175 merging mrjjwright's isBoolean, with tests, docs, and credit 2010-02-27 00:03:36 -05:00
John Wright
bd271e4794 added _.isBoolean function 2010-02-26 21:46:58 -07:00
Mike Frawley
d1ccc1e841 remove unused index variable in forEach 2010-02-26 08:47:36 -06:00
Jeremy Ashkenas
b8a633a5fd Underscore 0.6 is on the books. Think of it as a pre-release of 1.0 2010-02-24 15:10:40 -05:00
Jeremy Ashkenas
71b6e4f555 A whole slew of IE fixes and safety guards. 2010-02-24 15:01:51 -05:00
Jeremy Ashkenas
85d8f90bca move the OOP-setup bits down into that section for clarity. JavaScript allows this it's pre-declaration pass. 2010-02-24 13:49:57 -05:00
Jeremy Ashkenas
d855def438 adding an _.mixin utility function that allows you to add functions to Underscore (also used internally) 2010-02-24 13:44:46 -05:00
Jeremy Ashkenas
65d2c30312 don't use root as the default 'this' for a bound function, use an empty object instead. 2010-02-24 12:57:26 -05:00
Jeremy Ashkenas
d7acbca2ce reverted _.buildLookup, restoring _.without to it's previous implementation, adding a test for object identity 2010-02-24 12:53:35 -05:00
Jeremy Ashkenas
412d2e4486 avoiding isFunction in _.include 2010-02-24 12:47:40 -05:00
Jeremy Ashkenas
7824d63ce8 make the new faster isEmpty a little safer too 2010-02-24 12:43:57 -05:00
Jeremy Ashkenas
2c8fbe7875 remove the advanced_optimizations concessions and the advanced_optimizations rake task. Simple will do. 2010-02-24 12:16:45 -05:00
Jeremy Ashkenas
69bb3490b3 camelcase conventions 2010-02-24 12:10:07 -05:00
Jeremy Ashkenas
39024c35a6 waypoint commit on the big merge 2010-02-24 12:03:08 -05:00
Jeremy Ashkenas
2ec05e758b merging ratbeard/closure 2010-02-24 11:45:05 -05:00
Jeremy Ashkenas
a2aab7c699 merging ratbeard's numerous improvements 2010-02-24 11:38:27 -05:00
Jeremy Ashkenas
875633141a merging rlfletchers branch with a safer _.template when the template delimiter includes RegExp characters. 2010-02-24 11:03:47 -05:00
Rick Fletcher
3482ec1259 Escape template delimiters before using them in a RegExp 2010-02-23 23:47:28 -08:00
Mike Frawley
b8fd129130 only initWrapper() once. make wrapper constructor accessable as _._wrapper.
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.
2010-02-23 18:20:42 -06:00
Mike Frawley
c9b41a4996 modify rakefile build_advanced to strip off my call to _.initWrapper() 2010-02-23 18:14:54 -06:00
Mike Frawley
f591f68546 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.
2010-02-23 18:04:47 -06:00
Mike Frawley
1cf73c5474 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..
2010-02-23 17:39:22 -06:00
Mike Frawley
59d383c151 Revert "Create #alias method, callable on any object, _ by default."
This reverts commit c43de549ba.

Conflicts:

	test/objects.js
2010-02-23 17:26:32 -06:00
Mike Frawley
164e19c121 use var native_reduceRight etc. variables instead of Native = { reduceRight: ... }
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
2010-02-23 17:13:18 -06:00
Mike Frawley
b5449ca89a 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.
2010-02-23 17:01:18 -06:00
Mike Frawley
31f0f8c54c 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
2010-02-22 16:02:36 -06:00
Mike Frawley
bb250e7205 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...
2010-02-22 15:50:01 -06:00
Mike Frawley
b774bf7ca9 delegate to ECMA5 native Array.isArray if available 2010-02-22 14:37:54 -06:00
Mike Frawley
5a5e14d7a4 add #times utility method.
_(3).times(alert)

added tests and internal docs
2010-02-17 10:21:59 -06:00
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
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