Lines Matching refs:_

2   var _ = typeof require == 'function' ? require('..') : window._;  variable
10 var bound = _.bind(func, context);
13 bound = _(func).bind(context);
16 bound = _.bind(func, null, 'curly');
22 func = _.bind(func, this, 'hello');
25 func = _.bind(func, this, 'curly');
29 func = _.bind(func, this, 'hello', 'moe', 'curly');
33 _.bind(func, 0, 0, 'can bind a function to `0`')();
34 _.bind(func, '', '', 'can bind a function to an empty string')();
35 _.bind(func, false, false, 'can bind a function to `false`')();
40 var boundf = _.bind(F, {hello: 'moe curly'});
47 …assert.raises(function() { _.bind('notafunction'); }, TypeError, 'throws an error when binding to …
52 var func = function() { return this.name + ' ' + _.toArray(arguments).join(' '); };
54 obj.func = _.partial(func, 'a', 'b');
57 obj.func = _.partial(func, _, 'b', _, 'd');
60 func = _.partial(function() { return arguments.length; }, _, 'b', _, 'd');
64 func = _.partial(function() { return typeof arguments[2]; }, _, 'b', _, 'd');
75 var MyWidgetWithCoolOpts = _.partial(MyWidget, _, {a: 1});
81 _.partial.placeholder = obj;
82 func = _.partial(function() { return arguments.length; }, obj, 'b', obj, 'd');
85 _.partial.placeholder = {};
86 func = _.partial(function() { return arguments.length; }, obj, 'b', obj, 'd');
89 _.partial.placeholder = _;
100 _.bindAll(moe, 'getName', 'sayHi');
110 sayLast: function() { return this.sayHi(_.last(arguments)); }
113 …assert.raises(function() { _.bindAll(moe); }, Error, 'throws an error for bindAll with no function…
114 …assert.raises(function() { _.bindAll(moe, 'sayBye'); }, TypeError, 'throws an error for bindAll if…
115 …assert.raises(function() { _.bindAll(moe, 'name'); }, TypeError, 'throws an error for bindAll if t…
117 _.bindAll(moe, 'sayHi', 'sayLast');
124 _.bindAll(moe, ['getName']);
134 fib = _.memoize(fib); // Redefine `fib` for memoization
140 var fastO = _.memoize(o);
145 var upper = _.memoize(function(s) {
155 var hashed = _.memoize(function(key) {
166 var objCacher = _.memoize(function(value, key) {
182 _.delay(function(){ delayed = true; }, 100);
191 _.defer(function(bool){ deferred = bool; }, true);
192 _.delay(function(){ assert.ok(deferred, 'deferred the function'); done(); }, 50);
200 var throttledIncr = _.throttle(incr, 32);
204 _.delay(function(){ assert.equal(counter, 2, 'incr was throttled'); done(); }, 64);
212 var throttledUpdate = _.throttle(update, 32);
214 _.delay(function(){ throttledUpdate(3); }, 64);
216 _.delay(function(){ assert.equal(value, 3, 'updated to latest value'); done(); }, 96);
224 var throttledIncr = _.throttle(incr, 32);
226 _.delay(function(){
237 var throttledIncr = _.throttle(incr, 32);
239 _.delay(function(){ assert.equal(counter, 2, 'incr was called twice'); done(); }, 64);
247 var throttledIncr = _.throttle(incr, 30);
250 _.delay(function(){
263 var throttledIncr = _.throttle(incr, 100);
267 _.delay(saveResult, 50);
268 _.delay(saveResult, 150);
269 _.delay(saveResult, 160);
270 _.delay(saveResult, 230);
271 _.delay(function() {
288 var throttledIncr = _.throttle(incr, 32);
297 _.delay(function() {
308 var throttledIncr = _.throttle(incr, 60, {leading: false});
313 _.delay(function() {
324 var throttledIncr = _.throttle(incr, 100, {leading: false});
327 _.delay(throttledIncr, 50);
328 _.delay(throttledIncr, 60);
329 _.delay(throttledIncr, 200);
332 _.delay(function() {
336 _.delay(function() {
347 var throttledIncr = _.throttle(incr, 100, {leading: false});
353 _.delay(function() {
364 var throttledIncr = _.throttle(incr, 60, {trailing: false});
369 _.delay(function() {
375 _.delay(function() {
387 var throttledIncr = _.throttle(incr, 100);
388 var origNowFunc = _.now;
392 _.now = function() {
396 _.delay(function() {
400 _.now = origNowFunc;
420 throttledAppend = _.throttle(append, 32);
423 _.delay(function(){
433 var throttledIncr = _.throttle(incr, 32);
440 _.delay(function(){ assert.equal(counter, 3, 'incr was throttled'); done(); }, 64);
447 var throttledIncr = _.throttle(incr, 32, {leading: false});
452 _.delay(function(){ assert.equal(counter, 0, 'incr was throttled'); done(); }, 64);
460 var debouncedIncr = _.debounce(incr, 32);
462 _.delay(debouncedIncr, 16);
463 _.delay(function(){ assert.equal(counter, 1, 'incr was debounced'); done(); }, 96);
471 var debouncedIncr = _.debounce(incr, 32);
474 _.delay(function(){ assert.equal(counter, 0, 'incr was not called'); done(); }, 96);
483 var debouncedIncr = _.debounce(incr, 64, true);
489 _.delay(debouncedIncr, 16);
490 _.delay(debouncedIncr, 32);
491 _.delay(debouncedIncr, 48);
492 _.delay(function(){
507 var debouncedIncr = _.debounce(incr, 64, true);
514 _.delay(debouncedIncr, 16);
515 _.delay(debouncedIncr, 32);
516 _.delay(debouncedIncr, 48);
517 _.delay(function(){ assert.equal(counter, 2, 'incr was debounced'); done(); }, 128);
524 var debouncedIncr = _.debounce(function(){
530 _.delay(function(){ assert.equal(counter, 1, 'incr was debounced'); done(); }, 96);
537 var origNowFunc = _.now;
538 var debouncedIncr = _.debounce(function(){
545 _.now = function() {
549 _.delay(function() {
553 _.now = origNowFunc;
572 debouncedAppend = _.debounce(append, 32);
575 _.delay(function(){
583 var increment = _.once(function(){ return ++num; });
593 var f = _.once(function(){
602 …var backwards = _.wrap(greet, function(func, name){ return func(name) + ' ' + name.split('').rever…
607 obj.hi = _.wrap(inner, function(fn){ return fn() + this.name; });
611 var wrapped = _.wrap(noop, function(){ return Array.prototype.slice.call(arguments, 0); });
618 assert.equal(_.negate(isOdd)(2), true, 'should return the complement of the given function');
619 assert.equal(_.negate(isOdd)(3), false, 'should return the complement of the given function');
625 var composed = _.compose(exclaim, greet);
628 composed = _.compose(greet, exclaim);
644 composed = _.compose(f, g, h);
651 var after = _.after(afterAmount, function() {
667 var before = _.before(beforeAmount, function() { beforeCalled++; });
678 var increment = _.before(3, function(){ return ++this.num; });
679 _.times(10, increment, context);
685 var identity = _.iteratee();
686 assert.equal(identity, _.identity, '_.iteratee is exposed as an external function.');
691 _.each([_.iteratee(fn), _.iteratee(fn, {})], function(cb) {
693 assert.deepEqual(_.toArray(cb(1, 2, 3)), _.range(1, 4));
694 assert.deepEqual(_.toArray(cb(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)), _.range(1, 11));
698 var builtinIteratee = _.iteratee;
699 _.iteratee = function(value) {
701 if (_.isRegExp(value)) return function(obj) {
710 assert.deepEqual(_.countBy(collection, /b/g), {0: 1, 1: 1, 2: 1});
711 assert.equal(_.every(collection, /b/g), false);
712 assert.deepEqual(_.filter(collection, /b/g), ['bar', 'bbiz']);
713 assert.equal(_.find(collection, /b/g), 'bar');
714 assert.equal(_.findIndex(collection, /b/g), 1);
715 assert.equal(_.findKey(collection, /b/g), 1);
716 assert.equal(_.findLastIndex(collection, /b/g), 2);
717 assert.deepEqual(_.groupBy(collection, /b/g), {0: ['foo'], 1: ['bar'], 2: ['bbiz']});
718 assert.deepEqual(_.indexBy(collection, /b/g), {0: 'foo', 1: 'bar', 2: 'bbiz'});
719 assert.deepEqual(_.map(collection, /b/g), [0, 1, 2]);
720 assert.equal(_.max(collection, /b/g), 'bbiz');
721 assert.equal(_.min(collection, /b/g), 'foo');
722 assert.deepEqual(_.partition(collection, /b/g), [['bar', 'bbiz'], ['foo']]);
723 assert.deepEqual(_.reject(collection, /b/g), ['foo']);
724 assert.equal(_.some(collection, /b/g), true);
725 assert.deepEqual(_.sortBy(collection, /b/g), ['foo', 'bar', 'bbiz']);
726 assert.equal(_.sortedIndex(collection, 'blah', /b/g), 1);
727 assert.deepEqual(_.uniq(collection, /b/g), ['foo', 'bar', 'bbiz']);
730 assert.deepEqual(_.mapObject(objCollection, /b/g), {a: 0, b: 1, c: 2});
733 _.iteratee = builtinIteratee;
738 _.restArgs(function(a, args) {
743 _.restArgs(function(a, args) {
748 _.restArgs(function(a, b, c, args) {
754 _.restArgs(function() {
758 _.restArgs(function(array, iteratee, context) {